flux-iac / tofu-controller

A GitOps OpenTofu and Terraform controller for Flux
https://flux-iac.github.io/tofu-controller/
Apache License 2.0
1.29k stars 137 forks source link

New Terraform objects in drift-detection-only mode hang in Initializing status #1371

Open hirenko-v opened 3 months ago

hirenko-v commented 3 months ago

It seems like new objects reconciliation are skipping any actions by design, so I am wondering how we could deploy new objects just in drift-detection mode.

https://github.com/flux-iac/tofu-controller/blob/main/controllers/tf_controller_drift_detect.go#L29-L33

I've done some tests and with the change introduced in the PR things going well. If it works for the community we could merge it.

dgem commented 3 weeks ago

Hi @hirenko-v, Reading the PR, it makes me think this is a bug than a by design - wouldn't expect this to be by design :)

This PR fixes the issue for new objects created in drift-detection-only mode. Current logic leaves Terraform CRD in Initializing status if it is created in drift detection mode.

A workaround requires manual intervention by setting approvePlan to something but not disable

The fix, assuming it works (I have not tested it and have nothing to validate it on, not a comment on the PR) then thanks :)

It would be good to have a test, so the behaviour doesn't change. not sure how much effort that would be. any thoughts ?

cheers Dan