mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-01 07:47:56 +00:00
DeploymentController doesn't take any actions when being deleted
This commit is contained in:
parent
d8958257c4
commit
7815a3e7bc
@ -484,6 +484,10 @@ func (dc *DeploymentController) syncDeployment(key string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if d.DeletionTimestamp != nil {
|
||||||
|
return dc.syncStatusOnly(d)
|
||||||
|
}
|
||||||
|
|
||||||
if d.Spec.Paused {
|
if d.Spec.Paused {
|
||||||
return dc.sync(d)
|
return dc.sync(d)
|
||||||
}
|
}
|
||||||
|
@ -252,6 +252,17 @@ func TestSyncDeploymentCreatesReplicaSet(t *testing.T) {
|
|||||||
f.run(getKey(d, t))
|
f.run(getKey(d, t))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSyncDeploymentDontDoAnythingDuringDeletion(t *testing.T) {
|
||||||
|
f := newFixture(t)
|
||||||
|
|
||||||
|
d := newDeployment(1, nil)
|
||||||
|
now := unversioned.Now()
|
||||||
|
d.DeletionTimestamp = &now
|
||||||
|
f.dStore = append(f.dStore, d)
|
||||||
|
|
||||||
|
f.run(getKey(d, t))
|
||||||
|
}
|
||||||
|
|
||||||
// issue: https://github.com/kubernetes/kubernetes/issues/23218
|
// issue: https://github.com/kubernetes/kubernetes/issues/23218
|
||||||
func TestDeploymentController_dontSyncDeploymentsWithEmptyPodSelector(t *testing.T) {
|
func TestDeploymentController_dontSyncDeploymentsWithEmptyPodSelector(t *testing.T) {
|
||||||
fake := &fake.Clientset{}
|
fake := &fake.Clientset{}
|
||||||
|
@ -35,6 +35,17 @@ import (
|
|||||||
rsutil "k8s.io/kubernetes/pkg/util/replicaset"
|
rsutil "k8s.io/kubernetes/pkg/util/replicaset"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// syncStatusOnly only updates Deployments Status and doesn't take any mutating actions.
|
||||||
|
func (dc *DeploymentController) syncStatusOnly(deployment *extensions.Deployment) error {
|
||||||
|
newRS, oldRSs, err := dc.getAllReplicaSetsAndSyncRevision(deployment, false)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
allRSs := append(oldRSs, newRS)
|
||||||
|
return dc.syncDeploymentStatus(allRSs, newRS, deployment)
|
||||||
|
}
|
||||||
|
|
||||||
// sync is responsible for reconciling deployments on scaling events or when they
|
// sync is responsible for reconciling deployments on scaling events or when they
|
||||||
// are paused.
|
// are paused.
|
||||||
func (dc *DeploymentController) sync(deployment *extensions.Deployment) error {
|
func (dc *DeploymentController) sync(deployment *extensions.Deployment) error {
|
||||||
|
Loading…
Reference in New Issue
Block a user