Skip to content

Commit

Permalink
fix: added validation to verify if a container was removed and the wa…
Browse files Browse the repository at this point in the history
…iting time was reduced
  • Loading branch information
PacoDw committed Oct 1, 2019
1 parent 491d914 commit c63a38a
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions mongodbatlas/resource_mongodbatlas_network_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,9 @@ func resourceMongoDBAtlasNetworkContainerDelete(d *schema.ResourceData, meta int
Pending: []string{"provisioned_container"},
Target: []string{"deleted"},
Refresh: resourceNetworkContainerRefreshFunc(d, conn),
Timeout: 3 * time.Hour,
MinTimeout: 60 * time.Second,
Delay: 5 * time.Minute,
Timeout: 1 * time.Hour,
MinTimeout: 10 * time.Second,
Delay: 2 * time.Minute,
}

// Wait, catching any errors
Expand Down Expand Up @@ -285,11 +285,15 @@ func resourceNetworkContainerRefreshFunc(d *schema.ResourceData, client *matlas.
containerID := ids["container_id"]

var err error
container, _, err := client.Containers.Get(context.Background(), projectID, containerID)
container, res, err := client.Containers.Get(context.Background(), projectID, containerID)
if err != nil {
if res.StatusCode == 404 {
return 42, "deleted", nil
}
return nil, "", err
}
if *container.Provisioned && err == nil {
return nil, "provisioned_container", nil
} else if err != nil {
return nil, "", err
}

_, err = client.Containers.Delete(context.Background(), projectID, containerID)
Expand Down

0 comments on commit c63a38a

Please sign in to comment.