diff --git a/pkg/client/status.go b/pkg/client/status.go index a56ca4069f..1bdc58e21c 100644 --- a/pkg/client/status.go +++ b/pkg/client/status.go @@ -33,9 +33,10 @@ const ( ) // WaitForTaskToSucceed will poll indefinitely every 2 seconds for the task with uuid to have status of "SUCCEEDED". -// Returns an error from GetTaskStatus or a timeout error if the context is cancelled. +// The polling will not stop if the ctx is cancelled, it's only used for HTTP requests in the client. +// WaitForTaskToSucceed will exit immediately on an error getting the task. func WaitForTaskToSucceed(ctx context.Context, conn *nutanixClientV3.Client, uuid string) error { - return wait.PollImmediateInfiniteWithContext(ctx, pollingInterval, func(ctx context.Context) (done bool, err error) { + return wait.PollImmediateInfinite(pollingInterval, func() (done bool, err error) { status, getErr := GetTaskStatus(ctx, conn, uuid) return status == statusSucceeded, getErr }) diff --git a/pkg/client/status_test.go b/pkg/client/status_test.go index 63dc5c8491..e3318c4b8f 100644 --- a/pkg/client/status_test.go +++ b/pkg/client/status_test.go @@ -8,7 +8,6 @@ import ( "time" "github.com/stretchr/testify/assert" - "k8s.io/apimachinery/pkg/util/wait" nutanixtestclient "github.com/nutanix-cloud-native/cluster-api-provider-nutanix/test/helpers/prism-go-client/v3" ) @@ -127,7 +126,7 @@ func Test_WaitForTaskCompletion(t *testing.T) { fmt.Fprint(w, `{"status": "PENDING"}`) }, ctx: ctx, - expectedErr: wait.ErrWaitTimeout, + expectedErr: context.DeadlineExceeded, }, } for _, tt := range tests {