Skip to content

fix: Avoid error when removing read only spec in region config that does not define electable specs #3162

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

Merged
merged 12 commits into from
Mar 14, 2025

Conversation

AgustinBettati
Copy link
Member

@AgustinBettati AgustinBettati commented Mar 12, 2025

Description

Link to any related issue(s): CLOUDP-306136, also follow ups on test made in CLOUDP-305352.

A change is made to the plan modifier so that if a region does not have an electable spec, if a read only spec is removed its values are still taken from the state. Complete details and example in CLOUDP-306136.

Additional test changes present in PR:

  • Adding explicit steps to verify empty plan after removal of blocks
  • Adding scenario of removing block in region config that does not have electable_specs defined.

Type of change:

  • Bug fix (non-breaking change which fixes an issue). Please, add the "bug" label to the PR.
  • New feature (non-breaking change which adds functionality). Please, add the "enhancement" label to the PR. A migration guide must be created or updated if the new feature will go in a major version.
  • Breaking change (fix or feature that would cause existing functionality to not work as expected). Please, add the "breaking change" label to the PR. A migration guide must be created or updated.
  • This change requires a documentation update
  • Documentation fix/enhancement

Required Checklist:

  • I have signed the MongoDB CLA
  • I have read the contributing guides
  • I have checked that this change does not generate any credentials and that they are NOT accidentally logged anywhere.
  • I have added tests that prove my fix is effective or that my feature works per HashiCorp requirements
  • I have added any necessary documentation (if appropriate)
  • I have run make fmt and formatted my code
  • If changes include deprecations or removals I have added appropriate changelog entries.
  • If changes include removal or addition of 3rd party GitHub actions, I updated our internal document. Reach out to the APIx Integration slack channel to get access to the internal document.

Further comments

@github-actions github-actions bot added the bug label Mar 12, 2025
@@ -0,0 +1,3 @@
```release-note:bug
resource/mongodbatlas_advanced_cluster (preview provider 2.0.0): Avoid error when removing `read_only_specs` in `region_configs` that does not define `electable_specs`
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using mongodbatlas_advanced_cluster (preview provider 2.0.0) in the changelog

@@ -1375,23 +1388,25 @@ func TestAccMockableAdvancedCluster_shardedAddAnalyticsAndAutoScaling(t *testing
})
}

func TestAccMockableAdvancedCluster_removeBlocksFromConfig(t *testing.T) {
func TestAccAdvancedCluster_removeBlocksFromConfig(t *testing.T) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refactored removeBlocksFromConfig from a Mockable to regular test.
Main motivation was that execution of this test is long (+40min) and getting a successful local execution for updating golden files is a challenge. @lantoli I know you recently added this test, let me know if you see a concern with this.

@AgustinBettati AgustinBettati marked this pull request as ready for review March 13, 2025 09:19
@AgustinBettati AgustinBettati requested review from a team as code owners March 13, 2025 09:19
Copy link
Contributor

APIx bot: a message has been sent to Docs Slack channel

},
},
}
testStep := acc.TestStepCheckEmptyPlan(config)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. Refactor, like it better than what I did in #3105

Copy link
Contributor

@lmkerbey-mdb lmkerbey-mdb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Copy link
Member

@lantoli lantoli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@AgustinBettati
Copy link
Member Author

AgustinBettati commented Mar 14, 2025

Added additional changes to handle scenario that appeared in one of the tests:
If a region config

  • does not have electable specs
  • its read only spec is removed
  • instance size is modified in another region config from the same replication spec

The read only spec that was removed will have the new updated value of the instance size defined in the associated region_config electable spec. ff33457 and 7870b3c specifically capture this fix.

Verifying successful tests in

@AgustinBettati AgustinBettati merged commit 9c6c432 into master Mar 14, 2025
38 of 39 checks passed
@AgustinBettati AgustinBettati deleted the CLOUDP-306136 branch March 14, 2025 16:20
svc-apix-Bot added a commit that referenced this pull request Mar 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants