Skip to content

Terrform successfully applied changes, however mongo API returned 400 #689

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

Closed
markandersontrocme opened this issue Mar 1, 2022 · 4 comments · Fixed by #687
Closed

Terrform successfully applied changes, however mongo API returned 400 #689

markandersontrocme opened this issue Mar 1, 2022 · 4 comments · Fixed by #687
Assignees
Labels

Comments

@markandersontrocme
Copy link

Terraform CLI and Terraform MongoDB Atlas Provider Version

Terraform v1.1.6
on darwin_amd64
+ provider registry.terraform.io/mongodb/mongodbatlas v1.3.0

Terraform Configuration File

# Copy-paste your configuration info here

Steps to Reproduce

Cluster is on version 4.0 and try to upgrade it to 4.2

  1. terrafrom plan outputs that it will upgrade to 4.2
  2. terraform apply outputs
Modifying...
Modifications complete after 2s
Apply complete!
  1. No changes appear in MongoDB cloud
  2. terrafrom plan outputs that it will upgrade to 4.2
  3. repeat all the steps

Expected Behavior

The cluster to get upgraded or in this case to throw an error message.

Actual Behavior

It said the apply was complete and modifications worked.

Debug Output

---[ REQUEST ]---------------------------------------
PATCH /api/atlas/v1.0/groups/xxxxxxxxxxx/clusters/xxxxx HTTP/1.1
Host: cloud.mongodb.com
User-Agent: terraform-provider-mongodbatlas/1.3.0 go-mongodbatlas/0.15.0 (darwin;amd64)
Content-Length: 59
Accept: application/json
Content-Type: application/json
Accept-Encoding: gzip

{
 "autoScaling": {
  "compute": {}
 },
 "mongoDBMajorVersion": "4.2"
}

-----------------------------------------------------: timestamp=2022-03-01T15:11:58.269-0500
2022-03-01T15:11:58.870-0500 [INFO]  provider.terraform-provider-mongodbatlas_v1.3.0: 2022/03/01 15:11:58 [DEBUG] MongoDB Atlas API Response Details:
---[ RESPONSE ]--------------------------------------
HTTP/2.0 400 Bad Request
Content-Length: 369
Content-Type: application/json
Date: Tue, 01 Mar 2022 20:11:58 GMT
Referrer-Policy: strict-origin-when-cross-origin
Server: envoy
Strict-Transport-Security: max-age=31536000; includeSubdomains;
X-Content-Type-Options: nosniff
X-Envoy-Upstream-Service-Time: 184
X-Frame-Options: DENY
X-Mongodb-Service-Version: gitHash=66c497139005fec956be262cf890b70a23c16c01; versionString=v20220216
X-Permitted-Cross-Domain-Policies: none

{
 "detail": "Legacy backup is not supported on clusters with MongoDB version 4.2 or higher. We recommend that you switch to Cloud Backup along with your version upgrade. Your existing legacy backup snapshots will still be kept until they expire.",
 "error": 400,
 "errorCode": "CONTINUOUS_BACKUP_NOT_SUPPORTED_ON_MONGODB_VERSION_UPGRADE",
 "parameters": [],
 "reason": "Bad Request"
}

Crash Output

Additional Context

References

@nikhil-mongo nikhil-mongo self-assigned this Mar 2, 2022
@nikhil-mongo
Copy link
Collaborator

@markandersontrocme

Since you have Continuous/Legacy Backup enabled for the cluster when running on 4.0. Therefore, below two changes are required for the cluster to be made in order to upgrade it to 4.2.

MongoDB Atlas does not supports Legacy Backup from 4.2 onwards and the only way to use backup is to use Cloud Backup.

mongo_db_major_version       = "4.2"
cloud_backup = true
pit_enabled=true

Once done, you can then run terraform apply to successfully upgrade to 4.2. Please reach out to Atlas Support if you have more questions or concerns.

Thanks

@markandersontrocme
Copy link
Author

@nikhil-mongo

I know that I need to disable legacy backup and enable cloud backup I was able to figure that out by viewing the debug logs, however there is still a bug with the fact that Mongo API returned a 400 but the terraform provider just said apply was complete...

The terraform provider should also throw an error

@themantissa themantissa reopened this Mar 2, 2022
@themantissa
Copy link
Collaborator

@markandersontrocme thank you for the feedback. You are correct, the provider should appropriately catch the error and not complete successfully. We actually just corrected this: #687 (cc @martinstibbe) and expect the fix in our next release. We will close this issue when that is corrected.

@themantissa themantissa linked a pull request Mar 2, 2022 that will close this issue
10 tasks
@themantissa themantissa added the bug label Mar 2, 2022
@martinstibbe
Copy link
Contributor

@markandersontrocme This fix will be in version 1.3.1 pre release for testing soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants