GalleyBytes / terraform-operator

A Kubernetes CRD to handle terraform operations
http://tf.galleybytes.com
Apache License 2.0
364 stars 47 forks source link

threaded delete jobs #32

Closed isaaguilar closed 3 years ago

isaaguilar commented 3 years ago

Fixes #28

By wrapping the delete task in a go routine, it frees up the controller to work on the next item. However, now that it's threaded, the controller must do a query for resources before doing work on it. Tested this a few times with good results.

In the event that the controller is restarted in the middle of a thread, when the controller is back online, it will notice that a delete job is already running but doesn't do anything with it. In this case, the destroy job must be removed and the controller will recreate it. This case should not normally happen.

Also, the destroy job will also try to take care of orphaned apply job pods once they are complete.

isaaguilar commented 3 years ago

@jstrachan I've built an image isaaguilar/terraform-operator:v0.0.0 (digest: sha256:683f1fb7bf8b4fa8f0d2d279426960cac13b987195acc7c243f570aaa96c5f33) if you wanted to test this out.

I'm going to let the PR simmer while I try out more test cases.