Skip to content

Conversation

maastha
Copy link
Collaborator

@maastha maastha commented Aug 31, 2025

Description

Removes mongodbatlas_advanced_cluster deprecated params.

TPF preview to V2 state diff: https://www.diffchecker.com/T3369rEg/
SDKv2 to V2 state diff: https://www.diffchecker.com/4VjSiR7x/

Some of the tests that have been removed:

  • TestAccMockableAdvancedCluster_symmetricShardedOldSchemaDiskSizeGBAtElectableLevel
  • TestAccMockableAdvancedCluster_symmetricShardedOldSchema
  • TestAccAdvancedCluster_replicaSetScalingStrategyAndRedactClientLogDataOldSchema
  • TestMigAdvancedCluster_asymmetricShardedNewSchema
  • TestAccClusterAdvancedClusterConfig_singleShardedTransitionToOldSchemaExpectsError
  • TestMigAdvancedCluster_symmetricGeoShardedOldSchema
  • TestAccClusterAdvancedCluster_priorityOldSchema

Related documentation changes: #3634

Link to any related issue(s): CLOUDP-333683

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

secrets: inherit
uses: ./.github/workflows/acceptance-tests.yml
with:
reduced_tests: true
reduced_tests: false
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

will revert before merging

Copy link
Member

Choose a reason for hiding this comment

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

nit: my recommendation is these cases is to add a comment so it's clear and harder to forget, e.g.:

 reduced_tests: false // TODO: CHANGE TO true BEFORE MERGING

@maastha maastha marked this pull request as ready for review August 31, 2025 23:59
@Copilot Copilot AI review requested due to automatic review settings August 31, 2025 23:59
@maastha maastha requested review from a team as code owners August 31, 2025 23:59
Copy link
Contributor

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

Copy link
Contributor

@Copilot Copilot AI left a 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 removes deprecated parameters from the mongodbatlas_advanced_cluster resource and data sources, cleaning up the API surface by eliminating legacy schema attributes that were marked for deprecation.

Key changes include:

  • Removal of deprecated attributes: use_replication_spec_per_shard, num_shards, id, disk_size_gb, default_read_concern, and fail_index_key_too_long
  • Elimination of legacy API compatibility layers and dual-schema support
  • Simplification of test configurations and removal of old schema test cases

Reviewed Changes

Copilot reviewed 36 out of 45 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
internal/service/advancedclustertpf/schema.go Removes deprecated schema attributes and related plan modifiers
internal/service/advancedclustertpf/resource.go Simplifies resource logic by removing legacy API handling
internal/service/advancedclustertpf/resource_test.go Updates test cases to use new schema and removes old schema tests
internal/service/advancedclustertpf/resource_compatiblity.go Removes legacy compatibility functions for old sharding config
internal/testutil/acc/advanced_cluster.go Updates test utilities to remove deprecated parameters

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@maastha
Copy link
Collaborator Author

maastha commented Sep 1, 2025

Tests timing out in cloud-dev for now but were run previously https://github.com/mongodb/terraform-provider-mongodbatlas/actions/runs/17350913203/job/49257053501 on the draft branch

UPDATE: tests are now passing except TestAccAdvancedCluster_updateDeleteTimeoutFlex due to ATLAS_GENERAL_ERROR. This succeeds locally.

Copy link
Collaborator

@marcosuma marcosuma left a comment

Choose a reason for hiding this comment

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

Few tests failing so going to hold on LGTM

Copy link

@antellezr-mdb antellezr-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

@AgustinBettati AgustinBettati left a comment

Choose a reason for hiding this comment

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

Nice job, just want to confirm behaviour of TestAccClusterAdvancedCluster_replicaSetAWSProvider before LGTM

WithAnalyticsSpecs: false, // other update made after removed analytics block, computed value is expected to be the same
}, isSDKv2),
Check: checkReplicaSetAWSProvider(isTPF, projectID, clusterName, 50, 5, true, true),
WithAnalyticsSpecs: true, // other update made after removed analytics block, computed value is expected to be the same
Copy link
Member

Choose a reason for hiding this comment

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

I believe this comment is not accurate now as analytics specs is never removed. Lets double check what is the expected behaviour we want to capture in the test and from there adjust.

Copy link
Collaborator Author

@maastha maastha Sep 2, 2025

Choose a reason for hiding this comment

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

the test now simply checks update of nodes & disk_size_gb, while these values are explicitly configured for both analytics & electable specs, will remove the comment.
the expected behavior now is that if we expect analytics specs disk_size_gb to be updated as well, then user needs to explicitly specify it in the config, otherwise previous state is preserved (similar to TestAccAdvancedCluster_removeBlocksFromConfig).
On the contrary, previously id root disk_size_gb (now removed) was updated , then even if analytics specs had been removed from config, it would still be updated.

Copy link
Collaborator Author

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 any doc changes need to be made for this?

Copy link
Member

Choose a reason for hiding this comment

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

Okay, I am fine with adjusting this test as we still capture the behaviour of having removal of blocks being a no-op in TestAccAdvancedCluster_removeBlocksFromConfig. As a side note I see that WithAnalyticsSpecs is now always equal to true, we can remove that logic to simplify.

In terms of docs I believe the best practice section covers this aspect, only consideration is we could make it more visible (potentially linking from top of the page or from specific relevant attributes).

Copy link
Collaborator Author

@maastha maastha Sep 3, 2025

Choose a reason for hiding this comment

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

I'm not sure if the top of the page is the best idea because we already have a plethora of notes there. I'll add a mention in replication specs attribute though

Copy link
Collaborator Author

@maastha maastha Sep 3, 2025

Choose a reason for hiding this comment

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

image

adding this for region_configs & replication_specs

Comment on lines 1598 to 1602
func configAWSProvider(t *testing.T, configInfo ReplicaSetAWSConfig, isTPF bool) string {
t.Helper()
analyticsSpecs := ""

if isOptionalTrue(useSDKv2...) {
if !isTPF {
Copy link
Member

Choose a reason for hiding this comment

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

nit: Given we are preserving ConvertAdvancedClusterToTPF, can we leverage it here to only have one config definition.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'd prefer to keep it as is, this config also uses root level disk_size_gb which is different from the one used for TPF

{
ProtoV6ProviderFactories: acc.TestAccProviderV6Factories,
Config: configShardedTransitionOldToNewSchema(t, true, projectID, clusterName, true, true, false),
Check: acc.CheckIndependentShardScalingMode(resourceName, clusterName, "CLUSTER"),
Copy link
Member

Choose a reason for hiding this comment

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

great that we are preserving these checks of the autoscaling mode

@@ -0,0 +1,382 @@
package advancedclustertpf_test
Copy link
Member

Choose a reason for hiding this comment

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

like the approach of having separate file for specific 1.x migration paths

Comment on lines -33 to -39
keepUnknownsCalls = schemafunc.KeepUnknownFuncOr(keepUnkownFuncWithNodeCount, keepUnkownFuncWithNonEmptyAutoScaling)
keepUnknownsCalls = schemafunc.KeepUnknownFuncOr(keepUnkownFuncWithNonEmptyAutoScaling)
)

func keepUnkownFuncWithNodeCount(name string, replacement attr.Value) bool {
return name == "node_count" && !replacement.Equal(types.Int64Value(0))
}

Copy link
Member

Choose a reason for hiding this comment

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

Do you recall why this change was needed? Would not expect change to the plan modifier logic associated to node_count

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

can double check with @EspenAlbert #3592 (comment)
but I believe this was actually not being used.

Copy link
Collaborator

@EspenAlbert EspenAlbert Sep 2, 2025

Choose a reason for hiding this comment

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

Sorry, I think Agustin is right. This function should not be removed.
I think I read num_shards instead of node_count.
This ensures that a value in the state that is not 0 remains unknown.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@EspenAlbert is there an existing test for this that should have failed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@EspenAlbert @AgustinBettati fyi I have also added a list of some of the tests that have been removed in this PR.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Behavior node_count in the plan:

  1. Copied from state if block removed (Leo's logic in AdjustRegionConfigsChildren)
  2. if node_count > 0 in the state: KeepUnknown. No longer used because of (1)
  3. if node_count == 0: UseState value. Can happen since the API returns spec values even when not set in the config.

Having investigated this. We could remove the function and always keep it unknown.

To do test case (2), we would need to add a plan modifier test, similar to the TestPlanChecksClusterTwoRepSpecsWithAutoScalingAndSpecs.
I added a commit here to show how the behavior of (1) is used.

Copy link
Member

Choose a reason for hiding this comment

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

Just to make sure I understand, the current function is redundant because if node_count > 0 in the state (of a removed block) AdjustRegionConfigsChildren will ensure it has a known value. Essentially there would never be a case where node_count is left unknown right?
Agree we can add a test to verify this is correct.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added test in this commit which checks node_count is known

Copy link
Collaborator

@EspenAlbert EspenAlbert left a comment

Choose a reason for hiding this comment

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

Wow, a lot of work went into this! Well done 👏

Copy link
Member

@AgustinBettati AgustinBettati left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for addressing comments

@maastha
Copy link
Collaborator Author

maastha commented Sep 3, 2025

only TestAccAdvancedCluster_updateDeleteTimeoutFlex failing due to ATLAS_GENERAL_ERROR (flaky, succeeds locally), merging

@maastha maastha merged commit 6515a26 into CLOUDP-320243-dev-2.0.0 Sep 3, 2025
42 of 43 checks passed
@maastha maastha deleted the CLOUDP-333683-remove-old-schema-attrs branch September 3, 2025 23:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants