don't sync deployment when pod selector is empty

This commit is contained in:
Mike Danese
2016-03-25 00:40:12 -07:00
parent fa48e2497b
commit c4305762b2
3 changed files with 31 additions and 1 deletions

View File

@@ -789,3 +789,28 @@ func TestSyncDeploymentCreatesReplicaSet(t *testing.T) {
f.run(getKey(d, t))
}
// issue: https://github.com/kubernetes/kubernetes/issues/23218
func TestDeploymentController_dontSyncDeploymentsWithEmptyPodSelector(t *testing.T) {
fake := &fake.Clientset{}
controller := NewDeploymentController(fake, controller.NoResyncPeriodFunc)
controller.eventRecorder = &record.FakeRecorder{}
controller.rsStoreSynced = alwaysReady
controller.podStoreSynced = alwaysReady
d := newDeployment(1, nil)
empty := unversioned.LabelSelector{}
d.Spec.Selector = &empty
controller.dStore.Store.Add(d)
// We expect the deployment controller to not take action here since it's configuration
// is invalid, even though no replicasets exist that match it's selector.
controller.syncDeployment(fmt.Sprintf("%s/%s", d.ObjectMeta.Namespace, d.ObjectMeta.Name))
if len(fake.Actions()) == 0 {
return
}
for _, action := range fake.Actions() {
t.Logf("unexpected action: %#v", action)
}
t.Errorf("expected deployment controller to not take action")
}