Add polling to wait for post plan tasks to complete in remote backend #36655
+124
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Original Problem
It was seen that in some instances (Jira here) that using the remote backend with certain post plan tasks configured would cause the CLI to unceremoniously exit before confirmation could be given to apply runs in certain cases. This would occur due to these post plan tasks being in a running state when the backend checks if the run is confirmable.
To reproduce this behavior, set up a workspace (backed by a remote backend) with an OPA policy configured. When you perform an apply run, you'll see that the CLI exits before confirmation can be given (whether explicitly by the user or using auto-apply). Interestingly enough, I saw that enabling cost estimation avoided this erroneous behavior– since the processing of the cost estimate gave enough time for the OPA policy to complete before the confirmability of the run was checked.
Solution
Make the plan operation in the remote backend aware of post plan tasks, and have it wait for their completion before proceeding. The additions here are mostly copied from the analogous cloud backend methods, though I purposely omitted many of the features that you find in the cloud backend. The only text streamed to the console here would be notifications in the event of a task failing, or needing manual override– but the ability to do the override is not present here as it is in the cloud backend.
Target Release
1.12.x
CHANGELOG entry
The remote backend now notifies the user if post plan tasks have failed and/or need manual override.