Skip to content

Commit eb33a4d

Browse files
authored
Merge pull request #2404 from k8s-infra-cherrypick-robot/cherry-pick-2403-to-release-1.31
[release-1.31] fix: incomplete azcopy job state during volume snapshot restore and clone
2 parents 91308cc + 573d90c commit eb33a4d

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
@@ -136,7 +136,7 @@ func (ac *Azcopy) GetAzcopyJob(dstFileshare string, authAzcopyEnv []string) (Azc
136136
klog.Warningf("failed to get azcopy job with error: %v, jobState: %v", err, jobState)
137137
return AzcopyJobError, "", fmt.Errorf("couldn't parse azcopy job list in azcopy %v", err)
138138
}
139-
if jobState == AzcopyJobCompleted {
139+
if jobState == AzcopyJobCompleted || jobState == AzcopyJobCompletedWithErrors || jobState == AzcopyJobCompletedWithSkipped || jobState == AzcopyJobCompletedWithErrorsAndSkipped {
140140
return jobState, "100.0", err
141141
}
142142
if jobid == "" {
@@ -185,6 +185,12 @@ func parseAzcopyJobList(joblist string) (string, AzcopyJobState, error) {
185185
jobid = segments[0]
186186
case "Completed":
187187
return jobid, AzcopyJobCompleted, nil
188+
case "CompletedWithErrors":
189+
return jobid, AzcopyJobCompletedWithErrors, nil
190+
case "CompletedWithSkipped":
191+
return jobid, AzcopyJobCompletedWithSkipped, nil
192+
case "CompletedWithErrorsAndSkipped":
193+
return jobid, AzcopyJobCompletedWithErrorsAndSkipped, nil
188194
}
189195
}
190196
if jobid == "" {

pkg/util/util_test.go

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