Skip to content

Commit 063b1ab

Browse files
committed
Add retry logic to domain's createResource func to avoid propagation delays
1 parent fc674e2 commit 063b1ab

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

linode/domain/resource.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"log"
77
"strconv"
8+
"time"
89

910
"github.com/hashicorp/terraform-plugin-log/tflog"
1011
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
@@ -144,6 +145,19 @@ func createResource(ctx context.Context, d *schema.ResourceData, meta any) diag.
144145

145146
ctx = populateLogAttributes(ctx, d)
146147

148+
// Wait for the new domain to become visible before reading
149+
err = helper.WithRetries(ctx, 10, 2*time.Second, func() (bool, error) {
150+
_, err := client.GetDomain(ctx, domain.ID)
151+
if err != nil {
152+
// The domain may not be immediately visible after creation
153+
return linodego.IsNotFound(err), err
154+
}
155+
return false, nil
156+
})
157+
if err != nil {
158+
return diag.Errorf("Error waiting for Linode Domain %d to become visible: %s", domain.ID, err)
159+
}
160+
147161
return readResource(ctx, d, meta)
148162
}
149163

0 commit comments

Comments
 (0)