Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Refactors fail_index_key_too_long to be compatible with old implementation and use zero values in advanced_configuration #2893

Merged
merged 5 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,31 @@ func AddAdvancedConfig(ctx context.Context, tfModel *TFModel, input *admin.Clust
// special behavior using -1 when it is unset by the user
changeStreamOptionsPreAndPostImagesExpireAfterSeconds = conversion.Pointer(-1)
}
// 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
failIndexKeyTooLong := inputLegacy.FailIndexKeyTooLong
if tfModel != nil {
stateConfig := tfModel.AdvancedConfiguration
stateConfigSDK := NewAtlasReqAdvancedConfigurationLegacy(ctx, &stateConfig, diags)
if diags.HasError() {
return
}
if conversion.SafeValue(stateConfigSDK.FailIndexKeyTooLong) != conversion.SafeValue(failIndexKeyTooLong) {
failIndexKeyTooLong = stateConfigSDK.FailIndexKeyTooLong
}
}
advancedConfig = TFAdvancedConfigurationModel{
ChangeStreamOptionsPreAndPostImagesExpireAfterSeconds: types.Int64PointerValue(conversion.IntPtrToInt64Ptr(changeStreamOptionsPreAndPostImagesExpireAfterSeconds)),
DefaultWriteConcern: types.StringPointerValue(input.DefaultWriteConcern),
DefaultReadConcern: types.StringPointerValue(inputLegacy.DefaultReadConcern),
FailIndexKeyTooLong: types.BoolPointerValue(inputLegacy.FailIndexKeyTooLong),
JavascriptEnabled: types.BoolPointerValue(input.JavascriptEnabled),
MinimumEnabledTlsProtocol: types.StringPointerValue(input.MinimumEnabledTlsProtocol),
NoTableScan: types.BoolPointerValue(input.NoTableScan),
OplogMinRetentionHours: types.Float64PointerValue(input.OplogMinRetentionHours),
OplogSizeMb: types.Int64PointerValue(conversion.IntPtrToInt64Ptr(input.OplogSizeMB)),
SampleSizeBiconnector: types.Int64PointerValue(conversion.IntPtrToInt64Ptr(input.SampleSizeBIConnector)),
SampleRefreshIntervalBiconnector: types.Int64PointerValue(conversion.IntPtrToInt64Ptr(input.SampleRefreshIntervalBIConnector)),
TransactionLifetimeLimitSeconds: types.Int64PointerValue(input.TransactionLifetimeLimitSeconds),
DefaultWriteConcern: types.StringValue(conversion.SafeValue(input.DefaultWriteConcern)),
DefaultReadConcern: types.StringValue(conversion.SafeValue(inputLegacy.DefaultReadConcern)),
FailIndexKeyTooLong: types.BoolValue(conversion.SafeValue(failIndexKeyTooLong)),
JavascriptEnabled: types.BoolValue(conversion.SafeValue(input.JavascriptEnabled)),
MinimumEnabledTlsProtocol: types.StringValue(conversion.SafeValue(input.MinimumEnabledTlsProtocol)),
NoTableScan: types.BoolValue(conversion.SafeValue(input.NoTableScan)),
OplogMinRetentionHours: types.Float64Value(conversion.SafeValue(input.OplogMinRetentionHours)),
OplogSizeMb: types.Int64Value(conversion.SafeValue(conversion.IntPtrToInt64Ptr(input.OplogSizeMB))),
SampleSizeBiconnector: types.Int64Value(conversion.SafeValue(conversion.IntPtrToInt64Ptr(input.SampleSizeBIConnector))),
SampleRefreshIntervalBiconnector: types.Int64Value(conversion.SafeValue(conversion.IntPtrToInt64Ptr(input.SampleRefreshIntervalBIConnector))),
TransactionLifetimeLimitSeconds: types.Int64Value(conversion.SafeValue(input.TransactionLifetimeLimitSeconds)),
}
}
objType, diagsLocal := types.ObjectValueFrom(ctx, AdvancedConfigurationObjType.AttrTypes, advancedConfig)
Expand Down
9 changes: 3 additions & 6 deletions internal/service/advancedclustertpf/resource_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -491,12 +491,9 @@ func AdvancedConfigurationSchema(ctx context.Context) schema.SingleNestedAttribu
MarkdownDescription: "default_read_concern", // TODO: add description
},
"fail_index_key_too_long": schema.BoolAttribute{
DeprecationMessage: DeprecationMsgOldSchema,
Computed: true,
Optional: true,
PlanModifiers: []planmodifier.Bool{
PlanMustUseMongoDBVersion(4.4, EqualOrLower),
},
DeprecationMessage: DeprecationMsgOldSchema,
Computed: true,
Optional: true,
MarkdownDescription: "fail_index_key_too_long", // TODO: add description
},
},
Expand Down
Loading