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 24, 2022
1 parent e588feb commit 36b81d9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ibm/service/vpc/resource_ibm_is_subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,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] Error Deleting Subnet : %s", err)
Expand All @@ -685,15 +686,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 36b81d9

Please sign in to comment.