Skip to content

Rework DockercfgTokenDeletedController#13579

Closed
enj wants to merge 3 commits intoopenshift:masterfrom
enj:enj/f/limit_controller
Closed

Rework DockercfgTokenDeletedController#13579
enj wants to merge 3 commits intoopenshift:masterfrom
enj:enj/f/limit_controller

Conversation

@enj
Copy link
Contributor

@enj enj commented Mar 30, 2017

This works for me locally but needs an integration test.

[test]

Signed-off-by: Monis Khan mkhan@redhat.com

Trello xref: https://trello.com/c/ZtOfFpFz

Signed-off-by: Monis Khan <mkhan@redhat.com>
@enj enj requested review from deads2k and liggitt March 30, 2017 01:24
policyTemplate.Objects = append(policyTemplate.Objects, versionedObject)
}

controllerRoles := bootstrappolicy.GetBootstrapControllerRoles()
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 method used anywhere? I seem recall thinking that it should die.

Copy link
Contributor

Choose a reason for hiding this comment

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

@liggitt I like the upstream, reconcile on start combined with system:masters authorized separately which obviated the need for an external policy.json. You see any reason to keep creating the "BootstrapPolicyFile"?


var (
// controllerRoles is a slice of roles used for controllers
controllerRoles = []authorizationapi.ClusterRole{}
Copy link
Contributor

Choose a reason for hiding this comment

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

You'll want a clusterrole local role distinction. Found that out upstream.

controllerRoleBindings = []authorizationapi.ClusterRoleBinding{}
)

func addControllerRole(role authorizationapi.ClusterRole) {
Copy link
Contributor

Choose a reason for hiding this comment

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

No new openshift roles in our code here. Let's use the rbac roles and our converter. It will make future unification easier.

CoreClient: c.PrivilegedLoopbackKubernetesClientset.Core(),
Namespace: bootstrappolicy.DefaultOpenShiftInfraNamespace,
},
Stop: make(chan struct{}),
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't look. You didn't anonymously include the kube one, did you?

serviceaccountcontrollers.NewDockercfgDeletedController(c.KubeClientset(), serviceaccountcontrollers.DockercfgDeletedControllerOptions{}).Run()
serviceaccountcontrollers.NewDockercfgTokenDeletedController(c.KubeClientset(), serviceaccountcontrollers.DockercfgTokenDeletedControllerOptions{}).Run()

ctx := origincontroller.ControllerContext{
Copy link
Contributor

Choose a reason for hiding this comment

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

This block has the right idea. Please pull it out into a method which constructs the context and initializers and starts them all. Having only one in the map (as you have now) is perfect.

DockercfgTokenDeletedControllerName = "dockercfg-token-deleted-controller"
)

type ControllerContext struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Add some comments explaining why we have a different context. I think I see why you've done it now. Different informer factory, no options, and no use for avaialbleResources?

@deads2k
Copy link
Contributor

deads2k commented Mar 30, 2017

Relatively minor comments. This is a good start. I suspect that we'll end up swizzling packages around to adjust for this.

enj added 2 commits March 31, 2017 15:53
Signed-off-by: Monis Khan <mkhan@redhat.com>
Signed-off-by: Monis Khan <mkhan@redhat.com>
@enj
Copy link
Contributor Author

enj commented Mar 31, 2017

[test]

@openshift-bot
Copy link
Contributor

Evaluated for origin test up to 2d48afa

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_request_origin/524/) (Base Commit: 645cac4)

@enj
Copy link
Contributor Author

enj commented Apr 1, 2017

@deads2k the integration test I wrote seems to flake every so often locally. My best guess is kubernetes/kubernetes#41661 which we should get in the rebase?

@liggitt
Copy link
Contributor

liggitt commented Apr 1, 2017

kubernetes/kubernetes#41661 doesn't fix flakes, it fixes DOA clusters started after changing token signing keys while leaving invalid tokens in etcd

@enj
Copy link
Contributor Author

enj commented Apr 3, 2017

Here is what I have gathered from the logs:

  1. ClientBuilder creates DockercfgTokenDeletedController's SA
  2. DockercfgController makes dockercfg token for DockercfgTokenDeletedController's SA
  3. TokensController makes JWT token for DockercfgTokenDeletedController's SA
  4. DockercfgController and TokensController try to update DockercfgTokenDeletedController's SA to reference their respective secrets at the same time
  5. DockercfgController wins and updates DockercfgTokenDeletedController's SA
  6. ClientBuilder sees JWT token for DockercfgTokenDeletedController's SA and uses it to make a client for DockercfgTokenDeletedController
  7. DockercfgTokenDeletedController starts with JWT token for DockercfgTokenDeletedController's SA
  8. TokensController deletes JWT token for DockercfgTokenDeletedController's SA because it got a conflict error during the update
  9. DockercfgTokenDeletedController no longer functions

@deads2k @liggitt some questions:

  1. What is the expected behavior for a controller that has its token become invalid?
  2. Why does TokensController delete tokens when the error is a conflict?
  3. Should ClientBuilder wait for both the SA and the Secret to have references to each other before using the token?

@soltysh
Copy link
Contributor

soltysh commented Apr 4, 2017

  1. Why does TokensController delete tokens when the error is a conflict?

It's cleaning the secret, otherwise you might endup with some old crap that's not being linked anywhere

  1. Should ClientBuilder wait for both the SA and the Secret to have references to each other before using the token?

My guess is - yes. To mitigate the problem that you're watching just secrets you need to double check if that secret is actually used/linked in the SA and act upon it only then.

@openshift-bot openshift-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 1, 2017
@openshift-bot openshift-bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels May 20, 2017
@openshift-bot openshift-bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels May 28, 2017
@openshift-bot openshift-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 10, 2017
@openshift-bot
Copy link
Contributor

Origin Action Required: Pull request cannot be automatically merged, please rebase your branch from latest HEAD and push again

@openshift-bot openshift-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 10, 2017
@enj
Copy link
Contributor Author

enj commented Jun 15, 2017

Superseded by #14293

@enj enj closed this Jun 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants