Skip to content

Commit 699a042

Browse files
sriniocisankhsin
authored andcommitted
Added - Ensure that WR does not error out if there are no work request errors
1 parent d198a1a commit 699a042

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

internal/service/devops/devops_deploy_stage_resource.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,9 +1136,12 @@ func deployStageWaitForWorkRequest(wId *string, entityType string, action oci_de
11361136
}
11371137
}
11381138

1139-
// The workrequest may have failed, check for errors if identifier is not found or work failed or got cancelled
1139+
// The workrequest may have failed, check for errors if identifier is not found or work failed or got cancelled.
11401140
if identifier == nil || response.Status == oci_devops.OperationStatusFailed {
1141-
return nil, getErrorFromDevopsDeployStageWorkRequest(client, wId, retryPolicy, entityType, action)
1141+
err := getErrorFromDevopsDeployStageWorkRequest(client, wId, retryPolicy, entityType, action)
1142+
if err != nil {
1143+
return nil, err
1144+
}
11421145
}
11431146

11441147
return identifier, nil
@@ -1156,13 +1159,17 @@ func getErrorFromDevopsDeployStageWorkRequest(client *oci_devops.DevopsClient, w
11561159
return err
11571160
}
11581161

1162+
if len(response.Items) == 0 {
1163+
return nil
1164+
}
1165+
11591166
allErrs := make([]string, 0)
11601167
for _, wrkErr := range response.Items {
11611168
allErrs = append(allErrs, *wrkErr.Message)
11621169
}
11631170
errorMessage := strings.Join(allErrs, "\n")
11641171

1165-
workRequestErr := fmt.Errorf("work request did not succeed, workId: %s, entity: %s, action: %s. Message: %s", *workId, entityType, action, errorMessage)
1172+
workRequestErr := fmt.Errorf("Work Request did not succeed, workId: %s, entity: %s, action: %s. Message: %s", *workId, entityType, action, errorMessage)
11661173

11671174
return workRequestErr
11681175
}

0 commit comments

Comments
 (0)