Skip to content

Commit 48cb930

Browse files
committed
Fix delete deployment when there is an error
Signed-off-by: Ferran Rodenas <[email protected]>
1 parent b5124c7 commit 48cb930

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

vra/resource_deployment.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,7 +1103,10 @@ func deploymentActionStatusRefreshFunc(apiClient client.MulticloudIaaS, deployme
11031103
func deploymentDeleteStatusRefreshFunc(apiClient client.MulticloudIaaS, id string) resource.StateRefreshFunc {
11041104
return func() (interface{}, string, error) {
11051105
ret, err := apiClient.Deployments.GetDeploymentByIDUsingGET(
1106-
deployments.NewGetDeploymentByIDUsingGETParams().WithDeploymentID(strfmt.UUID(id)))
1106+
deployments.NewGetDeploymentByIDUsingGETParams().
1107+
WithDeploymentID(strfmt.UUID(id)).
1108+
WithExpandLastRequest(withBool(true)).
1109+
WithAPIVersion(withString(DeploymentsAPIVersion)))
11071110
if err != nil {
11081111
switch err.(type) {
11091112
case *deployments.GetDeploymentByIDUsingGETNotFound:
@@ -1113,7 +1116,17 @@ func deploymentDeleteStatusRefreshFunc(apiClient client.MulticloudIaaS, id strin
11131116
}
11141117
}
11151118

1116-
return [...]string{id}, reflect.TypeOf(ret).String(), nil
1119+
status := ret.Payload.Status
1120+
switch status {
1121+
case models.DeploymentStatusDELETEINPROGRESS:
1122+
return [...]string{id}, reflect.TypeOf(ret).String(), nil
1123+
case models.DeploymentStatusDELETESUCCESSFUL:
1124+
return [...]string{id}, reflect.TypeOf(ret).String(), nil
1125+
case models.DeploymentStatusDELETEFAILED:
1126+
return [...]string{id}, reflect.TypeOf(ret).String(), fmt.Errorf(ret.Payload.LastRequest.Details)
1127+
default:
1128+
return [...]string{id}, reflect.TypeOf(ret).String(), fmt.Errorf("deploymentStatusRefreshFunc: unknown status %v", status)
1129+
}
11171130
}
11181131
}
11191132

0 commit comments

Comments
 (0)