Merge pull request #4777 from hashicorp/phinze/mailgun-domain-destroy-takes-a-sec
mailgun: poll until domain destroy takes effect
This commit is contained in:
commit
8d2e18234e
|
@ -3,7 +3,9 @@ package mailgun
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform/helper/resource"
|
||||||
"github.com/hashicorp/terraform/helper/schema"
|
"github.com/hashicorp/terraform/helper/schema"
|
||||||
"github.com/pearkes/mailgun"
|
"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 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 {
|
func resourceMailgunDomainRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
|
|
|
@ -48,10 +48,10 @@ func testAccCheckMailgunDomainDestroy(s *terraform.State) error {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := client.RetrieveDomain(rs.Primary.ID)
|
resp, err := client.RetrieveDomain(rs.Primary.ID)
|
||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return fmt.Errorf("Domain still exists")
|
return fmt.Errorf("Domain still exists: %s", resp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue