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++ {
|
for i := int32(0); i < diff; i++ {
|
||||||
rs := oldRSs[i]
|
rs := oldRSs[i]
|
||||||
// Avoid delete replica set with non-zero replica counts
|
// 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
|
continue
|
||||||
}
|
}
|
||||||
glog.V(2).Infof("Trying to cleanup replica set %q for deployment %q", rs.Name, deployment.Name)
|
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) {
|
func TestDeploymentController_cleanupDeployment(t *testing.T) {
|
||||||
selector := map[string]string{"foo": "bar"}
|
selector := map[string]string{"foo": "bar"}
|
||||||
|
alreadyDeleted := newRSWithStatus("foo-1", 0, 0, selector)
|
||||||
|
now := metav1.Now()
|
||||||
|
alreadyDeleted.DeletionTimestamp = &now
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
oldRSs []*extensions.ReplicaSet
|
oldRSs []*extensions.ReplicaSet
|
||||||
@ -366,10 +369,19 @@ func TestDeploymentController_cleanupDeployment(t *testing.T) {
|
|||||||
revisionHistoryLimit: 0,
|
revisionHistoryLimit: 0,
|
||||||
expectedDeletions: 0,
|
expectedDeletions: 0,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
oldRSs: []*extensions.ReplicaSet{
|
||||||
|
alreadyDeleted,
|
||||||
|
},
|
||||||
|
revisionHistoryLimit: 0,
|
||||||
|
expectedDeletions: 0,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := range tests {
|
for i := range tests {
|
||||||
test := tests[i]
|
test := tests[i]
|
||||||
|
t.Logf("scenario %d", i)
|
||||||
|
|
||||||
fake := &fake.Clientset{}
|
fake := &fake.Clientset{}
|
||||||
informers := informers.NewSharedInformerFactory(nil, fake, controller.NoResyncPeriodFunc())
|
informers := informers.NewSharedInformerFactory(nil, fake, controller.NoResyncPeriodFunc())
|
||||||
controller := NewDeploymentController(informers.Extensions().V1beta1().Deployments(), informers.Extensions().V1beta1().ReplicaSets(), informers.Core().V1().Pods(), fake)
|
controller := NewDeploymentController(informers.Extensions().V1beta1().Deployments(), informers.Extensions().V1beta1().ReplicaSets(), informers.Core().V1().Pods(), fake)
|
||||||
|
Loading…
Reference in New Issue
Block a user