diff --git a/pkg/util/util.go b/pkg/util/util.go index c229efd76..4225a2cf8 100644 --- a/pkg/util/util.go +++ b/pkg/util/util.go @@ -256,7 +256,7 @@ func (ac *Azcopy) GetAzcopyJob(dstBlobContainer string, authAzcopyEnv []string) klog.Warningf("failed to get azcopy job with error: %v, jobState: %v", err, jobState) return AzcopyJobError, "", fmt.Errorf("couldn't parse azcopy job list in azcopy %v", err) } - if jobState == AzcopyJobCompleted { + if jobState == AzcopyJobCompleted || jobState == AzcopyJobCompletedWithErrors || jobState == AzcopyJobCompletedWithSkipped || jobState == AzcopyJobCompletedWithErrorsAndSkipped { return jobState, "100.0", err } if jobid == "" { @@ -305,6 +305,12 @@ func parseAzcopyJobList(joblist string) (string, AzcopyJobState, error) { jobid = segments[0] case "Completed": return jobid, AzcopyJobCompleted, nil + case "CompletedWithErrors": + return jobid, AzcopyJobCompletedWithErrors, nil + case "CompletedWithSkipped": + return jobid, AzcopyJobCompletedWithSkipped, nil + case "CompletedWithErrorsAndSkipped": + return jobid, AzcopyJobCompletedWithErrorsAndSkipped, nil } } if jobid == "" { diff --git a/pkg/util/util_test.go b/pkg/util/util_test.go index 75dd748ec..8286e23ba 100644 --- a/pkg/util/util_test.go +++ b/pkg/util/util_test.go @@ -444,6 +444,39 @@ func TestGetAzcopyJob(t *testing.T) { expectedPercent: "100.0", expectedErr: nil, }, + { + desc: "run exec parse azcopy job CompletedWithErrors", + 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", + listErr: nil, + enableShow: false, + showStr: "", + showErr: nil, + expectedJobState: AzcopyJobCompletedWithErrors, + expectedPercent: "100.0", + expectedErr: nil, + }, + { + desc: "run exec parse azcopy job CompletedWithSkipped", + 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", + listErr: nil, + enableShow: false, + showStr: "", + showErr: nil, + expectedJobState: AzcopyJobCompletedWithSkipped, + expectedPercent: "100.0", + expectedErr: nil, + }, + { + desc: "run exec parse azcopy job CompletedWithErrorsAndSkipped", + 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", + listErr: nil, + enableShow: false, + showStr: "", + showErr: nil, + expectedJobState: AzcopyJobCompletedWithErrorsAndSkipped, + expectedPercent: "100.0", + expectedErr: nil, + }, { desc: "run exec get error in azcopy jobs show", 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) { expectedJobState: AzcopyJobCompleted, expectedErr: nil, }, + { + desc: "parse azcopy job CompletedWithErrors", + 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", + expectedJobid: "", + expectedJobState: AzcopyJobCompletedWithErrors, + expectedErr: nil, + }, + { + desc: "parse azcopy job CompletedWithSkipped", + 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", + expectedJobid: "", + expectedJobState: AzcopyJobCompletedWithSkipped, + expectedErr: nil, + }, + { + desc: "parse azcopy job CompletedWithErrorsAndSkipped", + 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", + expectedJobid: "", + expectedJobState: AzcopyJobCompletedWithErrorsAndSkipped, + expectedErr: nil, + }, { desc: "parse azcopy job InProgress", 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",