Skip to content

Comments

Boskos: Remove downstream client#16206

Merged
k8s-ci-robot merged 7 commits intokubernetes:masterfrom
alvaroaleman:boskos-ctrl-client
Feb 11, 2020
Merged

Boskos: Remove downstream client#16206
k8s-ci-robot merged 7 commits intokubernetes:masterfrom
alvaroaleman:boskos-ctrl-client

Conversation

@alvaroaleman
Copy link
Member

@alvaroaleman alvaroaleman commented Feb 10, 2020

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/AcquireByState call, 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

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Feb 10, 2020
@k8s-ci-robot k8s-ci-robot added area/boskos Issues or PRs related to code in /boskos sig/testing Categorizes an issue or PR as relevant to SIG Testing. labels Feb 10, 2020
@sebastienvas sebastienvas removed their assignment Feb 10, 2020
Copy link
Contributor

@ixdy ixdy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how spammy is this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when is this set?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this comment is not really accurate anymore.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is an orthogonal change, the overarching goal of this PR is to allow using a cache

logrusutil.ComponentInit("boskos")
kubeClientOptions.AddFlags(flag.CommandLine)
var namespace string
flag.StringVar(&namespace, "namespace", corev1.NamespaceDefault, "namespace to install on")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a reason you put this in main() instead of with the rest of the flags above?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oversight, fixed

}

crd := &apiextensionsv1beta1.CustomResourceDefinition{
resourceCRD := &apiextensionsv1beta1.CustomResourceDefinition{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idle comment: we should probably update to apiextensions/v1 at some point.

return err
}

crd := &apiextensionsv1beta1.CustomResourceDefinition{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could've kept this generic and looped over the two types, right?

I guess the new version is a little easier to read.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This precludes a rolling upgrade, right, since we can't add the flag first, then upgrade the version, or the other way around

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The flag just got moved, it was part of the kubeOpts before

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 11, 2020
@k8s-ci-robot
Copy link
Contributor

[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

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 11, 2020
@k8s-ci-robot k8s-ci-robot merged commit 767a53b into kubernetes:master Feb 11, 2020
@k8s-ci-robot k8s-ci-robot added this to the v1.18 milestone Feb 11, 2020
alvaroaleman added a commit to alvaroaleman/test-infra that referenced this pull request Feb 12, 2020
…ctrl-client"

This reverts commit 767a53b, reversing
changes made to b253986.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. area/boskos Issues or PRs related to code in /boskos cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants