fix: re-sync PrefectAutomation every reconcile for continuous self-heal#298
Merged
mitchnielsen merged 2 commits intoJul 9, 2026
Merged
Conversation
UpdateAutomationStatus stamped Status.LastSyncTime, so needsSync short-circuited on a 10-minute drift timer and didn't re-check Prefect in between. A manual edit or delete of the automation in Prefect wasn't reconciled until the drift window elapsed or the operator restarted. PrefectDeployment never persists LastSyncTime, so needsSync's nil check makes it reconcile against Prefect every pass and self-heal continuously. Match that: stop stamping LastSyncTime on PrefectAutomation (needsSync is otherwise unchanged). syncWithPrefect is idempotent, so re-running it each pass is safe. Tests: UpdateAutomationStatus leaves LastSyncTime nil; needsSync returns true in steady state. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
b305be7 to
f9a2dbf
Compare
mitchnielsen
approved these changes
Jul 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
PrefectAutomationpersistedStatus.LastSyncTime, soneedsSyncshort-circuited on a 10-minute drift timer and never re-checked Prefect in between reconciles. A manual edit or delete of the automation in the Prefect UI/API was not reconciled back until the drift window elapsed or the operator restarted.PrefectDeploymentreconciles against Prefect on every pass (its status carries noLastSyncTime), so it self-heals out-of-band changes continuously. This alignsPrefectAutomationwith that behavior:needsSyncnow returnstrueeach reconcile.syncWithPrefectis idempotent (update-in-place), so re-running it every pass is safe.Why it was observable
With the drift gate, a deleted automation showed only the
Reconcilingdebug line every ~10s and never came back until a restart — even though the CR wasReady. After this change the controller re-checks each loop and re-applies desired state.Relationship to #297
Complementary. #297 makes the delete case recreate (surfaces a 404 on update as a sentinel → recreate). This PR fixes the cadence so that recreate (and any drift/edit correction) happens within one requeue interval instead of only on the 10-minute drift. Together they give prompt, continuous self-heal. This PR is orthogonal to #297 (it does not touch
syncWithPrefect/UpdateAutomation) and can merge independently.Test
Adds
TestAutomationNeedsSync— a unit test assertingneedsSyncreturnstruein steady state (id set, spec hash unchanged, generation observed, just synced), which wasfalsebefore.Related to #294, #297.