71/71
Sign inSign up free

824. A Blue-Green Switch That Never Switches

hard 40 XP ~14 minHands-on lab

The app in /srv/lab/app has two release slots, releases/blue and releases/green. The symlink live points at the slot that serves traffic. bin/deploy.sh BUILD_DIR should put a build into the idle slot, check it with bin/health.sh COLOUR, and switch live to it.

Reports from the team:

  • after bin/deploy.sh /srv/lab/builds/v41, live still points at blue, and a strange green link appeared inside releases/blue,
  • files deleted in a new build still exist in the slot,
  • last week a build that failed its health check went live anyway,
  • cd /srv/lab/builds && /srv/lab/app/bin/deploy.sh v41 doesn't find the build.

Task

Fix bin/deploy.sh (don't change health.sh). It must use $APP_ROOT as the app directory when set (default /srv/lab/app), accept a relative or absolute BUILD_DIR, make the idle slot an exact copy of the build, and only if bin/health.sh succeeds switch live to that slot and print live: COLOUR. When the health check fails, live must stay as it was and the script exits non-zero. Deploying twice switches back to the first colour.

About this machine

Ubuntu 24.04 with no internet access. You are student with passwordless sudo. The grader checks the final state of the machine, not the commands you typed. Values like names and ports are generated for you.

Teaching or writing about this? Embed this lab on your page

TerminalNot started

Your machine is ready to start

A fresh, isolated Ubuntu machine boots in a few seconds with the task already set up.

No account needed: 3 of 3 free tries left. Guest machines last 30 minutes.