-
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?
chore: Use use_effective_fields boolean attribute in resource #3910
Conversation
…flag_resource * CLOUDP-313272-dev-effective-fields: chore: Updates Atlas Go SDK (#3907) doc: Updates Terraform Compatibility Matrix documentation (#3905) chore: Adds panic for deprecated SDKv2 resource operations (#3900)
…flag_resource * CLOUDP-313272-dev-effective-fields: chore: Support resource deprecation in autogen (#3909) chore: Support configuration for update marshalling to send null for list/set types (#3908)
| "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 { |
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 to resource.go as it's only used there now
3d5ebd7 to
1bc1411
Compare
1bc1411 to
e50baa9
Compare
|
APIx bot: a message has been sent to Docs Slack channel |
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.
Pull request overview
This PR adds support for the use_effective_fields boolean attribute in the advanced cluster resource, which controls how hardware specification fields are returned from the API. When enabled, this feature helps eliminate plan drift during cluster auto-scaling operations by returning client-provided specifications rather than current scaled values.
Key changes:
- Added
use_effective_fieldsvalidation to prevent usage with Flex or Tenant clusters - Propagated the
use_effective_fieldsparameter through API calls for create, read, update, and list operations - Renamed internal functions to use lowercase naming convention
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
internal/service/advancedcluster/validate_schema.go |
Added validator to restrict use_effective_fields to dedicated clusters only |
internal/service/advancedcluster/schema.go |
Added validator to the use_effective_fields attribute |
internal/service/advancedcluster/resource.go |
Updated to pass use_effective_fields to API calls and renamed helper functions |
internal/service/advancedcluster/common_admin_sdk.go |
Moved cluster create/update functions and added use_effective_fields to API calls |
internal/service/advancedcluster/common_await_changes.go |
Added UseEffectiveFields to ClusterWaitParams and propagated through wait logic |
internal/service/advancedcluster/common.go |
Added isTenant helper function and renamed IsFlex to isFlex |
internal/service/advancedcluster/model_to_ClusterDescription20240805.go |
Renamed conversion functions to remove 20240805 suffix |
internal/service/advancedcluster/data_source.go |
Updated to pass use_effective_fields to read operations |
internal/service/advancedcluster/plural_data_source.go |
Added use_effective_fields parameter to list clusters API call |
internal/service/advancedcluster/effective_fields_test.go |
Added basic tests for use_effective_fields functionality |
internal/service/advancedcluster/resource_test.go |
Updated test helper function signature |
docs/resources/advanced_cluster.md |
Updated documentation to clarify Flex/Tenant restriction and auto-scaling behavior |
docs/data-sources/advanced_cluster.md |
Updated documentation to mention Flex/Tenant restriction |
docs/data-sources/advanced_clusters.md |
Updated documentation to mention Flex/Tenant restriction |
.github/workflows/code-health.yml |
Temporarily disabled job dependencies for testing |
.github/workflows/acceptance-tests-runner.yml |
Temporarily filtered tests to only run effective fields tests |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| 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 |
Copilot
AI
Nov 25, 2025
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.
Commented-out job dependency creates a risk if this temporary change is merged. Consider using a feature flag or environment variable check instead of commenting out the dependency.
| # 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 | ||
| ACCTEST_REGEX_RUN: '^TestAccAdvancedCluster_effective' |
Copilot
AI
Nov 25, 2025
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.
| # TEMPORARY: Don't merge, will be reverted in the last commit before merging | |
| ACCTEST_REGEX_RUN: '^TestAccAdvancedCluster_effective' | |
| # Run all advanced cluster acceptance tests | |
| ACCTEST_REGEX_RUN: '' |
| t.Fatalf("cluster %s not found in %s", clusterName, projectID) | ||
| } | ||
| advancedcluster.AwaitChanges(t.Context(), acc.MongoDBClient, &advancedcluster.ClusterWaitParams{ | ||
| _ = advancedcluster.AwaitChanges(t.Context(), acc.MongoDBClient, &advancedcluster.ClusterWaitParams{ |
Copilot
AI
Nov 25, 2025
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.
[nitpick] Using blank identifier to explicitly ignore the return value is appropriate here since AwaitChanges reports errors through the diagnostics parameter, but the function call appears incomplete without handling potential diagnostic errors after the call. Ensure diagnostics are checked if needed.
jwilliams-mongo
left a comment
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.
few minor comments on clarifying what happens for tenant/flex clusters
| * `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. |
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.
when we say "does not apply": are these fields not returned for M0/Flex? are they null? returned with pre-selected values?
|
|
||
| * `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. |
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.
same as above
| * `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. |
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.
same as above
Description
Use use_effective_fields boolean attribute in resource
effective_fields_test.goasresource_test.goalready has 3,000 lines.Link to any related issue(s): CLOUDP-360426
Type of change:
Required Checklist:
Further comments