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: Marks project.region_usage_restrictions as OptionalComputed to avoid provider upgrade errors #2291

Merged

Conversation

EspenAlbert
Copy link
Collaborator

@EspenAlbert EspenAlbert commented May 21, 2024

Description

  • Marks project.region_usage_restrictions as OptionalComputed to avoid provider upgrade errors
  • Enables TestAccGovProject_withProjectOwner in CI
  • Adds TestMigGovProject_regionUsageRestrictionsDefault (also enabled in the CI, error reproduction)

Link to any related issue(s): #2263 and CLOUDP-248517

Marking the attribute as Computed as earlier versions of the resource will have an empty state for this attribute.
Since the state is empty and the default server value depends on cloud-gov or not:

  • If cloud-gov, default value is: COMMERCIAL_FEDRAMP_REGIONS_ONLY
  • else, default value is null

Example of error and solution:

mongodbatlas_project.project: Modifying... [id=664c6820c4391e7c9f58377c]
╷
│ Error: Provider produced inconsistent result after apply
│
│ When applying changes to mongodbatlas_project.project, provider "provider[\"registry.terraform.io/mongodb/mongodbatlas\"]" produced an unexpected new value: .region_usage_restrictions: was null, but now cty.StringVal("COMMERCIAL_FEDRAMP_REGIONS_ONLY").
│
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.
╵

After adding Computed: true

mongodbatlas_project.project: Refreshing state... [id=664c6820c4391e7c9f58377c]

No changes. Your infrastructure matches the configuration.

Terraform has compared your real infrastructure against your configuration and found no differences, so no changes are needed.

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 defined an isolated PR with a relevant title as it will be used in the auto-generated changelog.
  • 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 May 21, 2024
@marcosuma
Copy link
Collaborator

do we have an acceptance test for this?

@EspenAlbert
Copy link
Collaborator Author

@marcosuma I have been investigating a bit, and we don't have ANY test running in mongodbgov.
I am looking at ways to add those tests

@EspenAlbert EspenAlbert force-pushed the CLOUDP-248517_project_region_usage_restrictions_optional_only branch from 11f5117 to 17591c0 Compare May 24, 2024 14:13
@EspenAlbert EspenAlbert changed the base branch from master to CLOUDP-250271_cloud_gov May 24, 2024 14:14
@EspenAlbert EspenAlbert force-pushed the CLOUDP-248517_project_region_usage_restrictions_optional_only branch from 81d47ae to 2ba7f47 Compare May 24, 2024 14:30
@EspenAlbert EspenAlbert marked this pull request as ready for review May 24, 2024 15:32
@EspenAlbert EspenAlbert requested review from a team as code owners May 24, 2024 15:32
Copy link
Contributor

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

Copy link

@erabil-mdb erabil-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!

{
ExternalProviders: acc.ExternalProviders("1.16.0"),
Config: configGovSimple(orgID, projectName),
Check: resource.ComposeTestCheckFunc(
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: based on what we were discussing last Thurs, have you done a quick manual check to verify the test is actually failing if you write a wrong check assertion? It would help us make sure the test is actually set-up correctly.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I did it :D Next time, I'll try to check in the test before the fix so it can be seen in the CI too (test added push and then fix push) 🚀

@marcosuma
Copy link
Collaborator

Nice one!

Base automatically changed from CLOUDP-250271_cloud_gov to master May 27, 2024 08:29
@EspenAlbert EspenAlbert merged commit 415c54b into master May 27, 2024
32 checks passed
@EspenAlbert EspenAlbert deleted the CLOUDP-248517_project_region_usage_restrictions_optional_only branch May 27, 2024 09:30
svc-apix-Bot added a commit that referenced this pull request May 27, 2024
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.

4 participants