-
Notifications
You must be signed in to change notification settings - Fork 40k
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
don't sync deployment when pod selector is empty #23467
don't sync deployment when pod selector is empty #23467
Conversation
Labelling this PR as size/XS |
GCE e2e build/test passed for commit 3755f7f10f8d509cc060326b7df7c5f5566ec5d1. |
3755f7f
to
f145b91
Compare
for _, action := range fake.Actions() { | ||
t.Logf("unexpected action: %#v", action) | ||
} | ||
t.Errorf("expected deployment controller to not take action") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On master this test fails with:
=== RUN TestDeploymentController_dontSyncDeploymentsWithEmptyPodSelector
--- FAIL: TestDeploymentController_dontSyncDeploymentsWithEmptyPodSelector (0.00s)
deployment_controller_test.go:810: unexpected action: core.CreateActionImpl{ActionImpl:core.ActionImpl{Namespace:"default", Verb:"create", Resource:"replicasets", Subresource:""}, Object:(*extensions.ReplicaSet)(0xc2081238c0)}
deployment_controller_test.go:810: unexpected action: core.UpdateActionImpl{ActionImpl:core.ActionImpl{Namespace:"default", Verb:"update", Resource:"deployments", Subresource:""}, Object:(*extensions.Deployment)(0xc208081b80)}
deployment_controller_test.go:810: unexpected action: core.UpdateActionImpl{ActionImpl:core.ActionImpl{Namespace:"", Verb:"update", Resource:"replicasets", Subresource:""}, Object:(*extensions.ReplicaSet)(0xc208123b00)}
deployment_controller_test.go:810: unexpected action: core.ListActionImpl{ActionImpl:core.ActionImpl{Namespace:"", Verb:"list", Resource:"pods", Subresource:""}, ListRestrictions:core.ListRestrictions{Labels:labels.nothingSelector{}, Fields:fields.andTerm{}}}
deployment_controller_test.go:810: unexpected action: core.UpdateActionImpl{ActionImpl:core.ActionImpl{Namespace:"default", Verb:"update", Resource:"deployments", Subresource:"status"}, Object:(*extensions.Deployment)(0xc2081b6500)}
deployment_controller_test.go:812: expected deployment controller to not take action
FAIL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clarification: WIthout the controller change, this test fails, as expected.
Labelling this PR as size/S |
f145b91
to
54c32f9
Compare
Labelling this PR as size/M |
GCE e2e build/test passed for commit f145b91540773de9b9de608d4862cfb75a1eddb7. |
GCE e2e build/test passed for commit 54c32f95d042fb2acc714f4cf80452ba6f0590c1. |
@@ -426,6 +426,11 @@ func (dc *DeploymentController) syncDeployment(key string) error { | |||
} | |||
|
|||
d := obj.(*extensions.Deployment) | |||
everything := unversioned.LabelSelector{} | |||
if reflect.DeepEqual(d.Spec.Selector, &everything) { | |||
dc.eventRecorder.Eventf(d, api.EventTypeWarning, "SelectingAll", "This controller is selecting all pods. Skipping sync.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/controller/Deployment/
I doubt "skipping sync" is very meaningful to users. How about "A non-empty selector is required."
54c32f9
to
8028751
Compare
@bgrant0607 @janetkuo I fixed both the daemon set and the deployment event message. PTAL |
@@ -426,6 +426,11 @@ func (dc *DeploymentController) syncDeployment(key string) error { | |||
} | |||
|
|||
d := obj.(*extensions.Deployment) | |||
everything := unversioned.LabelSelector{} | |||
if reflect.DeepEqual(d.Spec.Selector, &everything) { | |||
dc.eventRecorder.Eventf(d, api.EventTypeWarning, "SelectingAll", "This deployment is selecting all pods. A non-empty sync is required.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/sync/selector/
8028751
to
c430576
Compare
GCE e2e build/test passed for commit 8028751905beb2a250484826dda8cbcf2e668397. |
Thanks much. LGTM |
GCE e2e build/test passed for commit c430576. |
@k8s-bot test this [submit-queue is verifying that this PR is safe to merge] |
GCE e2e build/test passed for commit c430576. |
@k8s-bot test this [submit-queue is verifying that this PR is safe to merge] |
GCE e2e build/test passed for commit c430576. |
@k8s-bot test this [submit-queue is verifying that this PR is safe to merge] |
GCE e2e build/test passed for commit c430576. |
Automatic merge from submit-queue |
Commit found in the "release-1.2" branch appears to be this PR. Removing the "cherrypick-candidate" label. If this is an error find help to get your PR picked. |
…pick-of-#23530-kubernetes#23467-upstream-release-1.2 Automated cherry pick of kubernetes#23530 kubernetes#23467
…pick-of-#23530-kubernetes#23467-upstream-release-1.2 Automated cherry pick of kubernetes#23530 kubernetes#23467
…from-kube UPSTREAM: <carry>: remove embedded oauth server Origin-commit: 68b25f8b2004119ef841feaf4a9f2c936b432363
Fixes #23218
cc @bgrant0607 @janetkuo