Merge pull request 'fix: adjust timeouts to 90 mins' (#92) from fix/adjust_timeouts_90_min into main
Some checks failed
Publish / Check GoReleaser config (push) Successful in 10s
CI Workflow / Check GoReleaser config (pull_request) Failing after 47s
CI Workflow / Prepare GO cache (pull_request) Successful in 5m39s
CI Workflow / Test readiness for publishing provider (pull_request) Has been skipped
CI Workflow / CI run tests (pull_request) Has been skipped
CI Workflow / CI run build and linting (pull_request) Has been skipped
CI Workflow / Code coverage report (pull_request) Has been skipped
Publish / Publish provider (push) Successful in 14m52s
TF Acceptance Tests Workflow / Acceptance Tests (pull_request) Failing after 1h38m32s
Some checks failed
Publish / Check GoReleaser config (push) Successful in 10s
CI Workflow / Check GoReleaser config (pull_request) Failing after 47s
CI Workflow / Prepare GO cache (pull_request) Successful in 5m39s
CI Workflow / Test readiness for publishing provider (pull_request) Has been skipped
CI Workflow / CI run tests (pull_request) Has been skipped
CI Workflow / CI run build and linting (pull_request) Has been skipped
CI Workflow / Code coverage report (pull_request) Has been skipped
Publish / Publish provider (push) Successful in 14m52s
TF Acceptance Tests Workflow / Acceptance Tests (pull_request) Failing after 1h38m32s
Reviewed-on: #92
This commit is contained in:
commit
d34927537a
9 changed files with 38 additions and 33 deletions
|
|
@ -209,8 +209,8 @@ func (r *databaseResource) Create(
|
|||
)
|
||||
|
||||
database, err := postgresflexalphaWait.GetDatabaseByIdWaitHandler(ctx, r.client.DefaultAPI, projectID, instanceID, region, databaseID).
|
||||
SetTimeout(15 * time.Minute).
|
||||
SetSleepBeforeWait(15 * time.Second).
|
||||
SetTimeout(30 * time.Minute).
|
||||
SetSleepBeforeWait(10 * time.Second).
|
||||
WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(
|
||||
|
|
@ -279,8 +279,8 @@ func (r *databaseResource) Read(
|
|||
)
|
||||
|
||||
databaseResp, err := postgresflexalphaWait.GetDatabaseByIdWaitHandler(ctx, r.client.DefaultAPI, projectID, instanceID, region, databaseID).
|
||||
SetTimeout(15 * time.Minute).
|
||||
SetSleepBeforeWait(15 * time.Second).
|
||||
SetTimeout(30 * time.Minute).
|
||||
SetSleepBeforeWait(10 * time.Second).
|
||||
WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(
|
||||
|
|
@ -386,8 +386,8 @@ func (r *databaseResource) Update(
|
|||
ctx = core.LogResponse(ctx)
|
||||
|
||||
databaseResp, err := postgresflexalphaWait.GetDatabaseByIdWaitHandler(ctx, r.client.DefaultAPI, projectId, instanceId, region, databaseId).
|
||||
SetTimeout(15 * time.Minute).
|
||||
SetSleepBeforeWait(15 * time.Second).
|
||||
SetTimeout(30 * time.Minute).
|
||||
SetSleepBeforeWait(10 * time.Second).
|
||||
WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "error updating database", err.Error())
|
||||
|
|
|
|||
|
|
@ -208,7 +208,7 @@ func (r *instanceResource) Create(
|
|||
)
|
||||
|
||||
waitResp, err := wait.CreateInstanceWaitHandler(ctx, r.client.DefaultAPI, projectID, region, *instanceID).
|
||||
SetTimeout(30 * time.Minute).
|
||||
SetTimeout(90 * time.Minute).
|
||||
SetSleepBeforeWait(10 * time.Second).
|
||||
WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
|
|
@ -446,7 +446,7 @@ func (r *instanceResource) Update(
|
|||
region,
|
||||
instanceID,
|
||||
).
|
||||
SetTimeout(30 * time.Minute).
|
||||
SetTimeout(90 * time.Minute).
|
||||
SetSleepBeforeWait(10 * time.Second).
|
||||
WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -799,7 +799,7 @@ func testAccCheckPostgresFlexDestroy(s *terraform.State) error {
|
|||
testutils.ProjectId,
|
||||
testutils.Region,
|
||||
items[i].Id,
|
||||
15*time.Minute,
|
||||
30*time.Minute,
|
||||
10*time.Second,
|
||||
)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -241,7 +241,7 @@ func (r *userResource) Create(
|
|||
).SetSleepBeforeWait(
|
||||
10 * time.Second,
|
||||
).SetTimeout(
|
||||
15 * time.Minute,
|
||||
30 * time.Minute,
|
||||
).WaitWithContext(ctx)
|
||||
|
||||
if err != nil {
|
||||
|
|
@ -322,7 +322,7 @@ func (r *userResource) Read(
|
|||
).SetSleepBeforeWait(
|
||||
10 * time.Second,
|
||||
).SetTimeout(
|
||||
15 * time.Minute,
|
||||
30 * time.Minute,
|
||||
).WaitWithContext(ctx)
|
||||
|
||||
if err != nil {
|
||||
|
|
@ -445,7 +445,7 @@ func (r *userResource) Update(
|
|||
).SetSleepBeforeWait(
|
||||
10 * time.Second,
|
||||
).SetTimeout(
|
||||
15 * time.Minute,
|
||||
30 * time.Minute,
|
||||
).WaitWithContext(ctx)
|
||||
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -193,6 +193,7 @@ func (r *databaseResource) Create(ctx context.Context, req resource.CreateReques
|
|||
data.Owner.ValueString(),
|
||||
).
|
||||
SetSleepBeforeWait(10 * time.Second).
|
||||
SetTimeout(90 * time.Minute).
|
||||
WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(
|
||||
|
|
@ -253,9 +254,9 @@ func (r *databaseResource) Create(ctx context.Context, req resource.CreateReques
|
|||
region,
|
||||
databaseName,
|
||||
).SetSleepBeforeWait(
|
||||
30 * time.Second,
|
||||
10 * time.Second,
|
||||
).SetTimeout(
|
||||
15 * time.Minute,
|
||||
90 * time.Minute,
|
||||
).WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(
|
||||
|
|
|
|||
|
|
@ -354,8 +354,8 @@ func (r *instanceResource) Update(ctx context.Context, req resource.UpdateReques
|
|||
|
||||
waitResp, err := wait.
|
||||
UpdateInstanceWaitHandler(ctx, r.client.DefaultAPI, projectID, instanceID, region).
|
||||
SetSleepBeforeWait(15 * time.Second).
|
||||
SetTimeout(45 * time.Minute).
|
||||
SetSleepBeforeWait(10 * time.Second).
|
||||
SetTimeout(90 * time.Minute).
|
||||
WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(
|
||||
|
|
@ -416,7 +416,10 @@ func (r *instanceResource) Delete(ctx context.Context, req resource.DeleteReques
|
|||
|
||||
ctx = core.LogResponse(ctx)
|
||||
|
||||
delResp, err := wait.DeleteInstanceWaitHandler(ctx, r.client.DefaultAPI, projectID, instanceID, region).WaitWithContext(ctx)
|
||||
delResp, err := wait.DeleteInstanceWaitHandler(ctx, r.client.DefaultAPI, projectID, instanceID, region).
|
||||
SetSleepBeforeWait(10 * time.Second).
|
||||
SetTimeout(90 * time.Minute).
|
||||
WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(
|
||||
ctx,
|
||||
|
|
|
|||
|
|
@ -308,7 +308,7 @@ func (r *userResource) Create(
|
|||
region,
|
||||
userId,
|
||||
).SetSleepBeforeWait(
|
||||
90 * time.Second,
|
||||
10 * time.Second,
|
||||
).SetTimeout(
|
||||
90 * time.Minute,
|
||||
).WaitWithContext(ctx)
|
||||
|
|
@ -459,23 +459,23 @@ func (r *userResource) Delete(
|
|||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId := model.ProjectId.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
userId := model.UserId.ValueInt64()
|
||||
projectID := model.ProjectId.ValueString()
|
||||
instanceID := model.InstanceId.ValueString()
|
||||
userID := model.UserId.ValueInt64()
|
||||
region := model.Region.ValueString()
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
ctx = tflog.SetField(ctx, "instance_id", instanceId)
|
||||
ctx = tflog.SetField(ctx, "user_id", userId)
|
||||
ctx = tflog.SetField(ctx, "project_id", projectID)
|
||||
ctx = tflog.SetField(ctx, "instance_id", instanceID)
|
||||
ctx = tflog.SetField(ctx, "user_id", userID)
|
||||
ctx = tflog.SetField(ctx, "region", region)
|
||||
|
||||
// Delete existing record set
|
||||
// err := r.client.DeleteUserRequest(ctx, projectId, region, instanceId, userId).Execute()
|
||||
err := r.client.DefaultAPI.DeleteUserRequest(ctx, projectId, region, instanceId, userId).Execute()
|
||||
err := r.client.DefaultAPI.DeleteUserRequest(ctx, projectID, region, instanceID, userID).Execute()
|
||||
if err != nil {
|
||||
var oapiErr *oapierror.GenericOpenAPIError
|
||||
ok := errors.As(err, &oapiErr)
|
||||
if !ok {
|
||||
// TODO err handling
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "User Delete Error", fmt.Sprintf("error is no oapi error: %v", err))
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -487,12 +487,14 @@ func (r *userResource) Delete(
|
|||
// tflog.Warn(ctx, "[delete user] Wait handler got error 500")
|
||||
// return false, nil, nil
|
||||
default:
|
||||
// TODO err handling
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "User Delete Error", fmt.Sprintf("Unexpected API error: %v", err))
|
||||
return
|
||||
}
|
||||
}
|
||||
// Delete existing record set
|
||||
_, err = sqlserverflexbetaWait.DeleteUserWaitHandler(ctx, r.client.DefaultAPI, projectId, region, instanceId, userId).
|
||||
_, err = sqlserverflexbetaWait.DeleteUserWaitHandler(ctx, r.client.DefaultAPI, projectID, region, instanceID, userID).
|
||||
SetTimeout(90 * time.Minute).
|
||||
SetSleepBeforeWait(10 * time.Second).
|
||||
WaitWithContext(ctx)
|
||||
if err != nil {
|
||||
core.LogAndAddError(ctx, &resp.Diagnostics, "User Delete Error", fmt.Sprintf("Calling API: %v", err))
|
||||
|
|
|
|||
|
|
@ -281,8 +281,8 @@ func GetDatabaseByIdWaitHandler(
|
|||
if databaseID > math.MaxInt32 {
|
||||
return false, nil, fmt.Errorf("databaseID too large for int32")
|
||||
}
|
||||
dbId32 := int32(databaseID) //nolint:gosec // is checked above
|
||||
s, err := a.GetDatabaseRequest(ctx, projectID, region, instanceID, dbId32).Execute()
|
||||
dbID32 := int32(databaseID) //nolint:gosec // is checked above
|
||||
s, err := a.GetDatabaseRequest(ctx, projectID, region, instanceID, dbID32).Execute()
|
||||
if err != nil {
|
||||
var oapiErr *oapierror.GenericOpenAPIError
|
||||
ok := errors.As(err, &oapiErr)
|
||||
|
|
@ -290,6 +290,7 @@ func GetDatabaseByIdWaitHandler(
|
|||
return false, nil, fmt.Errorf("could not convert error to oapierror.GenericOpenAPIError")
|
||||
}
|
||||
switch oapiErr.StatusCode {
|
||||
// TODO: work-around
|
||||
case http.StatusBadGateway, http.StatusGatewayTimeout, http.StatusServiceUnavailable:
|
||||
tflog.Warn(
|
||||
ctx, "api responded with 50[2,3,4] status", map[string]interface{}{
|
||||
|
|
|
|||
|
|
@ -94,6 +94,7 @@ func CreateInstanceWaitHandler(
|
|||
case http.StatusNotFound:
|
||||
return false, nil, nil
|
||||
default:
|
||||
// TODO: work-around
|
||||
if strings.Contains(err.Error(), "is not a valid InstanceEdition") {
|
||||
tflog.Info(ctx, "API WORKAROUND", map[string]interface{}{"err": err})
|
||||
return false, nil, nil
|
||||
|
|
@ -263,7 +264,6 @@ func DeleteInstanceWaitHandler(
|
|||
return true, nil, nil
|
||||
},
|
||||
)
|
||||
handler.SetTimeout(30 * time.Minute)
|
||||
return handler
|
||||
}
|
||||
|
||||
|
|
@ -405,7 +405,5 @@ func DeleteUserWaitHandler(
|
|||
}
|
||||
},
|
||||
)
|
||||
handler.SetTimeout(15 * time.Minute)
|
||||
handler.SetSleepBeforeWait(15 * time.Second)
|
||||
return handler
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue