func ReadDomain(d *schema.ResourceData, meta interface{}) error {
mg := meta.(*mailgun.MailgunImpl)
- ctx, cancel := context.WithTimeout(context.Background(), time.Second*30)
+ ctx, cancel := context.WithTimeout(context.Background(), time.Second*120)
defer cancel()
domainName := d.Id()
mg = mailgun.NewMailgun(domainName, mg.APIKey())
d.Set("unsubscribe_tracking_settings_html_footer", domainTracking.Unsubscribe.HTMLFooter)
d.Set("unsubscribe_tracking_settings_text_footer", domainTracking.Unsubscribe.TextFooter)
- time.Sleep(25 * time.Second)
-
- ipAddress, err := mg.ListDomainIPS(ctx)
+ ipAddress, err := getIps(ctx, mg)
if err != nil {
return fmt.Errorf("Error Getting mailgun domain ips1 for %s: Error: %s", d.Id(), err)
}
return []*schema.ResourceData{d}, nil
}
+
+func getIps(ctx context.Context,mg *mailgun.MailgunImpl) ([]mailgun.IPAddress, error){
+ start := time.Now()
+ t := time.Now()
+ ipAddress, err := mg.ListDomainIPS(ctx)
+ for (err != nil && t.Sub(start)< 120 * time.Second) {
+ ipAddress, err = mg.ListDomainIPS(ctx)
+ time.Sleep(5 * time.Second)
+ t = time.Now()
+ }
+ return ipAddress, err
+}
}
func getFullDomain(mg *mailgun.MailgunImpl, domainName string) (*fullDomain, error) {
- ctx, cancel := context.WithTimeout(context.Background(), time.Second*30)
+ ctx, cancel := context.WithTimeout(context.Background(), time.Second*120)
defer cancel()
mg = mailgun.NewMailgun(domainName, mg.APIKey())
return nil, fmt.Errorf("Error Getting mailgun domain tracking Details for %s: Error: %s", domainName, err)
}
- ipAddress, err := mg.ListDomainIPS(ctx)
+ ipAddress, err := getIps(ctx, mg)
+
if err != nil {
return nil, fmt.Errorf("Error Getting mailgun domain ips2 for %s: Error: %s", domainName, err)
}
mg := testAccProvider.Meta().(*mailgun.MailgunImpl)
ctx, cancel := context.WithTimeout(context.Background(), time.Second*30)
defer cancel()
-
+ time.Sleep(5 * time.Second)
_, err := mg.GetDomain(ctx, domain.domainResponse.Domain.Name)
if err == nil {
return fmt.Errorf("domain still exists")