fly-apps / terraform-provider-fly

Terraform provider for the Fly.io API
BSD 3-Clause "New" or "Revised" License
114 stars 38 forks source link

Destroying volume fails saying it's still attached to the machine #218

Closed bilby91 closed 1 year ago

bilby91 commented 1 year ago

Hello,

We are using fly machines for our coder deployment.

We've been having issue with the destruction of the workspaces. Every time we try to delete the workspace, we run into this issue where the volume can't get deleted because it's still attached to the machine, even though the machine destruction has already successfully completed.

Initializing the backend...
Initializing provider plugins...
- Reusing previous version of fly-apps/fly from the dependency lock file
- Reusing previous version of coder/coder from the dependency lock file
- Using previously-installed fly-apps/fly v0.0.23
- Using previously-installed coder/coder v0.7.0
Terraform has been successfully initialized!
You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.
If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
Terraform 1.5.2
coder_app.code-server[0]: Plan to delete
coder_metadata.workspace[0]: Plan to delete
fly_machine.workspace[0]: Plan to delete
coder_agent.main: Plan to delete
fly_volume.home-volume: Plan to delete
fly_app.workspace: Plan to delete
coder_app.code-server[0]: Destroying... [id=228d3f47-0888-428b-97c4-2eceea497f3e]
coder_metadata.workspace[0]: Destroying... [id=dae4ceca-81dd-46fd-9eb5-7109e0e72f15]
coder_app.code-server[0]: Destruction complete after 0s
coder_metadata.workspace[0]: Destruction complete after 0s
fly_machine.workspace[0]: Destroying... [id=328743d0b43985]
fly_machine.workspace[0]: Destruction complete after 5s
fly_volume.home-volume: Destroying... [id=vol_jn924oqjj6qv03lq]
coder_agent.main: Destroying... [id=77642450-80c1-48c6-82a9-502ab6633032]
coder_agent.main: Destruction complete after 0s
fly_volume.home-volume: Destruction errored after 1s
Error: Delete volume failed
input:3: deleteVolume This volume is attached to a machine(328743d0b43985) and cannot be deleted.

Is there any workaround to avoid having to destroy resources multiple times?

mootari commented 1 year ago

You can find a workaround here: https://github.com/fly-apps/terraform-provider-fly/issues/154#issuecomment-1618942504

bilby91 commented 1 year ago

@mootari That did the trick!

Thanks!