upbound / provider-terraform

A @crossplane provider for Terraform
Apache License 2.0
142 stars 56 forks source link

Catch signals when running terraform CLI commands #231

Closed bobh66 closed 8 months ago

bobh66 commented 8 months ago

Description of your changes

This change executes the terraform CLI command inside a wrapper that will terminate the CLI command if the context terminates via timeout or signal before the command finishes.

This will help with handling provider shutdown cleanly but it may also leave the Workspace in an unknown state if the running command was apply or destroy.

I have:

How has this code been tested

This code needs to soak in a test environment for a while but I wanted to get the changes reviewed in the mean time. I'll take the PR out of WIP when the changes have been tested locally.

Test procedure:

bobh66 commented 8 months ago

I ran the same tests and it does clean up the lock, however the crossplane.io/external-create-pending annotation is left on the Workspace so reconciliation will still be blocked until someone manually removes the annotation.

bobh66 commented 8 months ago

After we merge this PR, let's also consider putting the async mode of reconciliation for the provider into our roadmap.

How does async apply to running the CLI command? It seems like we would still be CPU-bound even if we are running the command async.