Skip to content

Commit

Permalink
CB-27671 Updated environment deletion states, handled null cascading …
Browse files Browse the repository at this point in the history
…delete option (#174)
  • Loading branch information
daszabo authored Nov 5, 2024
1 parent 2140a39 commit 6362328
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 15 deletions.
27 changes: 15 additions & 12 deletions resources/environments/polling.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,26 @@ func waitForEnvironmentToBeDeleted(environmentName string, fallbackTimeout time.
return err
}
stateConf := &retry.StateChangeConf{
Pending: []string{"STORAGE_CONSUMPTION_COLLECTION_UNSCHEDULING_IN_PROGRESS",
"NETWORK_DELETE_IN_PROGRESS",
"FREEIPA_DELETE_IN_PROGRESS",
"RDBMS_DELETE_IN_PROGRESS",
"IDBROKER_MAPPINGS_DELETE_IN_PROGRESS",
"S3GUARD_TABLE_DELETE_IN_PROGRESS",
"CLUSTER_DEFINITION_DELETE_PROGRESS",
Pending: []string{
"CLUSTER_DEFINITION_CLEANUP_PROGRESS",
"UMS_RESOURCE_DELETE_IN_PROGRESS",
"DELETE_INITIATED",
"CLUSTER_DEFINITION_DELETE_PROGRESS",
"COMPUTE_CLUSTERS_DELETE_IN_PROGRESS",
"DATAHUB_CLUSTERS_DELETE_IN_PROGRESS",
"DATALAKE_CLUSTERS_DELETE_IN_PROGRESS",
"PUBLICKEY_DELETE_IN_PROGRESS",
"DELETE_INITIATED",
"ENVIRONMENT_ENCRYPTION_RESOURCES_DELETED",
"ENVIRONMENT_RESOURCE_ENCRYPTION_DELETE_IN_PROGRESS",
"EVENT_CLEANUP_IN_PROGRESS",
"EXPERIENCE_DELETE_IN_PROGRESS",
"ENVIRONMENT_RESOURCE_ENCRYPTION_DELETE_IN_PROGRESS",
"ENVIRONMENT_ENCRYPTION_RESOURCES_DELETED"},
"FREEIPA_DELETE_IN_PROGRESS",
"IDBROKER_MAPPINGS_DELETE_IN_PROGRESS",
"NETWORK_DELETE_IN_PROGRESS",
"PUBLICKEY_DELETE_IN_PROGRESS",
"RDBMS_DELETE_IN_PROGRESS",
"S3GUARD_TABLE_DELETE_IN_PROGRESS",
"STORAGE_CONSUMPTION_COLLECTION_UNSCHEDULING_IN_PROGRESS",
"UMS_RESOURCE_DELETE_IN_PROGRESS",
},
Target: []string{},
Delay: 5 * time.Second,
Timeout: *timeout,
Expand Down
6 changes: 5 additions & 1 deletion resources/environments/resource_aws_environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,11 @@ func (r *awsEnvironmentResource) Delete(ctx context.Context, req resource.Delete
if resp.Diagnostics.HasError() {
return
}
if err := deleteEnvironmentWithDiagnosticHandle(state.EnvironmentName.ValueString(), state.Cascading.ValueBool(), ctx, r.client, resp, state.PollingOptions); err != nil {
cascading := state.Cascading.ValueBool()
if state.Cascading.IsNull() {
cascading = true
}
if err := deleteEnvironmentWithDiagnosticHandle(state.EnvironmentName.ValueString(), cascading, ctx, r.client, resp, state.PollingOptions); err != nil {
return
}
}
Expand Down
6 changes: 5 additions & 1 deletion resources/environments/resource_azure_environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,11 @@ func (r *azureEnvironmentResource) Delete(ctx context.Context, req resource.Dele
return
}

if err := deleteEnvironmentWithDiagnosticHandle(state.EnvironmentName.ValueString(), state.Cascading.ValueBool(), ctx, r.client, resp, state.PollingOptions); err != nil {
cascading := state.Cascading.ValueBool()
if state.Cascading.IsNull() {
cascading = true
}
if err := deleteEnvironmentWithDiagnosticHandle(state.EnvironmentName.ValueString(), cascading, ctx, r.client, resp, state.PollingOptions); err != nil {
return
}
}
6 changes: 5 additions & 1 deletion resources/environments/resource_gcp_environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,11 @@ func (r *gcpEnvironmentResource) Delete(ctx context.Context, req resource.Delete
return
}

if err := deleteEnvironmentWithDiagnosticHandle(state.EnvironmentName.ValueString(), state.Cascading.ValueBool(), ctx, r.client, resp, state.PollingOptions); err != nil {
cascading := state.Cascading.ValueBool()
if state.Cascading.IsNull() {
cascading = true
}
if err := deleteEnvironmentWithDiagnosticHandle(state.EnvironmentName.ValueString(), cascading, ctx, r.client, resp, state.PollingOptions); err != nil {
return
}
}

0 comments on commit 6362328

Please sign in to comment.