diff --git a/stackit/internal/resources/mongodb-flex/instance/actions.go b/stackit/internal/resources/mongodb-flex/instance/actions.go index a5ba4192..96f2e385 100644 --- a/stackit/internal/resources/mongodb-flex/instance/actions.go +++ b/stackit/internal/resources/mongodb-flex/instance/actions.go @@ -101,6 +101,7 @@ func (r Resource) Create(ctx context.Context, req resource.CreateRequest, resp * time.Sleep(30 * time.Second) process := res.WaitHandler(ctx, r.client.MongoDBFlex.Instance, plan.ProjectID.ValueString(), plan.ID.ValueString()) + process.SetTimeout(1 * time.Hour) ins, err := process.WaitWithContext(ctx) if err != nil { resp.Diagnostics.AddError("failed MongoDB instance creation validation", err.Error()) diff --git a/stackit/internal/resources/postgres-flex/instance/actions.go b/stackit/internal/resources/postgres-flex/instance/actions.go index 624ab260..4ffe825c 100644 --- a/stackit/internal/resources/postgres-flex/instance/actions.go +++ b/stackit/internal/resources/postgres-flex/instance/actions.go @@ -144,13 +144,11 @@ func (r Resource) createUser(ctx context.Context, plan *Instance, d *diag.Diagno // the default user credentials won't change username := "stackit" database := "stackit" - roles := []string{} for maxTries := 10; maxTries > -1; maxTries-- { c := r.client.PostgresFlex body := users.CreateUserJSONRequestBody{ Database: &database, - Roles: &roles, Username: &username, } res, err := c.Users.CreateUserWithResponse(ctx, plan.ProjectID.ValueString(), plan.ID.ValueString(), body) @@ -161,13 +159,28 @@ func (r Resource) createUser(ctx context.Context, plan *Instance, d *diag.Diagno if (res.StatusCode() == http.StatusNotFound || res.StatusCode() == http.StatusBadRequest) && maxTries > 0 { - time.Sleep(time.Second * 5) + time.Sleep(time.Second * 10) continue } if res.HasError != nil { d.AddError("failed create user request", res.HasError.Error()) } + if res.JSON400 != nil { + e := "" + if res.JSON400.Message != nil { + e = "message: " + *res.JSON400.Message + } + if res.JSON400.Fields != nil { + for k, v := range *res.JSON400.Fields { + e = e + "\n" + k + ": " + strings.Join(v, ", ") + + } + } + d.AddError("response is 400", e) + return + } + if res.JSON200 == nil { d.AddError("response is nil", "api returned nil response") return