Which depots are down? OPS-2262

OpenShell basics · Easy · Investigate · about 20 min ·Linux

Lab machine

A private Linux machine with the problem already set up. Sessions last up to 60 minutes.
Ana Costa opened OPS-2262 at 07:31SEV-3

The public status page died in last night's upgrade. Customer service opens at 08:00 and needs to know which depots to warn callers about.

Each depot runs a small agent that answers /healthz with JSON like {"depot": "depot-3", "status": "ok"}. The status page used to collect them. Until it is fixed, you are the status page.

"I need a list I can read out: ok, degraded, or down. If a depot is half working I want to know, people will ask about their labels." (Ana)

ops/depots.txt lists all eight URLs. They do not all fail the same way.

Your task

Check every depot and write reports/depot-status.txt with one line per depot, for example depot-4 degraded. Use ok for a 200 whose status is ok, degraded for a 200 with any other status (after following redirects), and down for anything else, including no answer within 5 seconds.

On the machine

  • ops/depots.txt, eight health URLs
  • curl -i, curl -L, curl --max-time
  • The rules for each word in TICKET.md

Timeline

23:40Status page upgrade fails; the page shows a blank screen.
07:31Ana: "I need a list before the phones open."
08:00Phones open.

Done when

  1. `reports/depot-status.txt` has one line for each of the eight depots, in the form `depot-N status`.
  2. Every status is right, including depots that answer 200 without being ok.

Hints

Hint 1

Start with one depot: `curl -i` shows the status code and the body.

Hint 2

A 200 is not the whole answer. Read the JSON body as well.

Hint 3

`curl -L` follows redirects; `--max-time 5` gives up on a depot that never answers.

Hint 4

A loop over `ops/depots.txt` with `while read -r name url` saves typing eight commands.

Show the solution

Loop over ops/depots.txt with curl -sL --max-time 5 and -w '%{http_code}'. A non-200 or no answer is down; a 200 whose body has "status": "ok" is ok; any other 200 (degraded, or the maintenance page a redirect leads to) is degraded.