Skip to content

Commit 06140c9

Browse files
authored
ForceLegacySchemaFailed (#2908)
1 parent 9cdf77c commit 06140c9

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

internal/service/advancedclustertpf/data_source.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func (d *ds) readCluster(ctx context.Context, diags *diag.Diagnostics, modelDS *
6464
if diags.HasError() {
6565
return nil
6666
}
67-
if extraInfo.AsymmetricShardUnsupported && !useReplicationSpecPerShard {
67+
if extraInfo.ForceLegacySchemaFailed {
6868
diags.AddError("errorRead", "Please add `use_replication_spec_per_shard = true` to your data source configuration to enable asymmetric shard support. Refer to documentation for more details.")
6969
return nil
7070
}

internal/service/advancedclustertpf/model_ClusterDescription20240805.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ type ExtraAPIInfo struct {
2525
RootDiskSize *float64
2626
ContainerIDs map[string]string
2727
UsingLegacySchema bool
28-
AsymmetricShardUnsupported bool
28+
ForceLegacySchemaFailed bool
2929
}
3030

3131
func NewTFModel(ctx context.Context, input *admin.ClusterDescription20240805, timeout timeouts.Value, diags *diag.Diagnostics, apiInfo ExtraAPIInfo) *TFModel {

internal/service/advancedclustertpf/plural_data_source.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func (d *pluralDS) readClusters(ctx context.Context, diags *diag.Diagnostics, pl
7777
if diags.HasError() {
7878
return nil
7979
}
80-
if extraInfo.AsymmetricShardUnsupported && !useReplicationSpecPerShard {
80+
if extraInfo.ForceLegacySchemaFailed {
8181
continue
8282
}
8383
updateModelAdvancedConfig(ctx, diags, d.Client, modelOut, nil, nil)

internal/service/advancedclustertpf/resource.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -453,19 +453,19 @@ func (r *rs) applyTenantUpgrade(ctx context.Context, plan *TFModel, upgradeReque
453453
}
454454

455455
func getBasicClusterModel(ctx context.Context, diags *diag.Diagnostics, client *config.MongoDBClient, clusterResp *admin.ClusterDescription20240805, modelIn *TFModel, forceLegacySchema bool) (*TFModel, *ExtraAPIInfo) {
456-
apiInfo := resolveAPIInfo(ctx, diags, client, modelIn, clusterResp, forceLegacySchema)
456+
extraInfo := resolveAPIInfo(ctx, diags, client, modelIn, clusterResp, forceLegacySchema)
457457
if diags.HasError() {
458458
return nil, nil
459459
}
460-
if forceLegacySchema && apiInfo.AsymmetricShardUnsupported { // can't create a model if legacy is forced but cluster does not support it
461-
return nil, apiInfo
460+
if extraInfo.ForceLegacySchemaFailed { // can't create a model if legacy is forced but cluster does not support it
461+
return nil, extraInfo
462462
}
463-
modelOut := NewTFModel(ctx, clusterResp, modelIn.Timeouts, diags, *apiInfo)
463+
modelOut := NewTFModel(ctx, clusterResp, modelIn.Timeouts, diags, *extraInfo)
464464
if diags.HasError() {
465465
return nil, nil
466466
}
467467
overrideAttributesWithPrevStateValue(modelIn, modelOut)
468-
return modelOut, apiInfo
468+
return modelOut, extraInfo
469469
}
470470

471471
func updateModelAdvancedConfig(ctx context.Context, diags *diag.Diagnostics, client *config.MongoDBClient, model *TFModel, legacyAdvConfig *admin20240530.ClusterDescriptionProcessArgs, advConfig *admin.ClusterDescriptionProcessArgs20240805) {

internal/service/advancedclustertpf/resource_compatiblity.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,16 @@ func findNumShardsUpdates(ctx context.Context, state, plan *TFModel, diags *diag
4141

4242
func resolveAPIInfo(ctx context.Context, diags *diag.Diagnostics, client *config.MongoDBClient, plan *TFModel, clusterLatest *admin.ClusterDescription20240805, forceLegacySchema bool) *ExtraAPIInfo {
4343
var (
44-
api20240530 = client.AtlasV220240530.ClustersApi
45-
rootDiskSize = conversion.NilForUnknown(plan.DiskSizeGB, plan.DiskSizeGB.ValueFloat64Pointer())
46-
projectID = plan.ProjectID.ValueString()
47-
clusterName = plan.Name.ValueString()
48-
asymmetricShardUnsupported = false
44+
api20240530 = client.AtlasV220240530.ClustersApi
45+
rootDiskSize = conversion.NilForUnknown(plan.DiskSizeGB, plan.DiskSizeGB.ValueFloat64Pointer())
46+
projectID = plan.ProjectID.ValueString()
47+
clusterName = plan.Name.ValueString()
48+
forceLegacySchemaFailed = false
4949
)
5050
clusterRespOld, _, err := api20240530.GetCluster(ctx, projectID, clusterName).Execute()
5151
if err != nil {
5252
if admin20240530.IsErrorCode(err, "ASYMMETRIC_SHARD_UNSUPPORTED") {
53-
asymmetricShardUnsupported = true
53+
forceLegacySchemaFailed = forceLegacySchema
5454
} else {
5555
diags.AddError("errorRead", fmt.Sprintf("error reading advanced cluster with 2024-05-30 API (%s): %s", clusterName, err))
5656
return nil
@@ -68,7 +68,7 @@ func resolveAPIInfo(ctx context.Context, diags *diag.Diagnostics, client *config
6868
ContainerIDs: containerIDs,
6969
RootDiskSize: rootDiskSize,
7070
ZoneNameReplicationSpecIDs: replicationSpecIDsFromOldAPI(clusterRespOld),
71-
AsymmetricShardUnsupported: asymmetricShardUnsupported,
71+
ForceLegacySchemaFailed: forceLegacySchemaFailed,
7272
}
7373
if forceLegacySchema {
7474
info.UsingLegacySchema = true

0 commit comments

Comments
 (0)