Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating reapers to set OrphanDependents=false #43041

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 8 additions & 4 deletions pkg/kubectl/stop.go
Expand Up @@ -322,7 +322,7 @@ func (reaper *DaemonSetReaper) Stop(namespace, name string, timeout time.Duratio
return err
}

return reaper.client.DaemonSets(namespace).Delete(name, nil)
return reaper.client.DaemonSets(namespace).Delete(name, getNonOrphanDeleteOptions())
}

func (reaper *StatefulSetReaper) Stop(namespace, name string, timeout time.Duration, gracePeriod *api.DeleteOptions) error {
Expand Down Expand Up @@ -366,7 +366,7 @@ func (reaper *StatefulSetReaper) Stop(namespace, name string, timeout time.Durat

// TODO: Cleanup volumes? We don't want to accidentally delete volumes from
// stop, so just leave this up to the statefulset.
return statefulsets.Delete(name, nil)
return statefulsets.Delete(name, getNonOrphanDeleteOptions())
}

func (reaper *JobReaper) Stop(namespace, name string, timeout time.Duration, gracePeriod *api.DeleteOptions) error {
Expand Down Expand Up @@ -409,7 +409,7 @@ func (reaper *JobReaper) Stop(namespace, name string, timeout time.Duration, gra
return utilerrors.NewAggregate(errList)
}
// once we have all the pods removed we can safely remove the job itself
return jobs.Delete(name, nil)
return jobs.Delete(name, getNonOrphanDeleteOptions())
}

func (reaper *DeploymentReaper) Stop(namespace, name string, timeout time.Duration, gracePeriod *api.DeleteOptions) error {
Expand Down Expand Up @@ -467,7 +467,7 @@ func (reaper *DeploymentReaper) Stop(namespace, name string, timeout time.Durati

// Delete deployment at the end.
// Note: We delete deployment at the end so that if removing RSs fails, we at least have the deployment to retry.
return deployments.Delete(name, nil)
return deployments.Delete(name, getNonOrphanDeleteOptions())
}

type updateDeploymentFunc func(d *extensions.Deployment)
Expand Down Expand Up @@ -509,3 +509,7 @@ func (reaper *ServiceReaper) Stop(namespace, name string, timeout time.Duration,
}
return services.Delete(name, nil)
}

func getNonOrphanDeleteOptions() *api.DeleteOptions {
return &api.DeleteOptions{OrphanDependents: new(bool)}
}