Skip to content

fix: healthcheck.sh exits prematurely under set -e (#302)#303

Open
Nathan Schram (nathanschram) wants to merge 1 commit intodevfrom
fix/healthcheck-counter-set-e
Open

fix: healthcheck.sh exits prematurely under set -e (#302)#303
Nathan Schram (nathanschram) wants to merge 1 commit intodevfrom
fix/healthcheck-counter-set-e

Conversation

@nathanschram
Copy link
Copy Markdown
Member

Summary

  • pass()/fail() used ((var++)) which returns the pre-increment value — on first call (var=0) that trips set -e and the script exits after the first check. Switched to explicit $((var + 1)) assignment.
  • Error-log count piped journalctl through grep -c ., counting -- No entries -- as a match (false positive on clean systems). Now uses grep -vc '^-- ' to drop meta lines.

Fixes #302.

Test plan

  • Ran scripts/healthcheck.sh --version 0.35.1rc5 against live staging (post rc5 install) — 5 passed, 0 failed, exit 0.
  • Ran the no-errors path (clean logs, expected version match).
  • Confirm no regression for the FAIL paths — if staging ever emits an ERROR log within 60s of restart, the check should still flag it (logic unchanged apart from meta-line filtering).

🤖 Generated with Claude Code

Two bugs in scripts/healthcheck.sh made post-deploy health checks unusable:

1. pass()/fail() used `((var++))` which returns the pre-increment value.
   On first call (var=0) that trips `set -e`, so only the first check ever
   ran and the script always exited 1. Switched to explicit assignment.

2. The error-log count piped journalctl through `grep -c .`, which counts
   journalctl's `-- No entries --` meta line as a match, producing a
   false-positive "1 ERROR-level log entries in last 60s" on clean
   systems. Now filters meta lines with `grep -vc '^-- '`.

Verified with `scripts/healthcheck.sh --version 0.35.1rc5` on staging:
all 5 checks run, exit 0.

Closes #302

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 14, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: dce32241-21df-4c06-8220-ff3bb7b8d832

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/healthcheck-counter-set-e

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant