Skip to content

Commit d018eea

Browse files
authored
Merge pull request #1859 from k8s-infra-cherrypick-robot/cherry-pick-1858-to-release-1.25
[release-1.25] fix: incomplete azcopy job state during volume clone
2 parents 921e8e6 + 046a312 commit d018eea

File tree

2 files changed

+61
-1
lines changed

2 files changed

+61
-1
lines changed

pkg/util/util.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ func (ac *Azcopy) GetAzcopyJob(dstBlobContainer string, authAzcopyEnv []string)
257257
klog.Warningf("failed to get azcopy job with error: %v, jobState: %v", err, jobState)
258258
return AzcopyJobError, "", fmt.Errorf("couldn't parse azcopy job list in azcopy %v", err)
259259
}
260-
if jobState == AzcopyJobCompleted {
260+
if jobState == AzcopyJobCompleted || jobState == AzcopyJobCompletedWithErrors || jobState == AzcopyJobCompletedWithSkipped || jobState == AzcopyJobCompletedWithErrorsAndSkipped {
261261
return jobState, "100.0", err
262262
}
263263
if jobid == "" {
@@ -306,6 +306,12 @@ func parseAzcopyJobList(joblist string) (string, AzcopyJobState, error) {
306306
jobid = segments[0]
307307
case "Completed":
308308
return jobid, AzcopyJobCompleted, nil
309+
case "CompletedWithErrors":
310+
return jobid, AzcopyJobCompletedWithErrors, nil
311+
case "CompletedWithSkipped":
312+
return jobid, AzcopyJobCompletedWithSkipped, nil
313+
case "CompletedWithErrorsAndSkipped":
314+
return jobid, AzcopyJobCompletedWithErrorsAndSkipped, nil
309315
}
310316
}
311317
if jobid == "" {

pkg/util/util_test.go

+54
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,39 @@ func TestGetAzcopyJob(t *testing.T) {
437437
expectedPercent: "100.0",
438438
expectedErr: nil,
439439
},
440+
{
441+
desc: "run exec parse azcopy job CompletedWithErrors",
442+
listStr: "JobId: ed1c3833-eaff-fe42-71d7-513fb065a9d9\nStart Time: Monday, 07-Aug-23 03:29:54 UTC\nStatus: CompletedWithErrors\nCommand: copy https://{accountName}.file.core.windows.net/{srcFileshare}{SAStoken} https://{accountName}.file.core.windows.net/{dstFileshare}{SAStoken} --recursive --check-length=false",
443+
listErr: nil,
444+
enableShow: false,
445+
showStr: "",
446+
showErr: nil,
447+
expectedJobState: AzcopyJobCompletedWithErrors,
448+
expectedPercent: "100.0",
449+
expectedErr: nil,
450+
},
451+
{
452+
desc: "run exec parse azcopy job CompletedWithSkipped",
453+
listStr: "JobId: ed1c3833-eaff-fe42-71d7-513fb065a9d9\nStart Time: Monday, 07-Aug-23 03:29:54 UTC\nStatus: CompletedWithSkipped\nCommand: copy https://{accountName}.file.core.windows.net/{srcFileshare}{SAStoken} https://{accountName}.file.core.windows.net/{dstFileshare}{SAStoken} --recursive --check-length=false",
454+
listErr: nil,
455+
enableShow: false,
456+
showStr: "",
457+
showErr: nil,
458+
expectedJobState: AzcopyJobCompletedWithSkipped,
459+
expectedPercent: "100.0",
460+
expectedErr: nil,
461+
},
462+
{
463+
desc: "run exec parse azcopy job CompletedWithErrorsAndSkipped",
464+
listStr: "JobId: ed1c3833-eaff-fe42-71d7-513fb065a9d9\nStart Time: Monday, 07-Aug-23 03:29:54 UTC\nStatus: CompletedWithErrorsAndSkipped\nCommand: copy https://{accountName}.file.core.windows.net/{srcFileshare}{SAStoken} https://{accountName}.file.core.windows.net/{dstFileshare}{SAStoken} --recursive --check-length=false",
465+
listErr: nil,
466+
enableShow: false,
467+
showStr: "",
468+
showErr: nil,
469+
expectedJobState: AzcopyJobCompletedWithErrorsAndSkipped,
470+
expectedPercent: "100.0",
471+
expectedErr: nil,
472+
},
440473
{
441474
desc: "run exec get error in azcopy jobs show",
442475
listStr: "JobId: ed1c3833-eaff-fe42-71d7-513fb065a9d9\nStart Time: Monday, 07-Aug-23 03:29:54 UTC\nStatus: InProgress\nCommand: copy https://{accountName}.file.core.windows.net/{srcFileshare}{SAStoken} https://{accountName}.file.core.windows.net/{dstFileshare}{SAStoken} --recursive --check-length=false",
@@ -535,6 +568,27 @@ func TestParseAzcopyJobList(t *testing.T) {
535568
expectedJobState: AzcopyJobCompleted,
536569
expectedErr: nil,
537570
},
571+
{
572+
desc: "parse azcopy job CompletedWithErrors",
573+
str: "JobId: ed1c3833-eaff-fe42-71d7-513fb065a9d9\nStart Time: Monday, 07-Aug-23 03:29:54 UTC\nStatus: CompletedWithErrors\nCommand: copy https://{accountName}.file.core.windows.net/{srcFileshare}{SAStoken} https://{accountName}.file.core.windows.net/{dstFileshare}{SAStoken} --recursive --check-length=false",
574+
expectedJobid: "",
575+
expectedJobState: AzcopyJobCompletedWithErrors,
576+
expectedErr: nil,
577+
},
578+
{
579+
desc: "parse azcopy job CompletedWithSkipped",
580+
str: "JobId: ed1c3833-eaff-fe42-71d7-513fb065a9d9\nStart Time: Monday, 07-Aug-23 03:29:54 UTC\nStatus: CompletedWithSkipped\nCommand: copy https://{accountName}.file.core.windows.net/{srcFileshare}{SAStoken} https://{accountName}.file.core.windows.net/{dstFileshare}{SAStoken} --recursive --check-length=false",
581+
expectedJobid: "",
582+
expectedJobState: AzcopyJobCompletedWithSkipped,
583+
expectedErr: nil,
584+
},
585+
{
586+
desc: "parse azcopy job CompletedWithErrorsAndSkipped",
587+
str: "JobId: ed1c3833-eaff-fe42-71d7-513fb065a9d9\nStart Time: Monday, 07-Aug-23 03:29:54 UTC\nStatus: CompletedWithErrorsAndSkipped\nCommand: copy https://{accountName}.file.core.windows.net/{srcFileshare}{SAStoken} https://{accountName}.file.core.windows.net/{dstFileshare}{SAStoken} --recursive --check-length=false",
588+
expectedJobid: "",
589+
expectedJobState: AzcopyJobCompletedWithErrorsAndSkipped,
590+
expectedErr: nil,
591+
},
538592
{
539593
desc: "parse azcopy job InProgress",
540594
str: "JobId: ed1c3833-eaff-fe42-71d7-513fb065a9d9\nStart Time: Monday, 07-Aug-23 03:29:54 UTC\nStatus: InProgress\nCommand: copy https://{accountName}.file.core.windows.net/{srcFileshare}{SAStoken} https://{accountName}.file.core.windows.net/{dstFileshare}{SAStoken} --recursive --check-length=false",

0 commit comments

Comments
 (0)