Queue Terraform state destroy worker outside of transaction
What does this MR do and why?
If Terraform::States::TriggerDestroyService
is called from within a database transaction, an error is raised because we need to be outside of a transaction to schedule a Sidekiq worker.
Instead, we queue the worker after the current transaction is committed using AfterCommitQueue
.
Screenshots or screen recordings
These are strongly recommended to assist reviewers and reduce the time to merge your change.
How to set up and validate locally
- Using the Rails console, create a Terraform state:
> Terraform::State.create!(project_id: <project-id>, name: 'test-state')
- Create a project/group/personal access token with maintainer permissions for the associated project
- Send a request to remove the state:
> curl --header "Private-Token: <your_access_token>" --request DELETE "https://localhost:3000/api/v4/projects/<project-id>/terraform/state/test-state"
- Visit http://path/to/project/-/terraform and verify the state is (eventually) removed
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Tiger Watson