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

cluster quota to namespace mapping controller #9558

Merged
merged 3 commits into from
Jun 29, 2016

Conversation

deads2k
Copy link
Contributor

@deads2k deads2k commented Jun 24, 2016

Third commit: Needs to be moved and lacks any tests, but I'm interested in whether anyone has concerns about intent.

@derekwaynecarr This is like a doubly-linked project authz cache that cannot rely resource versions since quota tracks status.

Also added a create clusterquota command that I'll probably split into another pull. This should match create quota if we ever make one.

@openshift-bot openshift-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 25, 2016
@deads2k deads2k force-pushed the cq-03-reverse-index branch from 9782f29 to 4015e85 Compare June 27, 2016 12:12
@openshift-bot openshift-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 27, 2016
@deads2k deads2k force-pushed the cq-03-reverse-index branch from 4015e85 to a63bde1 Compare June 27, 2016 14:51
ClusterQuotaRecommendedName = "clusterquota"

clusterQuotaLong = `
Create a deployment config that uses a given image.
Copy link
Member

Choose a reason for hiding this comment

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

just a reminder to fix all this up.

@deads2k deads2k force-pushed the cq-03-reverse-index branch 2 times, most recently from 72afb8b to b0449ad Compare June 27, 2016 15:48
@derekwaynecarr
Copy link
Member

@deads2k - I won't have too much time today to dive deep into the cache side of things, but if i recall the complicated part of project cache was cluster acl changes requiring a full rebuild. I don't know if there is a similar style use case in your work here, but have not reasoned too deeply around it.

@deads2k
Copy link
Contributor Author

deads2k commented Jun 27, 2016

@Kargakis alright, the algorithm is ready for review, but I've got a really cool race.

  1. Add, Update, Delete a namespace really fast, before any of those are observed.
  2. Add or Update a quota that matches the Add or Update namespace
  3. The cache had the "bad" state for the namespace for some period of time. This makes the quota update the cache indicating a match.
  4. The ns Delete is compressed out and never delivered, so the improper match is never cleared.

Neat, right?

@deads2k deads2k force-pushed the cq-03-reverse-index branch 2 times, most recently from 168c6ea to 8276f5f Compare June 27, 2016 17:51
@deads2k deads2k force-pushed the cq-03-reverse-index branch from 8276f5f to a24ce97 Compare June 27, 2016 18:35
@deads2k deads2k changed the title [WIP] cluster quota to namespace mapping controller cluster quota to namespace mapping controller Jun 27, 2016
@deads2k
Copy link
Contributor Author

deads2k commented Jun 27, 2016

This is ready for review. I brought in 27341 because I was hitting races in my fuzzing unit test. I did not make our code do the work in the lock because we deadlocked I think I'd rather spend the time reworking onto shared informers instead of trying to fix the problem another way.

@deads2k
Copy link
Contributor Author

deads2k commented Jun 27, 2016

[test]

@deads2k
Copy link
Contributor Author

deads2k commented Jun 27, 2016

#9512

@deads2k
Copy link
Contributor Author

deads2k commented Jun 27, 2016

@stevekuznetsov I got

Stderr from the command:

pkg/quota/controller/clusterquotamapping/clusterquotamapping.go:366: declaration of err shadows declaration at pkg/quota/controller/clusterquotamapping/clusterquotamapping.go:358: 
pkg/quota/controller/clusterquotamapping/clusterquotamapping.go:506: declaration of ok shadows declaration at pkg/quota/controller/clusterquotamapping/clusterquotamapping.go:504: 
pkg/quota/controller/clusterquotamapping/clusterquotamapping.go:548: declaration of ok shadows declaration at pkg/quota/controller/clusterquotamapping/clusterquotamapping.go:546: 

I'm pretty sure that go recommends anti-patterns like that. How do I make govet less strict?

return err
allQuotas, err1 := c.quotaLister.List(kapi.ListOptions{})
if err1 != nil {
return err1
Copy link
Contributor

Choose a reason for hiding this comment

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

This does seem silly, but your method is ~35 lines long and has indentation five levels deep. Maybe make your for{} block a named function?

@stevekuznetsov
Copy link
Contributor

@deads2k left some comments on code refactors that might help, but mainly I have two things to say:

  • if "the Go way" actively introduces shadowing ... that sucks and maybe we should be OK with naming our oks and errs uniquely. I really don't think that the "negative" of having better named vars like that outweighs the ability for us to use static analysis to entirely remove shadowed variables from our codebase
  • you could always add your new package to the blacklist so go vet doesn't run shadow checks on you

quotaapi "github.com/openshift/origin/pkg/quota/api"
)

type IndexerToNamespaceLister struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this lister be upstreamed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Shouldn't this lister be upstreamed?

Can I get a TODO? I think we need to move the entire InformerFactory interface.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, that's fine.

// If the mapping cache is wrong and a previously deleted quota or namespace is created, this controller
// correctly adds the items back to the list and clears out all previous mappings.
//
// In addition to those constraints, the timing threshold for actaully hitting this problem is really tight. It's
Copy link
Contributor

Choose a reason for hiding this comment

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

typo

@deads2k deads2k force-pushed the cq-03-reverse-index branch from 054da9b to eb4bf26 Compare June 28, 2016 12:22
@deads2k
Copy link
Contributor Author

deads2k commented Jun 28, 2016

comments addressed.

@deads2k deads2k force-pushed the cq-03-reverse-index branch from a180754 to 92f7e72 Compare June 28, 2016 17:27
c.enqueueNamespace(cur)
}
func (c *ClusterQuotaMappingController) updateNamespace(old, cur interface{}) {
c.enqueueNamespace(cur)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you need to enqueue in case there are no label changes for the namespace? Same question about quota without selector changes in its own update handler.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you need to enqueue in case there are no label changes for the namespace? Same question about quota without selector changes in its own update handler.

The enqueue method is the spot that does that check since it is common to both the add and update paths.

Copy link
Contributor

Choose a reason for hiding this comment

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

missed. cool

@0xmichalis
Copy link
Contributor

LGTM

@deads2k
Copy link
Contributor Author

deads2k commented Jun 28, 2016

[merge]

@openshift-bot
Copy link
Contributor

openshift-bot commented Jun 28, 2016

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/5542/) (Image: devenv-rhel7_4486)

@openshift-bot
Copy link
Contributor

Evaluated for origin merge up to 92f7e72

@0xmichalis
Copy link
Contributor

[merge]

@deads2k
Copy link
Contributor Author

deads2k commented Jun 29, 2016

re[test]

@openshift-bot
Copy link
Contributor

Evaluated for origin test up to 92f7e72

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/5542/)

@openshift-bot openshift-bot merged commit e345c2c into openshift:master Jun 29, 2016
@deads2k deads2k deleted the cq-03-reverse-index branch September 6, 2016 17:17
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.

5 participants