Skip to content

Commit 4a13c99

Browse files
committed
fix: incomplete azcopy job state during restore and clone
1 parent bb91232 commit 4a13c99

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
@@ -121,7 +121,7 @@ func (ac *Azcopy) GetAzcopyJob(dstFileshare string, authAzcopyEnv []string) (Azc
121121
klog.Warningf("failed to get azcopy job with error: %v, jobState: %v", err, jobState)
122122
return AzcopyJobError, "", fmt.Errorf("couldn't parse azcopy job list in azcopy %v", err)
123123
}
124-
if jobState == AzcopyJobCompleted {
124+
if jobState == AzcopyJobCompleted || jobState == AzcopyJobCompletedWithErrors || jobState == AzcopyJobCompletedWithSkipped || jobState == AzcopyJobCompletedWithErrorsAndSkipped {
125125
return jobState, "100.0", err
126126
}
127127
if jobid == "" {
@@ -170,6 +170,12 @@ func parseAzcopyJobList(joblist string) (string, AzcopyJobState, error) {
170170
jobid = segments[0]
171171
case "Completed":
172172
return jobid, AzcopyJobCompleted, nil
173+
case "CompletedWithErrors":
174+
return jobid, AzcopyJobCompletedWithErrors, nil
175+
case "CompletedWithSkipped":
176+
return jobid, AzcopyJobCompletedWithSkipped, nil
177+
case "CompletedWithErrorsAndSkipped":
178+
return jobid, AzcopyJobCompletedWithErrorsAndSkipped, nil
173179
}
174180
}
175181
if jobid == "" {

pkg/util/util_test.go

+54
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,39 @@ func TestGetAzcopyJob(t *testing.T) {
116116
expectedPercent: "100.0",
117117
expectedErr: nil,
118118
},
119+
{
120+
desc: "run exec parse azcopy job CompletedWithErrors",
121+
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",
122+
listErr: nil,
123+
enableShow: false,
124+
showStr: "",
125+
showErr: nil,
126+
expectedJobState: AzcopyJobCompletedWithErrors,
127+
expectedPercent: "100.0",
128+
expectedErr: nil,
129+
},
130+
{
131+
desc: "run exec parse azcopy job CompletedWithSkipped",
132+
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",
133+
listErr: nil,
134+
enableShow: false,
135+
showStr: "",
136+
showErr: nil,
137+
expectedJobState: AzcopyJobCompletedWithSkipped,
138+
expectedPercent: "100.0",
139+
expectedErr: nil,
140+
},
141+
{
142+
desc: "run exec parse azcopy job CompletedWithErrorsAndSkipped",
143+
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",
144+
listErr: nil,
145+
enableShow: false,
146+
showStr: "",
147+
showErr: nil,
148+
expectedJobState: AzcopyJobCompletedWithErrorsAndSkipped,
149+
expectedPercent: "100.0",
150+
expectedErr: nil,
151+
},
119152
{
120153
desc: "run exec get error in azcopy jobs show",
121154
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",
@@ -248,6 +281,27 @@ func TestParseAzcopyJobList(t *testing.T) {
248281
expectedJobState: AzcopyJobCompleted,
249282
expectedErr: nil,
250283
},
284+
{
285+
desc: "parse azcopy job CompletedWithErrors",
286+
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",
287+
expectedJobid: "",
288+
expectedJobState: AzcopyJobCompletedWithErrors,
289+
expectedErr: nil,
290+
},
291+
{
292+
desc: "parse azcopy job CompletedWithSkipped",
293+
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",
294+
expectedJobid: "",
295+
expectedJobState: AzcopyJobCompletedWithSkipped,
296+
expectedErr: nil,
297+
},
298+
{
299+
desc: "parse azcopy job CompletedWithErrorsAndSkipped",
300+
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",
301+
expectedJobid: "",
302+
expectedJobState: AzcopyJobCompletedWithErrorsAndSkipped,
303+
expectedErr: nil,
304+
},
251305
{
252306
desc: "parse azcopy job InProgress",
253307
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)