Closed j0rzsh closed 3 months ago
Thanks for opening this issue! Please make sure you've followed our guidelines when opening the issue. In short, to help us reproduce the issue we need:
The ticket CLOUDP-263634 was created for internal tracking.
Hi @j0rzsh, Thanks for opening the issue. I am not able to reproduce the issue with the Terraform configuration you provided. Please could you provide the following info so that we can further investigate:
Thanks for your collaboration
Hello @oarbusi! Sorry yesterday was bank holiday and wasn't able to post.
So... this stopped happening just the same as it started. I suspect some kind of change in Atlas API that was returning an unwanted value and provider was failing.
Same code same versions stopped working and after 2 or 3 hours started working again. Should we close the issue? I think provider should be able to handle an unwanted value from the API but not sure how it is implemented as golang is not my best skill :)
Many thanks!
Thanks @j0rzsh for the update! Glad to hear it's working. Since we are unable to reproduce the issue, creating a fix is hard. I will close the issue but also will keep an eye on this if it ever happens again. Please open an issue if you bump into any other issue so that we can help
@oarbusi Just to add a little more info because I think I discovered the reason. So the problem is I was importing manually created alerts, and playing with them to see how the module was working and how the MongoDB API named alerts.
This panic is easily reproduced creating an alert like this (with the code above):
alarms = [
{
event_type = "HOST_DOWN"
}
]
Then manually go to the MongoDB website, change the alarm to: "Replica Set - Number of unhealthy members is above 1" for example and then run terraform apply again.
As the state has an alarm that does not have matcher, threshold_config nor metric_threshold_config, and the alarm in Atlas has it, provider fails because it expects something else.
So this is a bit of a corner case, but still is not the intended behaviour (I want that my terraform apply make Atlas to be aligned with my code even if someone manually modified something using the website).
If everything is managed using terraform, everything appears to be working fine (I have created a bunch of alerts, then reordered the list and applied without any issues).
@j0rzsh thanks for the extra details! I have been able to reproduce your issue. I have created this PR fixing it. It should be released in the next release.
Manny many thanks!
@j0rzsh the fix for this issue has been released in v1.17.5. Thanks again for opening the issue
Is there an existing issue for this?
Provider Version
v1.17.4
Terraform Version
v1.9.2
Terraform Edition
Terraform Open Source (OSS)
Current Behavior
Terraform configuration to reproduce the issue
Steps To Reproduce
Just run a terraform plan and the provider will crash. It was working previously, same versions, same code.
Removing from the state and the code the alarms and running terraform plan work as expected.
Logs
No response
Code of Conduct