mailgun: poll until domain destroy takes effect
Test failures indicate that this operation doesn't always take effect immediately: https://travis-ci.org/hashicorp/terraform/builds/103764466 Add a simple poll to retry a few times until it does. ``` --- PASS: TestAccMailgunDomain_Basic (1.51s) ``` Verified that this does the trick by looping the test and watching the logs for the retry behavior to kick in.
This commit is contained in:
parent
a5b28868a8
commit
be59831847
|
@ -3,7 +3,9 @@ package mailgun
|
|||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
"github.com/pearkes/mailgun"
|
||||
)
|
||||
|
@ -143,7 +145,16 @@ func resourceMailgunDomainDelete(d *schema.ResourceData, meta interface{}) error
|
|||
return fmt.Errorf("Error deleting domain: %s", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
// Give the destroy a chance to take effect
|
||||
return resource.Retry(1*time.Minute, func() error {
|
||||
_, err = client.RetrieveDomain(d.Id())
|
||||
if err == nil {
|
||||
log.Printf("[INFO] Retrying until domain disappears...")
|
||||
return fmt.Errorf("Domain seems to still exist; will check again.")
|
||||
}
|
||||
log.Printf("[INFO] Got error looking for domain, seems gone: %s", err)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func resourceMailgunDomainRead(d *schema.ResourceData, meta interface{}) error {
|
||||
|
|
|
@ -48,10 +48,10 @@ func testAccCheckMailgunDomainDestroy(s *terraform.State) error {
|
|||
continue
|
||||
}
|
||||
|
||||
_, err := client.RetrieveDomain(rs.Primary.ID)
|
||||
resp, err := client.RetrieveDomain(rs.Primary.ID)
|
||||
|
||||
if err == nil {
|
||||
return fmt.Errorf("Domain still exists")
|
||||
return fmt.Errorf("Domain still exists: %s", resp)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue