mongodb / terraform-provider-mongodbatlas

Terraform MongoDB Atlas Provider: Deploy, update, and manage MongoDB Atlas infrastructure as code through HashiCorp Terraform
https://registry.terraform.io/providers/mongodb/mongodbatlas
Mozilla Public License 2.0
238 stars 167 forks source link

Confirmation on timelimit for a terraform apply #57

Closed nikhil-mongo closed 4 years ago

nikhil-mongo commented 4 years ago

I created a create cluster file and the terraform ran for 12m to create the cluster. But then it threw 500 server error. Is this the time limit to complete a plan?

Error:
mongodbatlas_cluster.atlas_cluster: Still creating... [12m0s elapsed]

Error: error creating MongoDB Cluster: GET https://cloud.mongodb.com/api/atlas/v1.0/groups/5cd520dca6f239768087f39e/clusters/cluster-atlas: 500 (request "Server Error") 

  on cluster.tf line 1, in resource "mongodbatlas_cluster" "atlas_cluster":
   1: resource "mongodbatlas_cluster" "atlas_cluster" {

On the other hand, the cluster is created in the Atlas. And now when I run terraform destroy it shows no plan.

themantissa commented 4 years ago

Please note: Per the README support is provided under MongoDB Atlas support agreements.

It doesn't look like you hit a timeout but looking at that groups Activity Feed there is an error related to cluster-atlas about failing to execute a plan, potentially related but I don't have the ability to dig further. The 500 error here would be from Atlas, not the provider but the provider wasn't able to - for some reason - get that the cluster was created. Looks like perhaps something was amiss but I do not have enough to help further.

themantissa commented 4 years ago

Reopening issue as we have enough information now to know this is likely pointing to an issue with the Provider having a problem if a plan is executing, in this case to build a cluster, and a recoverable error is encountered, here a 500 was returned by a GET and the plan stopped - however the cluster creation did succeed and hence Terraform state and the Atlas reality did not match. The plan should not exit but continue to poll for some period of time to see if the plan did succeed. @marinsalinas or @PacoDw thoughts?

PacoDw commented 4 years ago

Thanks, @themantissa and @nikhil-mongo so much for your review, we will check what happens with it, but @nikhil-mongo can you help us sharing the Terraform configuration to recreate the issue?

nikhil-mongo commented 4 years ago

Hi @PacoDw

I am using Terraform v0.12.10 and the cluster.tf file is attached.The file is cluster.txt

Also I did not make any change to the Terraform configuration, which would cause this. I believe the response to the errors like 500, where a retry should be made to check the state of the cluster will be a good idea. The purpose behind this is that Atlas has a rate limit for hitting API requests per project and this might have been reached when Terraform used the API request to track the status of the cluster. When I try to use the same file now, I am getting this error error.txt which means that terraform is still trying to read the cluster status.

The terraform.tfstate file is terraform_state.txt. Please note that I had terminated the cluster from the Atlas UI. Let me know if I need to send you anything else.

PacoDw commented 4 years ago

Thank you so much! We will figure out this on ASAP 👍

PacoDw commented 4 years ago

Hi, @nikhil-mongo,
I tried to recreate the issue with the recent changes, and I didn't have any error about it, just a little issue that's resolved. Could you plz download the latest changes and test it again?

If you have another concern or comment plz let us know

nikhil-mongo commented 4 years ago

Hi @PacoDw

Thanks for all the efforts. It is not that API would hit 500 error each time. But with the latest plugin updated in my terraform on local machine, it is working great at the moment. Hopefully, it should not panic again.

Also to mention, when terraform panic and did not continue with the deployment, how could it still be looking for the same cluster with the data dependencies when I tried to apply the same .tf file again. It showed that it could not state the cluster and is unaware of the cluster deployed. I had provided this in my last comment as well.

Thanks.

PacoDw commented 4 years ago

You are welcome, thank you so much for your review

nikhil-mongo commented 4 years ago

Hi @PacoDw and @themantissa ,

The above issue has been encountered again.

Below is the error:

Error: error deleting MongoDB Cluster (cluster-atlas): DELETE https://cloud.mongodb.com/api/atlas/v1.0/groups/5cd520dca6f239768087f39e/clusters/cluster-atlas: 500 (request "Internal Server Error") Unexpected error.

But the request succeeds and now Terraform still gives me the option to destroy the cluster and encounters 400 error each time. This has somewhat corrupted by tfstate file.

Please reopen this issue.

themantissa commented 4 years ago

@nikhil-mongo please ensure you are testing with the most recent version, which is 0.3.1.
https://github.com/terraform-providers/terraform-provider-mongodbatlas/blob/master/CHANGELOG.md