Merge pull request #51186 from dixudx/fix_delete_uninitialized_resources
Automatic merge from submit-queue (batch tested with PRs 51186, 50350, 51751, 51645, 51837) fix bug on kubectl deleting uninitialized resources **What this PR does / why we need it**: **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #51185 **Special notes for your reviewer**: /assign @caesarxuchao @ahmetb **Release note**: ```release-note fix bug on kubectl deleting uninitialized resources ```
This commit is contained in:
@@ -404,6 +404,11 @@ func (reaper *DeploymentReaper) Stop(namespace, name string, timeout time.Durati
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if deployment.Initializers != nil {
|
||||
var falseVar = false
|
||||
nonOrphanOption := metav1.DeleteOptions{OrphanDependents: &falseVar}
|
||||
return deployments.Delete(name, &nonOrphanOption)
|
||||
}
|
||||
|
||||
// Use observedGeneration to determine if the deployment controller noticed the pause.
|
||||
if err := deploymentutil.WaitForObservedDeploymentInternal(func() (*extensions.Deployment, error) {
|
||||
|
||||
@@ -305,6 +305,9 @@ func (scaler *ReplicaSetScaler) Scale(namespace, name string, newSize uint, prec
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if rs.Initializers != nil {
|
||||
return nil
|
||||
}
|
||||
err = wait.Poll(waitForReplicas.Interval, waitForReplicas.Timeout, client.ReplicaSetHasDesiredReplicas(scaler.c, rs))
|
||||
|
||||
if err == wait.ErrWaitTimeout {
|
||||
@@ -373,6 +376,9 @@ func (scaler *StatefulSetScaler) Scale(namespace, name string, newSize uint, pre
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if job.Initializers != nil {
|
||||
return nil
|
||||
}
|
||||
err = wait.Poll(waitForReplicas.Interval, waitForReplicas.Timeout, client.StatefulSetHasDesiredReplicas(scaler.c, job))
|
||||
if err == wait.ErrWaitTimeout {
|
||||
return fmt.Errorf("timed out waiting for %q to be synced", name)
|
||||
|
||||
Reference in New Issue
Block a user