mongodb / mongodbatlas-cloudformation-resources

MongoDB Atlas CloudFormation Resources: Deploy, update, and manage MongoDB Atlas infrastructure as code through AWS CloudFormation
https://www.mongodb.com/atlas/aws-cloudformation
Apache License 2.0
58 stars 38 forks source link

fix: Edits to replication specs for cluster #1087

Closed EspenAlbert closed 2 months ago

EspenAlbert commented 2 months ago

Proposed changes

  1. Adds e2e test for cluster
  2. Fix: Edits to replication specs for cluster

Test Summary

  1. Create a GEOSHARDED cluster with a single replication spec (zone1) with 3 nodes
  2. Update the cluster:
    • Change from 3->5 nodes in zone1
    • Add a new replication spec (zone2) with 5 nodes
  3. Assert the replication_id is kept on the 1st replication spec, and a new replication spec is added and both replication specs have 5 nodes

Fix Summary

The fix reads the current cluster if replication specs are set and "matches" replication IDs. See the unit tests in mappings_test for the matching details.

Note: We couldn't reuse the Terraform implementation since CFN doesn't store the full state of the resource. It only receives the template used for the update call; this means the replication_spec IDs will never be set on the prevModel or currentModel (this behavior was "discovered" by trying an initial fix of updating the replication specs of the currentModel during create)

Bug reproduced & fix screenshots

Example of failing e2e test (Github action before fix committed)

Screenshot from CFN:

image

Example of passing e2e test (Github action after fix committed)

Screenshot from CFN:

image

Link to any related issue(s): CLOUDP-256730 and CLOUDP-256534

Type of change:

Manual QA performed:

Required Checklist:

Further comments

contract tests:

image