terraform
terraform copied to clipboard
Provisioning doesn't gracefully shut down on connection issues
Terraform Version
Terraform v0.7.13
Affected Resource(s)
- remote-exec
Debug Output
azurerm_virtual_machine.master: Provisioning with 'remote-exec'...
azurerm_virtual_machine.master (remote-exec): Connecting to remote host via SSH...
azurerm_virtual_machine.master (remote-exec): Host: 104.214.27.167
azurerm_virtual_machine.master (remote-exec): User: ubuntu
azurerm_virtual_machine.master (remote-exec): Password: false
azurerm_virtual_machine.master (remote-exec): Private key: true
azurerm_virtual_machine.master (remote-exec): SSH Agent: true
azurerm_virtual_machine.master: Still creating... (2m6s elapsed)
azurerm_virtual_machine.master: Still creating... (2m10s elapsed)
azurerm_virtual_machine.master: Still creating... (2m16s elapsed)
azurerm_virtual_machine.master: Still creating... (2m20s elapsed)
azurerm_virtual_machine.master (remote-exec): Connecting to remote host via SSH...
azurerm_virtual_machine.master (remote-exec): Host: 104.214.27.167
azurerm_virtual_machine.master (remote-exec): User: ubuntu
azurerm_virtual_machine.master (remote-exec): Password: false
azurerm_virtual_machine.master (remote-exec): Private key: true
azurerm_virtual_machine.master (remote-exec): SSH Agent: true
azurerm_virtual_machine.master: Still creating... (2m26s elapsed)
azurerm_virtual_machine.master: Still creating... (2m30s elapsed)
azurerm_virtual_machine.master: Still creating... (2m36s elapsed)
azurerm_virtual_machine.master: Still creating... (2m40s elapsed)
azurerm_virtual_machine.master (remote-exec): Connecting to remote host via SSH...
azurerm_virtual_machine.master (remote-exec): Host: 104.214.27.167
azurerm_virtual_machine.master (remote-exec): User: ubuntu
azurerm_virtual_machine.master (remote-exec): Password: false
azurerm_virtual_machine.master (remote-exec): Private key: true
azurerm_virtual_machine.master (remote-exec): SSH Agent: true
^CInterrupt received. Gracefully shutting down...
azurerm_virtual_machine.master: Still creating... (2m46s elapsed)
azurerm_virtual_machine.master: Still creating... (2m50s elapsed)
azurerm_virtual_machine.master: Still creating... (2m56s elapsed)
azurerm_virtual_machine.master (remote-exec): Connecting to remote host via SSH...
azurerm_virtual_machine.master (remote-exec): Host: 104.214.27.167
azurerm_virtual_machine.master (remote-exec): User: ubuntu
azurerm_virtual_machine.master (remote-exec): Password: false
azurerm_virtual_machine.master (remote-exec): Private key: true
azurerm_virtual_machine.master (remote-exec): SSH Agent: true
azurerm_virtual_machine.master: Still creating... (3m0s elapsed)
azurerm_virtual_machine.master: Still creating... (3m6s elapsed)
azurerm_virtual_machine.master: Still creating... (3m10s elapsed)
azurerm_virtual_machine.master: Still creating... (3m16s elapsed)
And so on...
Expected Behavior
After pressing Ctrl+C, "Interrupt received. Gracefully shutting down..." shows, and terraform gracefully shuts down.
Actual Behavior
Terraform keeps reconnecting indefinitely until I press Ctrl+C second time and shutdown it ungracefully... probably loosing some of saved state.
Steps to Reproduce
- Write terraform configuration with invalid connection parameter (e.g. non-existing ip or user, I use azurem, but I think it does apply to other providers as well, not tested though)
- terraform apply
Ah yes, this is something we didn't get into 0.8, but we have a plan in place to fix it. Tagged since I think nothing else is tracking this.
The plan in place is to extend the ResourceProvider.Stop API to provisioners as well and to listen to those to stop these.