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(rdb-user- privileges): add check user and retry process #1057

Merged
merged 4 commits into from Jan 31, 2022

Conversation

Monitob
Copy link
Contributor

@Monitob Monitob commented Jan 25, 2022

No description provided.

@Monitob Monitob self-assigned this Jan 25, 2022
@Monitob Monitob linked an issue Jan 25, 2022 that may be closed by this pull request
@bLuka
Copy link

bLuka commented Jan 26, 2022

Hello,

I wanted to understand properly, and looked at your changes. I don't see any change from the place where the panic from #1054 happened. Do you mean the issue happened because of a failure during resource creation?

Thank you very much in advance for your answers!

@Monitob
Copy link
Contributor Author

Monitob commented Jan 27, 2022

Hello,

I wanted to understand properly and look at your changes. I don't see any change from the place where the panic from #1054 happened. Do you mean the issue happened because of a failure during resource creation?

Thank you very much in advance for your answers!

Yes, I've noticed that the error from the API was not the right one.

Important points to understand the bug.

  • The database name in the query was the instance name. (failure during the resource creation and the tfstate was not good)
  • The code HTTP was 409 with not a clear message. Only state unavailable
  • The privilege is a resource related to a user and a database. (this both resource doesn’t have an ID to work with)

Conclusion:

  • The 409 means the user does not exist or the instance is really doing something so wait
  • We have to check if the user really exist, otherwise, we skip
  • To remove a user we need to put their privileges to none.
  • The user and privilege could happen really fast so we check every time and it could be async.

The terraform provider allows us to manage the state of the resources and there are some cases that the state checks are not made.

Thank you for your @bLuka question and allow me to identify this. Please feel free to create a new issue for further fixes or contact me by our community slack.

scaleway/resource_rdb_privilege.go Outdated Show resolved Hide resolved
scaleway/resource_rdb_privilege_test.go Outdated Show resolved Hide resolved
scaleway/resource_rdb_user.go Outdated Show resolved Hide resolved
scaleway/resource_rdb_user.go Outdated Show resolved Hide resolved
scaleway/resource_rdb_privilege.go Outdated Show resolved Hide resolved
scaleway/resource_rdb_privilege_test.go Outdated Show resolved Hide resolved
@Monitob Monitob merged commit 5de8d45 into scaleway:master Jan 31, 2022
@Monitob Monitob deleted the fix-user-privileges branch January 31, 2022 17:01
remyleone pushed a commit to remyleone/terraform-provider-scaleway that referenced this pull request Mar 28, 2022
@remyleone remyleone added the rdb Managed MySQL and PostgreSQL issues, bugs and feature requests label Jul 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rdb Managed MySQL and PostgreSQL issues, bugs and feature requests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Panic: index out of range with rdb_privilege
3 participants