Boskos: Remove downstream client#16206
Conversation
Currently, controller-runtime requires list types to: * End in `List`: https://github.com/kubernetes-sigs/controller-runtime/blob/82a78f979a567e9ff215905e57082a163067d8da/pkg/client/client_cache.go#L60 * Use non-pointer types as Items: kubernetes-sigs/controller-runtime#656
ixdy
left a comment
There was a problem hiding this comment.
Thanks for taking this on! This change generally LG to me - just a few questions.
| "k8s.io/test-infra/boskos/crds" | ||
| ) | ||
|
|
||
| // Make debugging a bit easier |
There was a problem hiding this comment.
The go tests suppress all logrus logs unless the test fails, in which case the person debugging them most likely wants debug-level logs.
Not a strong opinion here though, I can also remove it again.
| type Storage struct { | ||
| resources, dynamicResourceLifeCycles storage.PersistenceLayer | ||
| resourcesLock sync.RWMutex | ||
| ctx context.Context |
There was a problem hiding this comment.
Never, added a commit to properly plug it through
| "k8s.io/test-infra/boskos/crds" | ||
| ) | ||
|
|
||
| // Storage is used to decouple ranch functionality with the resource persistence layer |
There was a problem hiding this comment.
this comment is not really accurate anymore.
There was a problem hiding this comment.
Do you think so? IMHO it is accurate for as long as we have our internal representation, because the Storage hides the external (CRD) one.
There was a problem hiding this comment.
well, I mostly meant that we're no longer depending on the storage.PersistenceLayer interface, and some things (like the runtime client and namespace) are now leaking through.
|
|
||
| o := &crds.ResourceObject{} | ||
| name := types.NamespacedName{Namespace: s.namespace, Name: resource.GetName()} | ||
| if err := s.client.Get(s.ctx, name, o); err != nil { |
There was a problem hiding this comment.
I assume this bug (where we effectively discard the resource version because we fetch latest and update blindly) will be addressed in a future PR?
There was a problem hiding this comment.
Yes, it is an orthogonal change, the overarching goal of this PR is to allow using a cache
boskos/cmd/boskos/boskos.go
Outdated
| logrusutil.ComponentInit("boskos") | ||
| kubeClientOptions.AddFlags(flag.CommandLine) | ||
| var namespace string | ||
| flag.StringVar(&namespace, "namespace", corev1.NamespaceDefault, "namespace to install on") |
There was a problem hiding this comment.
is there a reason you put this in main() instead of with the rest of the flags above?
| } | ||
|
|
||
| crd := &apiextensionsv1beta1.CustomResourceDefinition{ | ||
| resourceCRD := &apiextensionsv1beta1.CustomResourceDefinition{ |
There was a problem hiding this comment.
idle comment: we should probably update to apiextensions/v1 at some point.
| return err | ||
| } | ||
|
|
||
| crd := &apiextensionsv1beta1.CustomResourceDefinition{ |
There was a problem hiding this comment.
we could've kept this generic and looped over the two types, right?
I guess the new version is a little easier to read.
There was a problem hiding this comment.
Well yeah, looping would require to have a slice somewhere everyone who could think about adding a CRD will definitely find and I was too lazy to think about the best place for that :)
IMHO we should drop the whole CRD creation entirely, as that requires us to give CRD Create permissions, which shouldn't be needed. I didn't do that in this PR to keep the potential basis for debate as minimal as possible :)
There was a problem hiding this comment.
IMHO we should drop the whole CRD creation entirely, as that requires us to give CRD Create permissions, which shouldn't be needed. I didn't do that in this PR to keep the potential basis for debate as minimal as possible :)
I agree. #16266
5918544 to
ead8695
Compare
| username = flag.String("username", "", "Username used to access the Boskos server") | ||
| passwordFile = flag.String("password-file", "", "The path to password file used to access the Boskos server") | ||
| cleanerCount = flag.Int("cleaner-count", defaultCleanerCount, "Number of threads running cleanup") | ||
| namespace = flag.String("namespace", corev1.NamespaceDefault, "namespace to install on") |
There was a problem hiding this comment.
This precludes a rolling upgrade, right, since we can't add the flag first, then upgrade the version, or the other way around
There was a problem hiding this comment.
The flag just got moved, it was part of the kubeOpts before
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alvaroaleman, stevekuznetsov The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
This PR is a first step towards making Boskos use a cache underneath, which we need to speed the whole thing up, as it lists all Resources for each
Acquire/AcquireByStatecall, which is pretty slow because we have about 4k objects.This PR removes the downstream kube client we have in boskos and replaces it with the one from controller-runtime, of which an api-compatible cache-backed version exists.
Note that the PR does not change the client to be cache-backed yet, I will do that in a followup as this PR is big enough already.
/assign @ixdy @sebastienvas @stevekuznetsov