Skip to content

Commit

Permalink
Remove the delete propagation flag
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Doug Davis committed Apr 1, 2020
1 parent df78b8b commit 90fa601
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/serving/v1/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,25 +262,25 @@ func updateServiceWithRetry(cl KnServingClient, name string, updateFunc serviceU
// For `timeout == 0` delete is performed async without any wait.
func (cl *knServingClient) DeleteService(serviceName string, timeout time.Duration) error {
if timeout == 0 {
return cl.deleteService(serviceName, v1.DeletePropagationBackground)
return cl.deleteService(serviceName)
}
waitC := make(chan error)
go func() {
waitForEvent := wait.NewWaitForEvent("service", cl.WatchService, func(evt *watch.Event) bool { return evt.Type == watch.Deleted })
err, _ := waitForEvent.Wait(serviceName, wait.Options{Timeout: &timeout}, wait.NoopMessageCallback())
waitC <- err
}()
err := cl.deleteService(serviceName, v1.DeletePropagationForeground)
err := cl.deleteService(serviceName)
if err != nil {
return err
}
return <-waitC
}

func (cl *knServingClient) deleteService(serviceName string, propagationPolicy v1.DeletionPropagation) error {
func (cl *knServingClient) deleteService(serviceName string) error {
err := cl.client.Services(cl.namespace).Delete(
serviceName,
&v1.DeleteOptions{PropagationPolicy: &propagationPolicy},
&v1.DeleteOptions{},
)
if err != nil {
return clienterrors.GetError(err)
Expand Down

0 comments on commit 90fa601

Please sign in to comment.