Repository navigation
fix(pm-stack): pm-git-sync owed redeploys — abort restart on dep failure, retry until success (#2391) - #2860
Conversation
…ure, retry until success (#2391) A failed dependency step no longer falls through to a restart: the redeploy is recorded in a durable state dir (PM_GIT_SYNC_STATE_DIR, default ~/.local/state/pm-git-sync) and retried on every run, including old==new runs, until dep step + restart succeed. Failed restarts are owed the same way. While any redeploy is owed the run exits non-zero with a FAIL line instead of a silent WARN + exit 0. Adds PM_GIT_SYNC_SYSTEMCTL seam and a stubbed harness (pm-git-sync.test.sh, 18 checks) covering dep-fail/retry/recovery and restart-fail/retry paths.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 44 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bf1d2e878b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| local subtree="$1" unit="$2" dep="$3" | ||
| ATTEMPTED="$ATTEMPTED$unit " | ||
| if [ -n "$dep" ]; then |
There was a problem hiding this comment.
Preserve owed dependency steps when newer source changes arrive
If an aggregator dependency update fails and the next pull changes only aggregator source files, the newly computed dependency step is empty. This attempt then skips the previously owed install, restarts the service, and clears its owed record despite the unresolved dependency failure; the projector has the same problem. Reproducing this with the test fixture produced exit 0 and removed the owed record while the Bun failure marker was still present. Merge any persisted dependency obligation into the new redeploy attempt before restarting.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 6d52033: attempt_redeploy now merges a persisted dependency obligation into the unit's next attempt — when the newly computed dep step is empty but an owed record exists, the owed dep step is loaded from the record and must succeed before any restart, and the record is only cleared by a fully successful attempt. Harness scenario 2b reproduces exactly your case (dep-fail owed, then a source-only aggregator pull with the failure marker still present): dep step is attempted, no restart occurs, owed record survives, exit non-zero. 23/23 harness checks pass.
| record_owed() { # <unit> <subtree> <dep-step-or-empty> | ||
| mkdir -p "$STATE_DIR" | ||
| printf '%s\n%s\n' "$2" "$3" >"$(owed_file "$1")" |
There was a problem hiding this comment.
Propagate failures to persist owed redeploys
If the state directory cannot be created or its record cannot be written, a failed redeploy is still discarded: callers suppress the failure from attempt_redeploy, and finish determines success solely by finding owed files. With a state path that cannot be created, a failed dependency install therefore produces exit 0 and a 'redeploys complete' message, and subsequent unchanged-HEAD runs never retry it. Check persistence failures and propagate them to the final exit status rather than treating an absent record as successful deployment.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 6d52033: record_owed now returns failure when the state dir cannot be created or the record cannot be written; both failure branches in attempt_redeploy set OWED_PERSIST_FAILED, and finish exits non-zero with a FAIL line when it is set — an absent record no longer reads as a successful deployment. Harness scenario 5 drives a failed redeploy with the state dir under a regular file (uncreatable): the run exits non-zero. 23/23 harness checks pass.
…rsistable owed records (#2391) Codex review on PR 2860, both findings fixed: - P1: a persisted dependency obligation is merged into the units next redeploy attempt, so a source-only pull no longer restarts past a still-unresolved dep install or clears its owed record. - P2: record_owed failures propagate via OWED_PERSIST_FAILED and fail the run in finish — an absent record no longer reads as success. Harness gains scenario 2b (source-only pull vs owed dep) and scenario 5 (unusable state dir); 23 checks pass, shellcheck clean.
Fixes #2391 (queue task 3977).
Problem
pm-git-sync.shlost redeploy failures twice: a failed dependency step only printed WARN and the service was restarted anyway onto code whose deps were never installed; and redeploys were computed only from theold..newdiff in the run where HEAD moved, so a failed redeploy was never retried and nothing recorded that one was owed — the script exited 0 throughout.Change (
pm-stack/scripts/pm-git-sync.sh)PM_GIT_SYNC_STATE_DIR, default${XDG_STATE_HOME:-~/.local/state}/pm-git-sync, one record per unit: subtree + dep step).old==newruns, until dep step + restart succeed; success clears the record.FAILjournal line naming the units and a non-zero exit — no more silent WARN + exit 0.PM_GIT_SYNC_SYSTEMCTLenv seam (mirrors the existingPM_GIT_SYNC_REPO/PM_GIT_SYNC_BUNseams) so the restart path is stub-able in tests.Tests
New harness
pm-stack/scripts/pm-git-sync.test.sh(stubbed git origin/clone + systemctl/bun seams), 18 checks, all passing on the laptop:shellcheck -S warningclean on both scripts.🤖 Queue worker lane E, task 3977
Need help on this PR? Tag
@codesmith-botwith what you need.