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 { 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 { 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) ctx, cancel := context.WithTimeout(context.TODO(), timeout)
defer cancel() 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) cancelCtx, cancel := context.WithCancel(ctx)
defer cancel() defer cancel()
runtimeObjs := []runtime.Object{} runtimeObjs := []runtime.Object{}

@ -17,6 +17,7 @@ limitations under the License.
package kube // import "helm.sh/helm/v3/pkg/kube" package kube // import "helm.sh/helm/v3/pkg/kube"
import ( import (
"context"
"errors" "errors"
"log" "log"
"testing" "testing"
@ -194,7 +195,10 @@ func TestKWaitJob(t *testing.T) {
resourceList = append(resourceList, list...) 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 { if tt.expectErrs != nil {
assert.EqualError(t, err, errors.Join(tt.expectErrs...).Error()) assert.EqualError(t, err, errors.Join(tt.expectErrs...).Error())
return return

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

Loading…
Cancel
Save