From 9c533b851d3705bc0bbfcb1c6f849d85a8560f4c Mon Sep 17 00:00:00 2001 From: Dimitri Koshkin Date: Thu, 4 Jan 2024 18:27:29 -0800 Subject: [PATCH] fix: revert to previous behaviod polling forever The ctx passed into WaitForTaskToSucceed is only used to cancel HTTP reqests and not to cancel the wait. --- pkg/client/status.go | 5 +++-- pkg/client/status_test.go | 3 +-- 2 files changed, 4 insertions(+), 4 deletions(-) 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 {