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

Convert service account token controller to use a work queue #23858

Merged
merged 1 commit into from
Jun 27, 2016

Conversation

liggitt
Copy link
Member

@liggitt liggitt commented Apr 5, 2016

Converts the service account token controller to use a work queue. This allows parallelization of token generation (useful when there are several simultaneous namespaces or service accounts being created). It also lets us requeue failures to be retried sooned than the next sync period (which can be very long).

Fixes an issue seen when a namespace is created with secrets quotaed, and the token controller tries to create a token secret prior to the quota status having been initialized. In that case, the secret is rejected at admission, and the token controller wasn't retrying until the resync period.

@liggitt
Copy link
Member Author

liggitt commented Apr 5, 2016

cc @deads2k

@k8s-github-robot k8s-github-robot added kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/old-docs size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Apr 5, 2016
// Unknown type. If we missed a ServiceAccount deletion, the
// corresponding secrets will be cleaned up during the Secret re-list
return
func (e *TokensController) requeue(queue *workqueue.Type, key interface{}) {
Copy link
Member Author

Choose a reason for hiding this comment

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

@deads2k is there a cleaner way to do this? this also doesn't protect against a hotloop if you get more than N persistent failures (other controllers may have similar issues with requeue). Without a place to record backoff (which presumes an object and the ability to update it successfully), I'm not sure how to make this better

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

#23444

That in combination with a ratelimit.NewBucketWithRate() and then bucket.Take() is what I planned to do downstream. I think that should give the duration to add to the requeue. MaxFailures should be tracked both on your object (which may fail) and a list of those failures in your controller (which should not fail).

@liggitt liggitt added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-label-needed labels Apr 5, 2016
@liggitt liggitt assigned lavalamp and unassigned mikedanese Apr 5, 2016
@liggitt
Copy link
Member Author

liggitt commented Apr 5, 2016

cc @lavalamp for controller review (or nominate alternate)

@@ -332,7 +397,8 @@ func (e *TokensController) createSecret(serviceAccount *api.ServiceAccount) erro

// Save the secret
if createdToken, err := e.client.Core().Secrets(serviceAccount.Namespace).Create(secret); err != nil {
return err
// retriable error
return true, err
} else {
Copy link
Contributor

Choose a reason for hiding this comment

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

Reduce indent

Copy link
Member Author

Choose a reason for hiding this comment

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

if you mean remove the else, I'd rather keep createdToken and err scoped to this block

@liggitt liggitt force-pushed the satoken-queue branch 3 times, most recently from 4e5c9c7 to b8f98d9 Compare April 5, 2016 15:55
@@ -53,6 +53,7 @@ func NewCMServer() *CMServer {
ConcurrentResourceQuotaSyncs: 5,
ConcurrentDeploymentSyncs: 5,
ConcurrentNamespaceSyncs: 2,
ConcurrentSATokenSyncs: 5,
Copy link
Member

Choose a reason for hiding this comment

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

"Workers" instead of Syncs?

Copy link
Member

Choose a reason for hiding this comment

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

I guess that would be inconsistent and I won't ask you to change them all. Sigh. "Syncs" is confusing.

Copy link
Member Author

Choose a reason for hiding this comment

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

agree, and agree

@lavalamp
Copy link
Member

lavalamp commented Apr 5, 2016

We may need a strategy for testing this sort of code. There's a lot of possible places for error returns, are they all exercised?

@liggitt
Copy link
Member Author

liggitt commented May 24, 2016

fixed mesos controllermanager int32 cast

@liggitt liggitt added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 24, 2016
}
if cl != nil && cl.Core().GetRESTClient().GetRateLimiter() != nil {
metrics.RegisterMetricAndTrackRateLimiterUsage("serviceaccount_controller", cl.Core().GetRESTClient().GetRateLimiter())
}
e.serviceAccounts, e.serviceAccountController = framework.NewIndexerInformer(

e.serviceAccounts, e.serviceAccountController = framework.NewInformer(
Copy link
Contributor

Choose a reason for hiding this comment

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

Why this change?

Copy link
Member Author

Choose a reason for hiding this comment

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

we don't need to look up service accounts by namespace, so no need to maintain that index

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 28, 2016
@liggitt
Copy link
Member Author

liggitt commented May 29, 2016

rebased

@liggitt liggitt added lgtm "Looks good to me", indicates that a PR is ready to be merged. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. labels May 29, 2016
@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 29, 2016
@k8s-bot
Copy link

k8s-bot commented May 29, 2016

GCE e2e build/test passed for commit 9d6d8c475495430f24e62aeb0532b154d6b4fe61.

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 29, 2016
@liggitt liggitt added lgtm "Looks good to me", indicates that a PR is ready to be merged. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jun 27, 2016
@liggitt
Copy link
Member Author

liggitt commented Jun 27, 2016

rebased

@k8s-bot
Copy link

k8s-bot commented Jun 27, 2016

GCE e2e build/test passed for commit f45d9dc.

@k8s-bot
Copy link

k8s-bot commented Jun 27, 2016

GCE e2e build/test passed for commit f45d9dc.

@ncdc
Copy link
Member

ncdc commented Jun 27, 2016

@k8s-bot unit test this issue: #28076

@k8s-bot
Copy link

k8s-bot commented Jun 27, 2016

GCE e2e build/test passed for commit f45d9dc.

@liggitt
Copy link
Member Author

liggitt commented Jun 27, 2016

@k8s-bot unit test this issue: #28076

@k8s-github-robot
Copy link

@k8s-bot test this [submit-queue is verifying that this PR is safe to merge]

@k8s-bot
Copy link

k8s-bot commented Jun 27, 2016

GCE e2e build/test passed for commit f45d9dc.

@k8s-github-robot
Copy link

Automatic merge from submit-queue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. 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.