@@ -10,11 +10,14 @@ import (
10
10
"go.mongodb.org/atlas-sdk/v20250219001/admin"
11
11
12
12
"github.com/hashicorp/terraform-plugin-framework/diag"
13
+ "github.com/hashicorp/terraform-plugin-log/tflog"
13
14
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry"
14
15
16
+ "github.com/mongodb/terraform-provider-mongodbatlas/internal/common/constant"
15
17
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/retrystrategy"
16
18
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/validate"
17
19
"github.com/mongodb/terraform-provider-mongodbatlas/internal/config"
20
+ "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/flexcluster"
18
21
)
19
22
20
23
var (
@@ -30,6 +33,19 @@ type ClusterWaitParams struct {
30
33
IsDelete bool
31
34
}
32
35
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
+
33
49
func AwaitChanges (ctx context.Context , client * config.MongoDBClient , waitParams * ClusterWaitParams , errorLocator string , diags * diag.Diagnostics ) * admin.ClusterDescription20240805 {
34
50
api := client .AtlasV2 .ClustersApi
35
51
targetState := retrystrategy .RetryStrategyIdleState
0 commit comments