Skip to content
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

fix: Update mongodbatlas_cloud_backup_schedule to add the ID field to policyItems #1357

Merged
merged 3 commits into from
Aug 2, 2023

Conversation

andreaangiolillo
Copy link
Collaborator

@andreaangiolillo andreaangiolillo commented Aug 1, 2023

Description

Ticket: INTMDB-970

This bug was discovered as part of HELP-4841: currently mongodbatlas_cloud_backup_schedule is updating backup policies without providing the id fields for policyItems. This prevents atlas from updating old snaphosts to use the new policy.

This PR updates the logic to include the ID field to policyItems` when updating the resource.

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.
  • Breaking change (fix or feature that would cause existing functionality to not work as expected). Please, add the "breaking change" label to the PR.
  • This change requires a documentation update
  • Documentation fix/enhancement

Required Checklist:

  • I have signed the MongoDB CLA
  • I have read the contribution guidelines
  • 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

Further comments

Testing

Updated acceptance test

Running tool: /Users/andrea.angiolillo/.asdf/shims/go test -timeout 300000s -run ^TestAccBackupRSCloudBackupSchedule_basic$ github.com/mongodb/terraform-provider-mongodbatlas/mongodbatlas

ok  	github.com/mongodb/terraform-provider-mongodbatlas/mongodbatlas	772.266s

Tested locally and checked that the policy retemption date was updated

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # mongodbatlas_cloud_backup_schedule.test will be updated in-place
  ~ resource "mongodbatlas_cloud_backup_schedule" "test" {
        id                                       = "Y2x1c3Rlcl9uYW1l:Q2x1c3RlcjA=-cHJvamVjdF9pZA==:NjNmNGQ0YTQ3YmFlYWM1OTQwNmRjMTMx"
        # (11 unchanged attributes hidden)

      ~ policy_item_hourly {
            id                 = "64c8e99dcca1e53ba52324b6"
          ~ retention_value    = 5 -> 6
            # (3 unchanged attributes hidden)
        }

        # (2 unchanged blocks hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.
2023-08-01T12:26:16.225+0100 [INFO]  backend/local: apply calling Apply
2023-08-01T12:26:16.225+0100 [DEBUG] Building and walking apply graph for NormalMode plan
2023-08-01T12:26:16.226+0100 [DEBUG] ProviderTransformer: "mongodbatlas_cloud_backup_schedule.test (expand)" (*terraform.nodeExpandApplyableResource) needs provider["registry.terraform.io/mongodb/mongodbatlas"]
2023-08-01T12:26:16.226+0100 [DEBUG] ProviderTransformer: "mongodbatlas_cloud_backup_schedule.test" (*terraform.NodeApplyableResourceInstance) needs provider["registry.terraform.io/mongodb/mongodbatlas"]
2023-08-01T12:26:16.226+0100 [DEBUG] pruning unused provider["registry.terraform.io/hashicorp/aws"]
2023-08-01T12:26:16.226+0100 [DEBUG] ReferenceTransformer: "provider[\"registry.terraform.io/mongodb/mongodbatlas\"]" references: []
2023-08-01T12:26:16.226+0100 [DEBUG] ReferenceTransformer: "mongodbatlas_cloud_backup_schedule.test (expand)" references: []
2023-08-01T12:26:16.226+0100 [DEBUG] ReferenceTransformer: "mongodbatlas_cloud_backup_schedule.test" references: []
2023-08-01T12:26:16.226+0100 [DEBUG] Starting graph walk: walkApply
2023-08-01T12:26:16.226+0100 [DEBUG] created provider logger: level=debug
2023-08-01T12:26:16.261+0100 [WARN]  ValidateProviderConfig from "provider[\"registry.terraform.io/mongodb/mongodbatlas\"]" changed the config value, but that value is unused
mongodbatlas_cloud_backup_schedule.test: Modifying... [id=Y2x1c3Rlcl9uYW1l:Q2x1c3RlcjA=-cHJvamVjdF9pZA==:NjNmNGQ0YTQ3YmFlYWM1OTQwNmRjMTMx]
2023-08-01T12:26:16.269+0100 [INFO]  Starting apply for mongodbatlas_cloud_backup_schedule.test
2023-08-01T12:26:16.269+0100 [DEBUG] mongodbatlas_cloud_backup_schedule.test: applying the planned Update change
mongodbatlas_cloud_backup_schedule.test: Still modifying... [id=Y2x1c3Rlcl9uYW1l:Q2x1c3RlcjA=-cHJvamVjdF9pZA==:NjNmNGQ0YTQ3YmFlYWM1OTQwNmRjMTMx, 10s elapsed]
mongodbatlas_cloud_backup_schedule.test: Still modifying... [id=Y2x1c3Rlcl9uYW1l:Q2x1c3RlcjA=-cHJvamVjdF9pZA==:NjNmNGQ0YTQ3YmFlYWM1OTQwNmRjMTMx, 20s elapsed]
mongodbatlas_cloud_backup_schedule.test: Still modifying... [id=Y2x1c3Rlcl9uYW1l:Q2x1c3RlcjA=-cHJvamVjdF9pZA==:NjNmNGQ0YTQ3YmFlYWM1OTQwNmRjMTMx, 30s elapsed]
mongodbatlas_cloud_backup_schedule.test: Still modifying... [id=Y2x1c3Rlcl9uYW1l:Q2x1c3RlcjA=-cHJvamVjdF9pZA==:NjNmNGQ0YTQ3YmFlYWM1OTQwNmRjMTMx, 40s elapsed]
mongodbatlas_cloud_backup_schedule.test: Still modifying... [id=Y2x1c3Rlcl9uYW1l:Q2x1c3RlcjA=-cHJvamVjdF9pZA==:NjNmNGQ0YTQ3YmFlYWM1OTQwNmRjMTMx, 50s elapsed]
mongodbatlas_cloud_backup_schedule.test: Still modifying... [id=Y2x1c3Rlcl9uYW1l:Q2x1c3RlcjA=-cHJvamVjdF9pZA==:NjNmNGQ0YTQ3YmFlYWM1OTQwNmRjMTMx, 1m0s elapsed]
mongodbatlas_cloud_backup_schedule.test: Still modifying... [id=Y2x1c3Rlcl9uYW1l:Q2x1c3RlcjA=-cHJvamVjdF9pZA==:NjNmNGQ0YTQ3YmFlYWM1OTQwNmRjMTMx, 1m10s elapsed]
mongodbatlas_cloud_backup_schedule.test: Still modifying... [id=Y2x1c3Rlcl9uYW1l:Q2x1c3RlcjA=-cHJvamVjdF9pZA==:NjNmNGQ0YTQ3YmFlYWM1OTQwNmRjMTMx, 1m20s elapsed]
mongodbatlas_cloud_backup_schedule.test: Still modifying... [id=Y2x1c3Rlcl9uYW1l:Q2x1c3RlcjA=-cHJvamVjdF9pZA==:NjNmNGQ0YTQ3YmFlYWM1OTQwNmRjMTMx, 1m30s elapsed]
mongodbatlas_cloud_backup_schedule.test: Modifications complete after 1m30s [id=Y2x1c3Rlcl9uYW1l:Q2x1c3RlcjA=-cHJvamVjdF9pZA==:NjNmNGQ0YTQ3YmFlYWM1OTQwNmRjMTMx]
2023-08-01T12:27:46.300+0100 [DEBUG] State storage *statemgr.Filesystem declined to persist a state snapshot

Apply complete! Resources: 0 added, 1 changed, 0 destroyed.

Screenshot 2023-08-01 at 12 29 31

@andreaangiolillo andreaangiolillo changed the title Fix: Update mongodbatlas_cloud_backup_schedule to add the ID field to policyItems fix: Update mongodbatlas_cloud_backup_schedule to add the ID field to policyItems Aug 1, 2023
@andreaangiolillo andreaangiolillo marked this pull request as ready for review August 1, 2023 11:31
@andreaangiolillo andreaangiolillo requested a review from a team as a code owner August 1, 2023 11:31
@andreaangiolillo andreaangiolillo merged commit be6c131 into master Aug 2, 2023
@andreaangiolillo andreaangiolillo deleted the INTMDB-970 branch August 2, 2023 09:18
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.

2 participants