diff --git a/cmd/ecloud/ecloud_floatingip.go b/cmd/ecloud/ecloud_floatingip.go index 5057e6d..acc9abc 100644 --- a/cmd/ecloud/ecloud_floatingip.go +++ b/cmd/ecloud/ecloud_floatingip.go @@ -220,9 +220,9 @@ func ecloudFloatingIPDelete(service ecloud.ECloudService, cmd *cobra.Command, ar waitFlag, _ := cmd.Flags().GetBool("wait") if waitFlag { - err := helper.WaitForCommand(FloatingIPResourceSyncStatusWaitFunc(service, arg, ecloud.SyncStatusComplete)) + err := helper.WaitForCommand(FloatingIPNotFoundWaitFunc(service, arg)) if err != nil { - output.OutputWithErrorLevelf("Error waiting for floating IP [%s] sync: %s", arg, err) + output.OutputWithErrorLevelf("Error waiting for removal of floating IP [%s]: %s", arg, err) continue } } @@ -331,3 +331,19 @@ func FloatingIPResourceSyncStatusWaitFunc(service ecloud.ECloudService, fipID st return fip.Sync.Status, nil }, status) } + +func FloatingIPNotFoundWaitFunc(service ecloud.ECloudService, fipID string) helper.WaitFunc { + return func() (finished bool, err error) { + _, err = service.GetFloatingIP(fipID) + if err != nil { + switch err.(type) { + case *ecloud.FloatingIPNotFoundError: + return true, nil + default: + return false, fmt.Errorf("Failed to retrieve floating IP [%s]: %s", fipID, err) + } + } + + return false, nil + } +}