Merge pull request #65908 from juanvallejo/jvallejo/switch-delete-strategy-background

Automatic merge from submit-queue (batch tested with PRs 64695, 65982, 65908). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

switch delete strategy to background deletion

**Release note**:
```release-note
"kubectl delete" no longer waits for dependent objects to be deleted when removing parent resources
```

### Before 1.11.0

- Resources that had client-side reapers in older versions of the client had all of their dependents deleted first. The parent resource itself was deleted *last*. This allowed the command to be re-entrant and was largely an artifact of it **having** to be done that way by a client-side reaper.

### After 1.11.0 (with this PR)

- Resources that previously had client-side reapers are no longer deleted last (after their dependents). They are now instead deleted first. The garbage-collector server-side then deletes any dependents.
- This means that the `delete` command can return, and the parent object can be deleted while child objects still exist.
  - This is okay because the child resources are eventually deleted by the garbage collector server-side. 

cc @liggitt @soltysh
pull/8/head
Kubernetes Submit Queue 2018-07-10 08:55:15 -07:00 committed by GitHub
commit 029213748a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -240,7 +240,7 @@ func (o *DeleteOptions) DeleteResult(r *resource.Result) error {
if o.GracePeriod >= 0 {
options = metav1.NewDeleteOptions(int64(o.GracePeriod))
}
policy := metav1.DeletePropagationForeground
policy := metav1.DeletePropagationBackground
if !o.Cascade {
policy = metav1.DeletePropagationOrphan
}

View File

@ -137,9 +137,9 @@ func TestOrphanDependentsInDeleteObject(t *testing.T) {
}),
}
// DeleteOptions.PropagationPolicy should be Foreground, when cascade is true (default).
foregroundPolicy := metav1.DeletePropagationForeground
policy = &foregroundPolicy
// DeleteOptions.PropagationPolicy should be Background, when cascade is true (default).
backgroundPolicy := metav1.DeletePropagationBackground
policy = &backgroundPolicy
streams, _, buf, _ := genericclioptions.NewTestIOStreams()
cmd := NewCmdDelete(tf, streams)
cmd.Flags().Set("namespace", "test")