fix: Emit warning when use effective fields is used#4405
fix: Emit warning when use effective fields is used#4405marcabreracast wants to merge 5 commits intomasterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the advanced cluster plan modification logic to warn users when use_effective_fields = true is combined with auto-scaling and the configuration changes spec fields that Atlas will ignore.
Changes:
- Emit a Terraform warning when
use_effective_fields=true, auto-scaling is enabled, andinstance_size/disk_size_gb/disk_iopschange. - Refactor
autoScalingUsedto accept a single cluster model and adjust auto-scaling keep-unknown detection accordingly.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| autoScalingFields := determineKeepUnknownsAutoScaling(ctx, diags, state, plan) | ||
| keepUnknown = append(keepUnknown, autoScalingFields...) | ||
| emitWarningIfSpecChangedWithAutoScaling(ctx, diags, plan, attributeChanges) | ||
| schemafunc.CopyUnknowns(ctx, state, plan, keepUnknown, nil) |
There was a problem hiding this comment.
This PR introduces new user-facing behavior (a warning when use_effective_fields=true, auto-scaling is enabled, and spec fields change), but there’s no automated coverage asserting when the warning should/shouldn’t be emitted. Adding a focused unit test around emitWarningIfSpecChangedWithAutoScaling (or exercising it via an existing plan modifier test harness) would help prevent regressions and false positives.
There was a problem hiding this comment.
There's not a way of asserting warnings into the test framework. The code path is exercised by the existing TestAccAdvancedCluster_effectiveComputeAutoScalingInstanceSize test, which runs the exact scenario. A panic or logic error would be caught there.
Behaviour of the warning is documented and manual tests are done in the PR description.
Description
Emits a Terraform warning during
ModifyPlanwhen all three conditions are met:use_effective_fields = truecompute_enabled = trueordisk_gb_enabled = true)instance_size,disk_size_gb, ordisk_iopsIn this combination, the Atlas API silently ignores the spec change, the new values are stored in Terraform state but the cluster is never modified, producing a false "1 changed" result with no feedback. The warning makes this visible and directs the user to temporarily disable auto-scaling to apply the change.
Link to any related issue(s): https://jira.mongodb.org/browse/CLOUDP-388940
Type of change:
Required Checklist:
Testing
The warning itself cannot be asserted programmatically. Manual verification is therefore required.
Manual test steps
Further comments