From 8d4a71be3da1a50b3bd7c0ff496b9b94c8bb00c4 Mon Sep 17 00:00:00 2001 From: Laurie Odgers Date: Fri, 30 Aug 2019 04:04:50 +1000 Subject: [PATCH] fix: destroy_grace_seconds are considered (#179) Closes #174 --- docker/resource_docker_container_funcs.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/docker/resource_docker_container_funcs.go b/docker/resource_docker_container_funcs.go index e1b0edc5..61b9423c 100644 --- a/docker/resource_docker_container_funcs.go +++ b/docker/resource_docker_container_funcs.go @@ -8,7 +8,6 @@ import ( "errors" "fmt" "log" - "math/rand" "os" "sort" "strconv" @@ -569,9 +568,8 @@ func resourceDockerContainerDelete(d *schema.ResourceData, meta interface{}) err if !d.Get("attach").(bool) { // Stop the container before removing if destroy_grace_seconds is defined if d.Get("destroy_grace_seconds").(int) > 0 { - mapped := int32(d.Get("destroy_grace_seconds").(int)) - timeoutInSeconds := rand.Int31n(mapped) - timeout := time.Duration(time.Duration(timeoutInSeconds) * time.Second) + timeout := time.Duration(int32(d.Get("destroy_grace_seconds").(int))) * time.Second + if err := client.ContainerStop(context.Background(), d.Id(), &timeout); err != nil { return fmt.Errorf("Error stopping container %s: %s", d.Id(), err) }