-
Notifications
You must be signed in to change notification settings - Fork 209
chore: Use use_effective_fields boolean attribute in resource #3910
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
base: CLOUDP-313272-dev-effective-fields
Are you sure you want to change the base?
Changes from all commits
cc2196c
f71cb5e
7a78f0c
0d77c8a
40a6b54
395b800
21f2563
e32b977
f08c8a9
06bcb1c
e3c65e7
1c39a35
6315ae4
d539cc3
62ca3de
70b05a3
c3df6f9
0fba06c
7f6e201
e50baa9
b2298b0
eed8808
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -88,7 +88,7 @@ jobs: | |||||
| cat doc.repo.patch | ||||||
| exit 1 | ||||||
| call-acceptance-tests-workflow: | ||||||
| needs: [build, lint, shellcheck, unit-test, generate-doc-check] | ||||||
| # needs: [build, lint, shellcheck, unit-test, generate-doc-check] # TEMPORARY: Don't merge, will be reverted in the last commit before merging | ||||||
|
||||||
| # needs: [build, lint, shellcheck, unit-test, generate-doc-check] # TEMPORARY: Don't merge, will be reverted in the last commit before merging | |
| needs: [build, lint, shellcheck, unit-test, generate-doc-check] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -176,7 +176,7 @@ data "mongodbatlas_advanced_cluster" "this" { | |
|
|
||
| * `project_id` - (Required) The unique ID for the project to create the cluster. | ||
| * `name` - (Required) Name of the cluster as it appears in Atlas. Once the cluster is created, its name cannot be changed. | ||
| * `use_effective_fields` - (Optional) Controls how hardware specification fields are returned in the response. When set to true, the non-effective specs (`electable_specs`, `read_only_specs`, `analytics_specs`) fields return the hardware specifications that the client provided. When set to false (default), the non-effective specs fields show the **current** hardware specifications. Cluster auto-scaling is the primary cause for differences between initial and current hardware specifications. **Note:** Effective specs (`effective_electable_specs`, `effective_read_only_specs`, `effective_analytics_specs`) are always returned regardless of the flag value and always report the **current** hardware specifications. See the resource documentation for [Auto-Scaling with Effective Fields](../resources/advanced_cluster.md#auto-scaling-with-effective-fields) for more details. | ||
| * `use_effective_fields` - (Optional) Controls how hardware specification fields are returned in the response. When set to true, the non-effective specs (`electable_specs`, `read_only_specs`, `analytics_specs`) fields return the hardware specifications that the client provided. When set to false (default), the non-effective specs fields show the **current** hardware specifications. Cluster auto-scaling is the primary cause for differences between initial and current hardware specifications. It does not apply to tenant or flex clusters. **Note:** Effective specs (`effective_electable_specs`, `effective_read_only_specs`, `effective_analytics_specs`) are always returned regardless of the flag value and always report the **current** hardware specifications. See the resource documentation for [Auto-Scaling with Effective Fields](../resources/advanced_cluster.md#auto-scaling-with-effective-fields) for more details. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. when we say "does not apply": are these fields not returned for M0/Flex? are they null? returned with pre-selected values? |
||
|
|
||
| ## Attributes Reference | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -204,7 +204,7 @@ data "mongodbatlas_advanced_clusters" "this" { | |
| ## Argument Reference | ||
|
|
||
| * `project_id` - (Required) The unique ID for the project to get the clusters. | ||
| * `use_effective_fields` - (Optional) Controls how hardware specification fields are returned in the response. When set to true, the non-effective specs (`electable_specs`, `read_only_specs`, `analytics_specs`) fields return the hardware specifications that the client provided. When set to false (default), the non-effective specs fields show the **current** hardware specifications. Cluster auto-scaling is the primary cause for differences between initial and current hardware specifications. **Note:** Effective specs (`effective_electable_specs`, `effective_read_only_specs`, `effective_analytics_specs`) are always returned regardless of the flag value and always report the **current** hardware specifications. See the resource documentation for [Auto-Scaling with Effective Fields](../resources/advanced_cluster.md#auto-scaling-with-effective-fields) for more details. | ||
| * `use_effective_fields` - (Optional) Controls how hardware specification fields are returned in the response. When set to true, the non-effective specs (`electable_specs`, `read_only_specs`, `analytics_specs`) fields return the hardware specifications that the client provided. When set to false (default), the non-effective specs fields show the **current** hardware specifications. Cluster auto-scaling is the primary cause for differences between initial and current hardware specifications. It does not apply to tenant or flex clusters. **Note:** Effective specs (`effective_electable_specs`, `effective_read_only_specs`, `effective_analytics_specs`) are always returned regardless of the flag value and always report the **current** hardware specifications. See the resource documentation for [Auto-Scaling with Effective Fields](../resources/advanced_cluster.md#auto-scaling-with-effective-fields) for more details. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above |
||
|
|
||
| ## Attributes Reference | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -575,7 +575,7 @@ Refer to the following for full privatelink endpoint connection string examples: | |
| * `redact_client_log_data` - (Optional) Flag that enables or disables log redaction, see the [manual](https://www.mongodb.com/docs/manual/administration/monitoring/#log-redaction) for more information. Use this in conjunction with Encryption at Rest and TLS/SSL (Transport Encryption) to assist compliance with regulatory requirements. **Note**: Changing this setting on a cluster will trigger a rolling restart as soon as the cluster is updated. | ||
| * `config_server_management_mode` - (Optional) Config Server Management Mode for creating or updating a sharded cluster. Valid values are `ATLAS_MANAGED` (default) and `FIXED_TO_DEDICATED`. When configured as `ATLAS_MANAGED`, Atlas may automatically switch the cluster's config server type for optimal performance and savings. When configured as `FIXED_TO_DEDICATED`, the cluster will always use a dedicated config server. To learn more, see the [Sharded Cluster Config Servers documentation](https://dochub.mongodb.org/docs/manual/core/sharded-cluster-config-servers/). | ||
| - `delete_on_create_timeout`- (Optional) Indicates whether to delete the resource being created if a timeout is reached when waiting for completion. When set to `true` and timeout occurs, it triggers the deletion and returns immediately without waiting for deletion to complete. When set to `false`, the timeout will not trigger resource deletion. If you suspect a transient error when the value is `true`, wait before retrying to allow resource deletion to finish. Default is `true`. | ||
| * `use_effective_fields` - (Optional) Controls how hardware specification fields are returned in the response. When set to true, the non-effective specs (`electable_specs`, `read_only_specs`, `analytics_specs`) fields return the hardware specifications that the client provided. When set to false (default), the non-effective specs fields show the **current** hardware specifications. Cluster auto-scaling is the primary cause for differences between initial and current hardware specifications. This opt-in feature enhances auto-scaling workflows by eliminating the need for `lifecycle.ignore_changes` blocks and preventing plan drift from Atlas-managed changes. This attribute will be deprecated in provider version 2.x and removed in 3.x when the new behavior becomes default. See [Auto-Scaling with Effective Fields](#auto-scaling-with-effective-fields) for more details. | ||
| * `use_effective_fields` - (Optional) Controls how hardware specification fields are returned in the response. When set to true, the non-effective specs (`electable_specs`, `read_only_specs`, `analytics_specs`) fields return the hardware specifications that the client provided. When set to false (default), the non-effective specs fields show the **current** hardware specifications. Cluster auto-scaling is the primary cause for differences between initial and current hardware specifications. This opt-in feature enhances auto-scaling workflows by eliminating the need for `lifecycle.ignore_changes` blocks and preventing plan drift from Atlas-managed changes. It does not apply to tenant or flex clusters. This attribute will be deprecated in provider version 2.x and removed in 3.x when the new behavior becomes default. See [Auto-Scaling with Effective Fields](#auto-scaling-with-effective-fields) for more details. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above |
||
|
|
||
| ### bi_connector_config | ||
|
|
||
|
|
@@ -779,7 +779,7 @@ replication_specs = [ | |
|
|
||
| When auto-scaling is enabled, there are two approaches to manage your cluster configuration with Terraform: | ||
|
|
||
| **Option 1 (Recommended):** Use `use_effective_fields = true` to enable the new effective fields behavior. With this option, Atlas-managed auto-scaling changes won't cause plan drift, eliminating the need for `lifecycle` ignore customizations. You can read scaled values using the `effective_electable_specs`, `effective_analytics_specs`, and `effective_read_only_specs` attributes in the `mongodbatlas_advanced_cluster` data source. See [Auto-Scaling with Effective Fields](#auto-scaling-with-effective-fields) for details. | ||
| **Option 1 (Recommended):** Use `use_effective_fields = true` to enable the new effective fields behavior. With this option, Atlas-managed auto-scaling changes won't cause plan drift, eliminating the need for `lifecycle` ignore customizations. Auto-scaling features independently ignore specific Terraform-configured fields: compute auto-scaling ignores only `instance_size`, disk auto-scaling ignores only `disk_size_gb` and `disk_iops`, while both together ignore all three fields. You can read the actual scaled values using the `effective_electable_specs` and `effective_read_only_specs` attributes in the `mongodbatlas_advanced_cluster` data source. See [Auto-Scaling with Effective Fields](#auto-scaling-with-effective-fields) for details. | ||
|
|
||
| **Option 2:** If not using `use_effective_fields`, use a lifecycle ignore customization to prevent unintended changes. To explicitly change `disk_size_gb` or `instance_size` values, comment out the `lifecycle` block and run `terraform apply`. Please be sure to uncomment the `lifecycle` block once done to prevent any accidental changes. | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,42 +16,6 @@ import ( | |
| "github.com/mongodb/terraform-provider-mongodbatlas/internal/service/flexcluster" | ||
| ) | ||
|
|
||
| func CreateCluster(ctx context.Context, diags *diag.Diagnostics, client *config.MongoDBClient, req *admin.ClusterDescription20240805, waitParams *ClusterWaitParams) *admin.ClusterDescription20240805 { | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. moved to resource.go as it's only used there now |
||
| var ( | ||
| pauseAfter = req.GetPaused() | ||
| clusterResp *admin.ClusterDescription20240805 | ||
| ) | ||
| if pauseAfter { | ||
| req.Paused = nil | ||
| } | ||
| clusterResp = createClusterLatest(ctx, diags, client, req, waitParams) | ||
| if diags.HasError() { | ||
| return nil | ||
| } | ||
| if pauseAfter { | ||
| clusterResp = updateCluster(ctx, diags, client, &pauseRequest, waitParams, operationPauseAfterCreate) | ||
| } | ||
| return clusterResp | ||
| } | ||
|
|
||
| func createClusterLatest(ctx context.Context, diags *diag.Diagnostics, client *config.MongoDBClient, req *admin.ClusterDescription20240805, waitParams *ClusterWaitParams) *admin.ClusterDescription20240805 { | ||
| _, _, err := client.AtlasV2.ClustersApi.CreateCluster(ctx, waitParams.ProjectID, req).Execute() | ||
| if err != nil { | ||
| addErrorDiag(diags, operationCreate, defaultAPIErrorDetails(waitParams.ClusterName, err)) | ||
| return nil | ||
| } | ||
| return AwaitChanges(ctx, client, waitParams, operationCreate, diags) | ||
| } | ||
|
|
||
| func updateCluster(ctx context.Context, diags *diag.Diagnostics, client *config.MongoDBClient, req *admin.ClusterDescription20240805, waitParams *ClusterWaitParams, operationName string) *admin.ClusterDescription20240805 { | ||
| _, _, err := client.AtlasV2.ClustersApi.UpdateCluster(ctx, waitParams.ProjectID, waitParams.ClusterName, req).Execute() | ||
| if err != nil { | ||
| addErrorDiag(diags, operationName, defaultAPIErrorDetails(waitParams.ClusterName, err)) | ||
| return nil | ||
| } | ||
| return AwaitChanges(ctx, client, waitParams, operationName, diags) | ||
| } | ||
|
|
||
| // ProcessArgs.ClusterAdvancedConfig is managed through create/updateCluster APIs instead of /processArgs APIs but since corresponding TF attributes | ||
| // belong in the advanced_configuration attribute we still need to check for any changes | ||
| func UpdateAdvancedConfiguration(ctx context.Context, diags *diag.Diagnostics, client *config.MongoDBClient, p *ProcessArgs, waitParams *ClusterWaitParams) (latest *admin.ClusterDescriptionProcessArgs20240805, changed bool) { | ||
|
|
@@ -141,7 +105,7 @@ func DeleteCluster(ctx context.Context, diags *diag.Diagnostics, client *config. | |
| return | ||
| } | ||
| } | ||
| AwaitChanges(ctx, client, waitParams, operationDelete, diags) | ||
| _ = AwaitChanges(ctx, client, waitParams, operationDelete, diags) | ||
| } | ||
|
|
||
| func DeleteClusterNoWait(client *config.MongoDBClient, projectID, clusterName string, isFlex bool) func(ctx context.Context) error { | ||
|
|
@@ -160,9 +124,9 @@ func DeleteClusterNoWait(client *config.MongoDBClient, projectID, clusterName st | |
| } | ||
| } | ||
|
|
||
| func GetClusterDetails(ctx context.Context, diags *diag.Diagnostics, projectID, clusterName string, client *config.MongoDBClient, fcvPresentInState bool) (clusterDesc *admin.ClusterDescription20240805, flexClusterResp *admin.FlexClusterDescription20241113) { | ||
| func GetClusterDetails(ctx context.Context, diags *diag.Diagnostics, projectID, clusterName string, client *config.MongoDBClient, fcvPresentInState, useEffectiveFields bool) (clusterDesc *admin.ClusterDescription20240805, flexClusterResp *admin.FlexClusterDescription20241113) { | ||
| isFlex := false | ||
| clusterDesc, resp, err := client.AtlasV2.ClustersApi.GetCluster(ctx, projectID, clusterName).Execute() | ||
| clusterDesc, resp, err := client.AtlasV2.ClustersApi.GetCluster(ctx, projectID, clusterName).UseEffectiveInstanceFields(useEffectiveFields).Execute() | ||
| if err != nil { | ||
| if validate.StatusNotFound(resp) || admin.IsErrorCode(err, ErrorCodeClusterNotFound) { | ||
| return nil, 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.
Temporary test filter creates a risk if merged. The hardcoded regex replaces conditional logic and would cause only effective fields tests to run in all scenarios.