Skip to content

Commit 2f8e06d

Browse files
authored
Merge pull request #1858 from andyzhangx/fix-azcopy-jobstate
fix: incomplete azcopy job state during volume clone
2 parents f0514c3 + 44c8c5d commit 2f8e06d

File tree

2 files changed

+61
-1
lines changed

2 files changed

+61
-1
lines changed

pkg/util/util.go

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

pkg/util/util_test.go

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,39 @@ func TestGetAzcopyJob(t *testing.T) {
444444
expectedPercent: "100.0",
445445
expectedErr: nil,
446446
},
447+
{
448+
desc: "run exec parse azcopy job CompletedWithErrors",
449+
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",
450+
listErr: nil,
451+
enableShow: false,
452+
showStr: "",
453+
showErr: nil,
454+
expectedJobState: AzcopyJobCompletedWithErrors,
455+
expectedPercent: "100.0",
456+
expectedErr: nil,
457+
},
458+
{
459+
desc: "run exec parse azcopy job CompletedWithSkipped",
460+
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",
461+
listErr: nil,
462+
enableShow: false,
463+
showStr: "",
464+
showErr: nil,
465+
expectedJobState: AzcopyJobCompletedWithSkipped,
466+
expectedPercent: "100.0",
467+
expectedErr: nil,
468+
},
469+
{
470+
desc: "run exec parse azcopy job CompletedWithErrorsAndSkipped",
471+
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",
472+
listErr: nil,
473+
enableShow: false,
474+
showStr: "",
475+
showErr: nil,
476+
expectedJobState: AzcopyJobCompletedWithErrorsAndSkipped,
477+
expectedPercent: "100.0",
478+
expectedErr: nil,
479+
},
447480
{
448481
desc: "run exec get error in azcopy jobs show",
449482
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",
@@ -542,6 +575,27 @@ func TestParseAzcopyJobList(t *testing.T) {
542575
expectedJobState: AzcopyJobCompleted,
543576
expectedErr: nil,
544577
},
578+
{
579+
desc: "parse azcopy job CompletedWithErrors",
580+
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",
581+
expectedJobid: "",
582+
expectedJobState: AzcopyJobCompletedWithErrors,
583+
expectedErr: nil,
584+
},
585+
{
586+
desc: "parse azcopy job CompletedWithSkipped",
587+
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",
588+
expectedJobid: "",
589+
expectedJobState: AzcopyJobCompletedWithSkipped,
590+
expectedErr: nil,
591+
},
592+
{
593+
desc: "parse azcopy job CompletedWithErrorsAndSkipped",
594+
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",
595+
expectedJobid: "",
596+
expectedJobState: AzcopyJobCompletedWithErrorsAndSkipped,
597+
expectedErr: nil,
598+
},
545599
{
546600
desc: "parse azcopy job InProgress",
547601
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)