Skip to content

Commit 064955c

Browse files
authored
chore: Refactors fail_index_key_too_long to be compatible with old implementation and use zero values in advanced_configuration (#2893)
* chore: Refactor fail_index_key_too_long to be compatible with old implementation and use zero values in advanced_configuration * chore: fix formatting * fix: nil pointer error * chore: Update failIndexKeyTooLong retrieval to use getter method
1 parent 47633ce commit 064955c

File tree

2 files changed

+26
-17
lines changed

2 files changed

+26
-17
lines changed

internal/service/advancedclustertpf/model_ClusterDescriptionProcessArgs20240805.go

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,31 @@ func AddAdvancedConfig(ctx context.Context, tfModel *TFModel, input *admin.Clust
1919
// special behavior using -1 when it is unset by the user
2020
changeStreamOptionsPreAndPostImagesExpireAfterSeconds = conversion.Pointer(-1)
2121
}
22+
// When MongoDBMajorVersion is not 4.4 or lower, the API response for fail_index_key_too_long will always be null, to ensure no consistency issues, we need to match the config
23+
failIndexKeyTooLong := inputLegacy.GetFailIndexKeyTooLong()
24+
if tfModel != nil {
25+
stateConfig := tfModel.AdvancedConfiguration
26+
stateConfigSDK := NewAtlasReqAdvancedConfigurationLegacy(ctx, &stateConfig, diags)
27+
if diags.HasError() {
28+
return
29+
}
30+
if stateConfigSDK != nil && stateConfigSDK.GetFailIndexKeyTooLong() != failIndexKeyTooLong {
31+
failIndexKeyTooLong = stateConfigSDK.GetFailIndexKeyTooLong()
32+
}
33+
}
2234
advancedConfig = TFAdvancedConfigurationModel{
2335
ChangeStreamOptionsPreAndPostImagesExpireAfterSeconds: types.Int64PointerValue(conversion.IntPtrToInt64Ptr(changeStreamOptionsPreAndPostImagesExpireAfterSeconds)),
24-
DefaultWriteConcern: types.StringPointerValue(input.DefaultWriteConcern),
25-
DefaultReadConcern: types.StringPointerValue(inputLegacy.DefaultReadConcern),
26-
FailIndexKeyTooLong: types.BoolPointerValue(inputLegacy.FailIndexKeyTooLong),
27-
JavascriptEnabled: types.BoolPointerValue(input.JavascriptEnabled),
28-
MinimumEnabledTlsProtocol: types.StringPointerValue(input.MinimumEnabledTlsProtocol),
29-
NoTableScan: types.BoolPointerValue(input.NoTableScan),
30-
OplogMinRetentionHours: types.Float64PointerValue(input.OplogMinRetentionHours),
31-
OplogSizeMb: types.Int64PointerValue(conversion.IntPtrToInt64Ptr(input.OplogSizeMB)),
32-
SampleSizeBiconnector: types.Int64PointerValue(conversion.IntPtrToInt64Ptr(input.SampleSizeBIConnector)),
33-
SampleRefreshIntervalBiconnector: types.Int64PointerValue(conversion.IntPtrToInt64Ptr(input.SampleRefreshIntervalBIConnector)),
34-
TransactionLifetimeLimitSeconds: types.Int64PointerValue(input.TransactionLifetimeLimitSeconds),
36+
DefaultWriteConcern: types.StringValue(conversion.SafeValue(input.DefaultWriteConcern)),
37+
DefaultReadConcern: types.StringValue(conversion.SafeValue(inputLegacy.DefaultReadConcern)),
38+
FailIndexKeyTooLong: types.BoolValue(failIndexKeyTooLong),
39+
JavascriptEnabled: types.BoolValue(conversion.SafeValue(input.JavascriptEnabled)),
40+
MinimumEnabledTlsProtocol: types.StringValue(conversion.SafeValue(input.MinimumEnabledTlsProtocol)),
41+
NoTableScan: types.BoolValue(conversion.SafeValue(input.NoTableScan)),
42+
OplogMinRetentionHours: types.Float64Value(conversion.SafeValue(input.OplogMinRetentionHours)),
43+
OplogSizeMb: types.Int64Value(conversion.SafeValue(conversion.IntPtrToInt64Ptr(input.OplogSizeMB))),
44+
SampleSizeBiconnector: types.Int64Value(conversion.SafeValue(conversion.IntPtrToInt64Ptr(input.SampleSizeBIConnector))),
45+
SampleRefreshIntervalBiconnector: types.Int64Value(conversion.SafeValue(conversion.IntPtrToInt64Ptr(input.SampleRefreshIntervalBIConnector))),
46+
TransactionLifetimeLimitSeconds: types.Int64Value(conversion.SafeValue(input.TransactionLifetimeLimitSeconds)),
3547
}
3648
}
3749
objType, diagsLocal := types.ObjectValueFrom(ctx, AdvancedConfigurationObjType.AttrTypes, advancedConfig)

internal/service/advancedclustertpf/schema.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -527,12 +527,9 @@ func AdvancedConfigurationSchema(ctx context.Context) schema.SingleNestedAttribu
527527
MarkdownDescription: "default_read_concern", // TODO: add description
528528
},
529529
"fail_index_key_too_long": schema.BoolAttribute{
530-
DeprecationMessage: DeprecationMsgOldSchema,
531-
Computed: true,
532-
Optional: true,
533-
PlanModifiers: []planmodifier.Bool{
534-
PlanMustUseMongoDBVersion(4.4, EqualOrLower),
535-
},
530+
DeprecationMessage: DeprecationMsgOldSchema,
531+
Computed: true,
532+
Optional: true,
536533
MarkdownDescription: "fail_index_key_too_long", // TODO: add description
537534
},
538535
},

0 commit comments

Comments
 (0)