Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch image quota to shared informers #12088

Merged
merged 1 commit into from
Jan 14, 2017
Merged

Conversation

soltysh
Copy link
Contributor

@soltysh soltysh commented Dec 1, 2016

This is addressing this card: https://trello.com/c/Gc7NkZoe/765-5-quota-performance-improvements

@deads2k is that good direction, I prefer asking rather than going to deep with it?

@soltysh
Copy link
Contributor Author

soltysh commented Dec 1, 2016

Note to myself, try looking into how to solve the problem of "use this cache if available".

@soltysh
Copy link
Contributor Author

soltysh commented Dec 1, 2016

@openshift-bot openshift-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 1, 2016
@soltysh soltysh changed the title WIP: Switch quota to shared informers Switch image quota to shared informers Jan 11, 2017
@soltysh soltysh removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 11, 2017
@soltysh
Copy link
Contributor Author

soltysh commented Jan 11, 2017

@deads2k this is ready for review, if there's something more that should be added to fulfill the attached card lemme know

@@ -221,7 +221,7 @@ func BuildMasterConfig(options configapi.MasterConfig) (*MasterConfig, error) {

kubeletClientConfig := configapi.GetKubeletClientConfig(options)

quotaRegistry := quota.NewAllResourceQuotaRegistry(privilegedLoopbackOpenShiftClient, privilegedLoopbackKubeClientset, kubeInformerFactory)
quotaRegistry := quota.NewAllResourceQuotaRegistry(informerFactory, privilegedLoopbackOpenShiftClient, privilegedLoopbackKubeClientset)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this one used for admission? The admission one probably doesn't need the informers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This one already accepted informers, but just k8s ones, but I needed both k8s and origin ones. I've also moved this parameter from the end of this function call as the first argument, to make it similar to other methods. And since quota.NewAllResourceQuotaRegistry under covers creates evaluators which are now switched to informers, it's needed this way.

@deads2k
Copy link
Contributor

deads2k commented Jan 11, 2017

yeah, this is what I meant.

@soltysh
Copy link
Contributor Author

soltysh commented Jan 12, 2017

[test]

results = append(results, &itemList.Items[i])
results := make([]runtime.Object, 0, len(list))
for _, is := range list {
objCopy, err := kapi.Scheme.DeepCopy(is)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it necessary to deep-copy here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I don't I might end up modifying cache, and that's not desired, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

You should deep-copy when you are about to mutate but I am not sure if we gain much. I guess it depends on how much we mutate below this point.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Evaluator should not mutate, by design, so you might be right. I'll wait for @deads2k review and his advice on that, if you don't mind.

Copy link
Contributor

Choose a reason for hiding this comment

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

If I don't I might end up modifying cache, and that's not desired, right?

Quota counts won't do mutation. In general, we've tried to avoid unnecessary deep copies, so I'm used to seeing a pattern in controllers where you check whether you are likely to have changes against your shared cache reference. After you've eliminated all the obvious pre-checks, you can make a copy in one spot to make the code easier to reason about, but it should be minority of cases.

Doing this copy here would be too early for a normal controller and we happen to know in this case we don't need it, so I would skip the copies.

fakeClient.AddReactor("list", "imagestreams", imagetest.GetFakeImageStreamListHandler(t, tc.iss...))

evaluator := NewImageStreamEvaluator(fakeClient)
isInformer := cache.NewSharedIndexInformer(
Copy link
Contributor

Choose a reason for hiding this comment

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

This is just a straight counting evaluator, right? If so, I'm not sure you need a test at all. The counting is checked upstream.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You know I like more then less testing 😉

@deads2k
Copy link
Contributor

deads2k commented Jan 13, 2017

just the deep copy, then lgtm.

@soltysh
Copy link
Contributor Author

soltysh commented Jan 13, 2017

Comments addressed, will merge on green tests.

@openshift-bot
Copy link
Contributor

Evaluated for origin test up to e2dbd12

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/12839/) (Base Commit: 8a41d6f)

@soltysh
Copy link
Contributor Author

soltysh commented Jan 14, 2017

Merging on previous approval.

[merge]

@openshift-bot
Copy link
Contributor

Evaluated for origin merge up to e2dbd12

@openshift-bot
Copy link
Contributor

openshift-bot commented Jan 14, 2017

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/12875/) (Base Commit: 46bdbfa) (Image: devenv-rhel7_5677)

@openshift-bot openshift-bot merged commit b16b328 into openshift:master Jan 14, 2017
@soltysh soltysh deleted the card765 branch January 15, 2017 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants