Skip to content

Commit

Permalink
log improvement: subnet delete retry logs
Browse files Browse the repository at this point in the history
  • Loading branch information
deepaksibm committed Jan 10, 2022
1 parent f60e407 commit 1352595
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ibm/resource_ibm_is_subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,7 @@ func subnetDelete(d *schema.ResourceData, meta interface{}, id string) error {
response, err = sess.DeleteSubnet(deleteSubnetOptions)
if err != nil {
if response != nil && response.StatusCode == 409 {
log.Printf("[DEBUG] Delete subnet response status code: 409 conflict, provider will try again. %s", err)
_, err = isWaitForSubnetDeleteRetry(sess, d.Id(), d.Timeout(schema.TimeoutDelete))
if err != nil {
return fmt.Errorf("Error Deleting Subnet : %s", err)
Expand All @@ -682,15 +683,15 @@ func subnetDelete(d *schema.ResourceData, meta interface{}, id string) error {
}

func isWaitForSubnetDeleteRetry(vpcClient *vpcv1.VpcV1, id string, timeout time.Duration) (interface{}, error) {
log.Printf("Retrying subnet (%s) delete", id)
log.Printf("[DEBUG] Retrying subnet (%s) delete", id)
stateConf := &resource.StateChangeConf{
Pending: []string{isSubnetInUse},
Target: []string{isSubnetDeleting, isSubnetDeleted, ""},
Refresh: func() (interface{}, string, error) {
deleteSubnetOptions := &vpcv1.DeleteSubnetOptions{
ID: &id,
}
log.Printf("Retrying subnet (%s) delete", id)
log.Printf("[DEBUG] Retrying subnet (%s) delete", id)
response, err := vpcClient.DeleteSubnet(deleteSubnetOptions)
if err != nil {
if response != nil && response.StatusCode == 409 {
Expand Down

0 comments on commit 1352595

Please sign in to comment.