Conversation
…ompute auto-scaling Add test steps to verify Atlas returns 400 (not 500) when clearing storage_config while compute auto-scaling stays configured. Refs: CLOUDP-447210
When clearing storage_config on an INFINITE cluster, the forced replicationSpecs PATCH included analyticsSpecs with nodeCount=0 but no instanceSize, causing Atlas to return 400 MISSING_ATTRIBUTE. The fix omits analyticsSpecs entirely when nodeCount=0 and instanceSize is not set, which is the correct behavior for INFINITE clusters. Fixes: CLOUDP-447210
…onfig The function now handles more than just auto-scaling children - it also omits analyticsSpecs without instanceSize that INFINITE rejects. The new name better reflects its purpose.
…ero-node analytics Add test case to verify that clearing storage_config works when analytics_specs is explicitly configured with node_count = 0. This tests the edge case where analyticsSpecs would be included in the PATCH without instanceSize.
…sSpecs The comment incorrectly suggested that only INFINITE rejects analyticsSpecs without instanceSize. In reality, Atlas rejects this for all cluster types, but the bug only manifests for INFINITE because ForceUpdateAttr forces the entire replicationSpecs into the PATCH.
…Config - Update comments in model_to_ClusterDescription20240805.go and resource.go to reflect that the function now handles more than just empty auto-scaling children (also analyticsSpecs without instanceSize). - Remove redundant comment in configDatabaseEditionWithZeroNodeAnalytics that repeated information already in the test function comment.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When clearing
storage_configon an INFINITE cluster, the forcedreplicationSpecsPATCH includedanalyticsSpecswithnodeCount=0but noinstanceSize, causing Atlas to return 400 MISSING_ATTRIBUTE. Atlas was returning 500 instead of 400, which made this provider bug look like an Atlas issue until the 500 was fixed.Root Cause
The issue was in the Terraform provider, not Atlas. The bug only triggers for INFINITE clusters because:
analyticsSpecsin responses (even withnodeCount: 0)storage_config,shardSizeLimitRemovedreturns true, which setsForceUpdateAttr = ["replicationSpecs"]ForceUpdateAttrforces the entirereplicationSpecstree into the PATCH, including unchanged attributesanalyticsSpecsbecame{"nodeCount": 0}withoutinstanceSizebecause:analyticsSpecsfrom state whennodeCount == 0(to avoid ANALYTICS_INSTANCE_SIZE_MUST_MATCH errors)CopyUnknownscopiesnodeCountfrom state but keepsinstanceSizeunknown (because auto-scaling is enabled, which addsinstance_sizetokeepUnknown)CORE clusters don't have this issue because
shardSizeLimitRemovedreturns false (CORE doesn't havestorageConfig), soForceUpdateAttris not set and only changed attributes are included in the PATCH.The Approach: Why ForceUpdateAttr + omitInvalidInfiniteConfig
Why
ForceUpdateAttris needed:The Atlas API requires the entire
replicationSpecsobject to be present in the PATCH request to clearshardSizeLimitGB. WithoutForceUpdateAttr:storageConfigis not present (Atlas doesn't return it after clearing)storageConfigis not present (user removed it from config)ForceUpdateAttrforces the entirereplicationSpecsinto the PATCH, which tells Atlas to clear the field.Why
omitInvalidInfiniteConfigis needed:When
ForceUpdateAttrforces the entirereplicationSpecsinto the PATCH, it includes ALL fields, not just the ones that changed. This includesanalyticsSpecswithnodeCount=0but noinstanceSize, which INFINITE rejects.omitInvalidInfiniteConfigremoves invalid fields from the PATCH payload before sending it to Atlas.Why this asymmetry exists:
The asymmetry between CORE and INFINITE is inherent to the feature:
storageConfig(shardSizeLimitGB)This is not a bug - it's a reflection of the different capabilities of CORE and INFINITE clusters.
The Fix
Renamed
omitEmptyAutoScalingChildren→omitInvalidInfiniteConfig: The function now handles more than just auto-scaling children - it also omitsanalyticsSpecswithoutinstanceSizethat INFINITE rejects. The new name better reflects its purpose.Added
analyticsSpecsremoval logic: WhennodeCount=0andinstanceSizeis not set, the function now setsanalyticsSpecs = nilto prevent Atlas from rejecting the PATCH.Future Improvements
A future PR could explore removing
ForceUpdateAttrentirely by using a different mechanism to detect the removal (e.g., explicitly markingstorageConfigfor removal in the plan). However, this requires verification that the Atlas API accepts this approach and is out of scope for this fix.Link to any related issue(s): CLOUDP-447210
Type of change:
Required Checklist:
Further comments