Skip to content

Commit

Permalink
Remove the delete propagation flag (knative#770)
Browse files Browse the repository at this point in the history
* Remove the delete propagation flag

In it's current state it now takes me about 25 seconds for the `kn delete`
to complete. Before knative#682 it used to be
almost immediate. This is because we now pass in the
`DeletePropagationBackground` flag. I believe this is a mistake, not only
because of the 20+ seconds of additional time to delete things, but IMO
the CLI should talk to the server in the same way regardless of the --wait
flag. That flag should just be a CLI thing to indicate if the user wants the CLI
to wait for the server to complete but not HOW the server should do the delete.

Signed-off-by: Doug Davis <dug@us.ibm.com>

* try just tweaking the --no-wait flag

Signed-off-by: Doug Davis <dug@us.ibm.com>
  • Loading branch information
Doug Davis authored and rhuss committed Apr 15, 2020
1 parent 3e25a10 commit edb5151
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/cmd/kn_revision_delete.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ kn revision delete NAME [flags]
--async DEPRECATED: please use --no-wait instead. Delete revision and don't wait for it to be deleted.
-h, --help help for delete
-n, --namespace string Specify the namespace to operate in.
--no-wait Delete revision and don't wait for it to be deleted.
--no-wait Delete revision and don't wait for it to be deleted. (default true)
--wait-timeout int Seconds to wait before giving up on waiting for revision to be deleted. (default 600)
```

Expand Down
2 changes: 1 addition & 1 deletion docs/cmd/kn_service_delete.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ kn service delete NAME [flags]
--async DEPRECATED: please use --no-wait instead. Delete service and don't wait for it to be deleted.
-h, --help help for delete
-n, --namespace string Specify the namespace to operate in.
--no-wait Delete service and don't wait for it to be deleted.
--no-wait Delete service and don't wait for it to be deleted. (default true)
--wait-timeout int Seconds to wait before giving up on waiting for service to be deleted. (default 600)
```

Expand Down
9 changes: 8 additions & 1 deletion pkg/kn/commands/wait_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,15 @@ type WaitFlags struct {
func (p *WaitFlags) AddConditionWaitFlags(command *cobra.Command, waitTimeoutDefault int, action, what, until string) {
waitUsage := fmt.Sprintf("%s %s and don't wait for it to be %s.", action, what, until)
//TODO: deprecated flag should be removed in next release

// Special-case 'delete' command so it comes back to the user immediately
noWaitDefault := false
if action == "Delete" {
noWaitDefault = true
}

command.Flags().BoolVar(&p.Async, "async", false, "DEPRECATED: please use --no-wait instead. "+waitUsage)
command.Flags().BoolVar(&p.NoWait, "no-wait", false, waitUsage)
command.Flags().BoolVar(&p.NoWait, "no-wait", noWaitDefault, waitUsage)

timeoutUsage := fmt.Sprintf("Seconds to wait before giving up on waiting for %s to be %s.", what, until)
command.Flags().IntVar(&p.TimeoutInSeconds, "wait-timeout", waitTimeoutDefault, timeoutUsage)
Expand Down
9 changes: 9 additions & 0 deletions pkg/kn/commands/wait_flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,12 @@ func TestAddWaitUsageMessage(t *testing.T) {
t.Error("wrong until message")
}
}

func TestAddWaitUsageDelete(t *testing.T) {
flags := &WaitFlags{}
cmd := cobra.Command{}
flags.AddConditionWaitFlags(&cmd, 60, "Delete", "blub", "deleted")
if !strings.Contains(cmd.UsageString(), "deleted. (default true)") {
t.Error("Delete has wrong default value for --no-wait")
}
}

0 comments on commit edb5151

Please sign in to comment.