Pipefail: Make a Broken Pipeline Fail Loudly
MediumShell Scripting15-25 minA broken health check is at /root/case/health.broken.sh (kept for study — don't edit it). It should report a log HEALTHY (exit 0) only when the log contains the service marker, and fail with a non-zero status when it doesn't.
It doesn't: it exits 0 for both /root/case/good.log and /root/case/bad.log. Run it against each and see for yourself.
Your task: write a correct /root/scripts/health.sh that, like the broken one, takes the log file to check as its first argument (health.sh <logfile>). Grading runs your script against both logs — good.log must exit 0, bad.log must exit non-zero — and checks that the script enables pipefail. It also runs your script against a fresh good and bad log you haven't seen, at a different path, so decide from the file's contents, not its name. The marker and the two log paths come from /root/case/assignment.env. See /root/case/brief.txt.
- Reproduce the false-healthy result on the bad log
- Work out why the failure is being masked
- Write a health check that reports the bad log as unhealthy
- Keep the good log passing (exit 0)
Hands-on lab: you work on a real Linux box in your browser, graded on the machine's actual state.
