-
Notifications
You must be signed in to change notification settings - Fork 190
chore: Updates mongodbatlas_advanced_cluster
(SDKv2 & TPF) to consume selected processArgs fields from the createCluster/updateCluster APIs
#3231
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
Conversation
mongodbatlas_advanced_cluster
(SDKv2) to consume selected processArgs fields from the createCluster/updateCluster
mongodbatlas_advanced_cluster
(SDKv2) to consume selected processArgs fields from the createCluster/updateClustermongodbatlas_advanced_cluster
(SDKv2) to consume selected processArgs fields from the createCluster/updateCluster APIs
mongodbatlas_advanced_cluster
(SDKv2) to consume selected processArgs fields from the createCluster/updateCluster APIsmongodbatlas_advanced_cluster
(SDKv2 & TPF) to consume selected processArgs fields from the createCluster/updateCluster APIs
@@ -348,7 +348,7 @@ func dataSourceRead(ctx context.Context, d *schema.ResourceData, meta any) diag. | |||
return diag.FromErr(fmt.Errorf(ErrorAdvancedConfRead, "", clusterName, err)) | |||
} | |||
|
|||
if err := d.Set("advanced_configuration", flattenProcessArgs(processArgs20240530, processArgs)); err != nil { | |||
if err := d.Set("advanced_configuration", flattenProcessArgs(processArgs20240530, processArgs, clusterDesc.AdvancedConfiguration)); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
although not an absolute requirement for Read, but still fetching these from cluster response (instead of /processArgs) for consistency.
@@ -939,7 +945,7 @@ func resourceUpdate(ctx context.Context, d *schema.ResourceData, meta any) diag. | |||
} | |||
waitOnUpdate = true | |||
} | |||
if d.HasChange("replica_set_scaling_strategy") || d.HasChange("redact_client_log_data") || d.HasChange("config_server_management_mode") { | |||
if d.HasChange("replica_set_scaling_strategy") || d.HasChange("redact_client_log_data") || d.HasChange("config_server_management_mode") || d.HasChange("advanced_configuration") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AgustinBettati can you confirm if this should be okay or we should update this in the above call (connV220240530.ClustersApi.UpdateCluster #L943)? In that case, will need the SDK for that to be updated as well to support the new AdvancedConfiguration attribute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see a concern here, as we are still respecting what the comment below mentions when calling the latest API version.
can call latest API (2024-10-23 or newer) as replications specs (with nested autoscaling property) is not specified
In this case I understand we only add the advancedConfiguration property but no replicationSpecs, meaning no risk.
if diags.HasError() { | ||
return | ||
} | ||
AddAdvancedConfig(ctx, modelOut, advConfig, legacyAdvConfig, diags) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updateModelAdvancedConfig already calls AddAdvancedConfig(), so this is not required
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)), | ||
DefaultMaxTimeMS: types.Int64PointerValue(conversion.IntPtrToInt64Ptr(input.DefaultMaxTimeMS)), | ||
TlsCipherConfigMode: types.StringValue(conversion.SafeValue(input.TlsCipherConfigMode)), | ||
MinimumEnabledTlsProtocol: types.StringValue(conversion.SafeValue(clusterAdvConfig.MinimumEnabledTlsProtocol)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: you moved this from line 42 intentionally?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
didn't remove anything, just moved MinimumEnabledTlsProtocol here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup, I said moved :) just wanted to check if you moved it intentionally and if there was a reason
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol I misread, yes moved intentionally just to keep these together for readability since they are both fetched from clusterAdvConfig
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from a first look, change LGTM - are you running all cluster tests? I remember we disabled some from regular PR execution.
Yes I'm running them separately for this branch, will add links soon |
p := aclist[0].(map[string]any) | ||
|
||
if _, ok := d.GetOkExists("advanced_configuration.0.minimum_enabled_tls_protocol"); ok { | ||
res.MinimumEnabledTlsProtocol = conversion.StringPtr(cast.ToString(p["minimum_enabled_tls_protocol"])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: cast p["minimum_enabled_tls_protocol"].(string)
instead of using the current way
@@ -1148,6 +1150,11 @@ func updateRequest(ctx context.Context, d *schema.ResourceData, projectID, clust | |||
if d.HasChange("config_server_management_mode") { | |||
cluster.ConfigServerManagementMode = conversion.StringPtr(d.Get("config_server_management_mode").(string)) | |||
} | |||
if d.HasChange("advanced_configuration") { | |||
if aclist, ok := d.Get("advanced_configuration").([]any); ok && len(aclist) > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This means that removing advanced_configuration from the config will never update?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's the behavior today as well right? since it's O/C, or did you mean something else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes LGMT overall :)
All acceptance test runs succeed: |
@@ -100,6 +100,11 @@ func UpdateAdvancedConfiguration(ctx context.Context, diags *diag.Diagnostics, c | |||
return nil, nil, false | |||
} | |||
} | |||
// clusterAdvConfig is managed through create/updateCluster APIs instead of processArgs APIs but since corresponding TF attributes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it can be confusing that UpdateAdvancedConfiguration doesn't update clusterAdvConfig, can we move this comment to be in the func description? although not ideal but I think it's clearer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also func is having many params, consider using a request struct
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved comment & updated to use struct, ty!
if clusterAdvConfig != nil { | ||
flattenedProcessArgs[0]["tls_cipher_config_mode"] = clusterAdvConfig.GetTlsCipherConfigMode() | ||
flattenedProcessArgs[0]["custom_openssl_cipher_config_tls12"] = clusterAdvConfig.GetCustomOpensslCipherConfigTls12() | ||
flattenedProcessArgs[0]["minimum_enabled_tls_protocol"] = clusterAdvConfig.GetMinimumEnabledTlsProtocol() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can it happen that minimum_enabled_tls_protocol exists in p20240530 but not in clusterAdvConfig? in case it makes sense to keep reading it from p20240530, and override if present at clusterAdvConfig
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
var advancedConfig TFAdvancedConfigurationModel | ||
if input != nil && inputLegacy != nil { | ||
if input != nil && inputLegacy != nil && clusterAdvConfig != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can it happen that clusterAdvConfig is nil and we want at least to see the other params that don't depend on it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, recently discovered for TENANT cluster type this may be the case, updated.
@@ -33,7 +33,7 @@ require ( | |||
github.com/zclconf/go-cty v1.16.2 | |||
go.mongodb.org/atlas v0.37.0 | |||
go.mongodb.org/atlas-sdk/v20240530005 v20240530005.0.0 | |||
go.mongodb.org/atlas-sdk/v20240805005 v20240805005.0.0 | |||
go.mongodb.org/atlas-sdk/v20240805005 v20240805005.0.1-0.20250402112219-2468c5354718 // uses api-bot-update-v20240805-backport-cluster to support AdvancedConfiguration in create/updateCluster APIs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there are no tests changes, can we add or modify tests to check these new attributes are set correctly? for instance in some tests first steps to check in the data source the attribute values
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
existing tests do check all these values to be set as expected
terraform-provider-mongodbatlas/internal/service/advancedcluster/resource_advanced_cluster_test.go
Line 2140 in 1335955
func checkAdvanced(usePreviewProvider bool, name, tls string, processArgs *admin.ClusterDescriptionProcessArgs20240805) resource.TestCheckFunc { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
if !update.IsZeroValues(clusterAdvConfig) { | ||
changed = true | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
q: If clusterAdvConfig made some changes, is there a need to flag the changed
here? If changes are made only in clusterAdvConfig I would expect once cluster is IDLE there is not need to detect changes here as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed is required to be flagged here so that the advanced_configuration in the TF model is updated (which is required to be done if any of the params change)
Will re-run complete acc test group advanced_cluster & TPF in sometime before merge as dev is unstable right now when creating new projects |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM , thanks for the follow-ups
@@ -20,6 +23,12 @@ var ( | |||
ErrLegacyIgnoreLabel = fmt.Errorf("label `%s` is not supported as it is reserved for internal purposes", LegacyIgnoredLabelKey) | |||
) | |||
|
|||
type ProcessArgs struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice refactoring
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job!
… fields from the createCluster/updateCluster APIs (#3250)
only 1 cluster test failing due to OUT_OF_CAPACITY, merging |
Description
This PR updates Atlas SDK v20240805 generated from
api-bot-update-v20240805-backport-cluster
branch (mongodb/atlas-sdk-go#576)Link to any related issue(s): CLOUDP-296222
Type of change:
Required Checklist:
Further comments