After a deploy, the health check fails intermittently. Your script must roll back automatically, but only if the failure persists. How?
IntermediateScenarioScenarios: deployments, user management and fleet operations
Answer
Situation read → A single failed probe during warm-up should not trigger rollback; sustained failure should.
What I'd do →
ok=0 fail=0
for _ in $(seq 1 30); do
if curl -fsS -o /dev/null --max-time 3 http://127.0.0.1:8080/readyz; then
ok=$((ok + 1)); fail=0
(( ok >= 5 )) && { echo "healthy"; exit 0; }
else
fail=$((fail + 1)); ok=0
(( fail >= 5 )) && break
fi
sleep 2
done
rollback "$previous"; exit 1
- Require 5 consecutive successes to pass and 5 consecutive failures to fail, within an overall deadline.
Why → Consecutive-count thresholds smooth out warm-up noise while still failing fast on real breakage.
Interview tip → Mention this mirrors Kubernetes successThreshold/failureThreshold and ALB healthy/unhealthy thresholds.
More on Scenarios: deployments, user management and fleet operations
Write the core of a deploy script with release directories, an atomic symlink switch and rollback.IntermediateDeploy to 10 servers behind an AWS ALB one at a time, removing each from the target group during its deploy. Outline the script.AdvancedImplement a blue/green switch on a single nginx host with a script.AdvancedOnboard 30 engineers: create accounts and install their SSH keys from their GitHub usernames, idempotently.IntermediateAn engineer leaves the company. Write the offboarding steps for Linux servers.IntermediateYou are asked to audit a server for risky accounts. What does your script check?Intermediate