From 7a1501a7bb84d5e7750751e8a425299a7dbdd24d Mon Sep 17 00:00:00 2001 From: yuyi Date: Tue, 7 May 2024 21:20:43 +0800 Subject: [PATCH] fix(utils): wait a second for new job to be created before fetching --- internal/dashboard/generated/bindata/bindata.go | 12 +++++++----- internal/resource/utils/jobs.go | 3 +++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/internal/dashboard/generated/bindata/bindata.go b/internal/dashboard/generated/bindata/bindata.go index a83b8b911..cde8839e2 100644 --- a/internal/dashboard/generated/bindata/bindata.go +++ b/internal/dashboard/generated/bindata/bindata.go @@ -200,11 +200,13 @@ var _bindata = map[string]func() (*asset, error){ // directory embedded in the file by go-bindata. // For example if you run go-bindata on data/... and data contains the // following hierarchy: -// data/ -// foo.txt -// img/ -// a.png -// b.png +// +// data/ +// foo.txt +// img/ +// a.png +// b.png +// // then AssetDir("data") would return []string{"foo.txt", "img"} // AssetDir("data/img") would return []string{"a.png", "b.png"} // AssetDir("foo.txt") and AssetDir("notexist") would return an error diff --git a/internal/resource/utils/jobs.go b/internal/resource/utils/jobs.go index 98a8a37fe..55eeefb4f 100644 --- a/internal/resource/utils/jobs.go +++ b/internal/resource/utils/jobs.go @@ -90,6 +90,9 @@ func RunJob(ctx context.Context, c client.Client, logger *logr.Logger, namespace return "", int32(cmdconst.ExitCodeNotExecuted), errors.Wrapf(err, "failed to create job of image: %s", image) } + // Wait for the job to be created before fetching it + time.Sleep(time.Second) + var jobObject *batchv1.Job for i := 0; i < obcfg.GetConfig().Time.CheckJobMaxRetries; i++ { jobObject, err = GetJob(ctx, c, namespace, fullJobName)