Signed-off-by: Austin Abro <AustinAbro321@gmail.com>
pull/13604/head
Austin Abro 9 months ago
parent b337790c10
commit 28a9183ee3
No known key found for this signature in database
GPG Key ID: 92EB5159E403F9D6

@ -40,16 +40,18 @@ type kstatusWaiter struct {
}
func (w *kstatusWaiter) Wait(resourceList ResourceList, timeout time.Duration) error {
return w.wait(resourceList, timeout, false)
ctx, cancel := context.WithTimeout(context.TODO(), timeout)
defer cancel()
return w.wait(ctx, resourceList, false)
}
func (w *kstatusWaiter) WaitWithJobs(resourceList ResourceList, timeout time.Duration) error {
return w.wait(resourceList, timeout, true)
}
func (w *kstatusWaiter) wait(resourceList ResourceList, timeout time.Duration, waitForJobs bool) error {
ctx, cancel := context.WithTimeout(context.TODO(), timeout)
defer cancel()
return w.wait(ctx, resourceList, true)
}
func (w *kstatusWaiter) wait(ctx context.Context, resourceList ResourceList, waitForJobs bool) error {
cancelCtx, cancel := context.WithCancel(ctx)
defer cancel()
runtimeObjs := []runtime.Object{}

@ -17,6 +17,7 @@ limitations under the License.
package kube // import "helm.sh/helm/v3/pkg/kube"
import (
"context"
"errors"
"log"
"testing"
@ -194,7 +195,10 @@ func TestKWaitJob(t *testing.T) {
resourceList = append(resourceList, list...)
}
err := kwaiter.wait(resourceList, time.Second*3, tt.waitForJobs)
ctx, cancel := context.WithTimeout(context.Background(), time.Second*3)
defer cancel()
err := kwaiter.wait(ctx, resourceList, tt.waitForJobs)
if tt.expectErrs != nil {
assert.EqualError(t, err, errors.Join(tt.expectErrs...).Error())
return

@ -53,6 +53,7 @@ func (w *waiter) WaitWithJobs(resources ResourceList, timeout time.Duration) err
// Implementation
// TODO this function doesn't make sense unless you pass a readyChecker to it
// TODO pass context instead
// checker := NewReadyChecker(cs, w.c.Log, PausedAsReady(true), CheckJobs(true))
w.timeout = timeout
return w.waitForResources(resources)
}

Loading…
Cancel
Save