Skip to content

Commit

Permalink
added failure check and tainting on failure
Browse files Browse the repository at this point in the history
  • Loading branch information
ujjwal-ibm authored and hkantare committed Jul 7, 2021
1 parent 60264ca commit 868bb01
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ibm/resource_ibm_is_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -996,6 +996,7 @@ func isWaitForInstanceAvailable(instanceC *vpcv1.VpcV1, id string, timeout time.
forceTimeout := v.(int)
go isRestartStartAction(instanceC, id, d, forceTimeout, communicator)
}

return stateConf.WaitForState()
}

Expand Down Expand Up @@ -1040,6 +1041,10 @@ func isInstanceRefreshFunc(instanceC *vpcv1.VpcV1, id string, d *schema.Resource
if *instance.Status == "available" || *instance.Status == "failed" || *instance.Status == "running" {
// let know the isRestartStartAction() to stop
close(communicator)
// taint the instance if status is failed
if *instance.Status == "failed" {
return instance, *instance.Status, fmt.Errorf("Instance (%s) went into failed state during the operation \n [WARNING] Running terraform apply again will remove the tainted instance and attempt to create the instance again replacing the previous configuration", *instance.ID)
}
return instance, *instance.Status, nil

}
Expand Down

0 comments on commit 868bb01

Please sign in to comment.