@@ -10,11 +10,14 @@ import (
1010 "go.mongodb.org/atlas-sdk/v20250219001/admin"
1111
1212 "github.com/hashicorp/terraform-plugin-framework/diag"
13+ "github.com/hashicorp/terraform-plugin-log/tflog"
1314 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
1415
16+ "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/constant"
1517 "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/retrystrategy"
1618 "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/validate"
1719 "github.com/mongodb/terraform-provider-mongodbatlas/internal/config"
20+ "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/flexcluster"
1821)
1922
2023var (
@@ -30,6 +33,19 @@ type ClusterWaitParams struct {
3033 IsDelete bool
3134}
3235
36+ func AwaitChangesUpgrade (ctx context.Context , client * config.MongoDBClient , waitParams * ClusterWaitParams , errorLocator string , diags * diag.Diagnostics ) * admin.ClusterDescription20240805 {
37+ upgraded := AwaitChanges (ctx , client , waitParams , errorLocator , diags )
38+ if diags .HasError () || upgraded == nil {
39+ return nil
40+ }
41+ providerName := getProviderName (upgraded .ReplicationSpecs )
42+ if slices .Contains ([]string {flexcluster .FlexClusterType , constant .TENANT }, providerName ) {
43+ tflog .Warn (ctx , fmt .Sprintf ("cluster upgrade unexpected provider %s, retrying" , providerName ))
44+ return AwaitChanges (ctx , client , waitParams , errorLocator , diags )
45+ }
46+ return upgraded
47+ }
48+
3349func AwaitChanges (ctx context.Context , client * config.MongoDBClient , waitParams * ClusterWaitParams , errorLocator string , diags * diag.Diagnostics ) * admin.ClusterDescription20240805 {
3450 api := client .AtlasV2 .ClustersApi
3551 targetState := retrystrategy .RetryStrategyIdleState
0 commit comments