Do not cleanup replicasets already marked for deletion
This commit is contained in:
parent
ff83eb58eb
commit
97c9e7fe07
@ -554,7 +554,7 @@ func (dc *DeploymentController) cleanupDeployment(oldRSs []*extensions.ReplicaSe
|
||||
for i := int32(0); i < diff; i++ {
|
||||
rs := oldRSs[i]
|
||||
// Avoid delete replica set with non-zero replica counts
|
||||
if rs.Status.Replicas != 0 || *(rs.Spec.Replicas) != 0 || rs.Generation > rs.Status.ObservedGeneration {
|
||||
if rs.Status.Replicas != 0 || *(rs.Spec.Replicas) != 0 || rs.Generation > rs.Status.ObservedGeneration || rs.DeletionTimestamp != nil {
|
||||
continue
|
||||
}
|
||||
glog.V(2).Infof("Trying to cleanup replica set %q for deployment %q", rs.Name, deployment.Name)
|
||||
|
@ -323,6 +323,9 @@ func TestScale(t *testing.T) {
|
||||
|
||||
func TestDeploymentController_cleanupDeployment(t *testing.T) {
|
||||
selector := map[string]string{"foo": "bar"}
|
||||
alreadyDeleted := newRSWithStatus("foo-1", 0, 0, selector)
|
||||
now := metav1.Now()
|
||||
alreadyDeleted.DeletionTimestamp = &now
|
||||
|
||||
tests := []struct {
|
||||
oldRSs []*extensions.ReplicaSet
|
||||
@ -366,10 +369,19 @@ func TestDeploymentController_cleanupDeployment(t *testing.T) {
|
||||
revisionHistoryLimit: 0,
|
||||
expectedDeletions: 0,
|
||||
},
|
||||
{
|
||||
oldRSs: []*extensions.ReplicaSet{
|
||||
alreadyDeleted,
|
||||
},
|
||||
revisionHistoryLimit: 0,
|
||||
expectedDeletions: 0,
|
||||
},
|
||||
}
|
||||
|
||||
for i := range tests {
|
||||
test := tests[i]
|
||||
t.Logf("scenario %d", i)
|
||||
|
||||
fake := &fake.Clientset{}
|
||||
informers := informers.NewSharedInformerFactory(nil, fake, controller.NoResyncPeriodFunc())
|
||||
controller := NewDeploymentController(informers.Extensions().V1beta1().Deployments(), informers.Extensions().V1beta1().ReplicaSets(), informers.Core().V1().Pods(), fake)
|
||||
|
Loading…
Reference in New Issue
Block a user