The job that only works by hand OPS-2246

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

Lab machine

A private Linux machine with the problem already set up. Sessions last up to 60 minutes.
Ivo Petrov opened OPS-2246 at 11:40SEV-3

The overnight manifest sync has failed three nights in a row, so depots start the day with yesterday's manifests. When Ivo runs it by hand, it works.

jobs/sync.sh pulls the overnight manifests from the tracking API. The scheduler runs it at 02:00. It has failed three nights running, and var/log/scheduler.log records the exit code but not the reason.

"I ran it three times this morning and it worked every time. It must be the scheduler." (Ivo)

bin/run-scheduled runs a job exactly the way the scheduler does: a bare environment, no login profile. Your interactive shell loads env.sh when it starts. The scheduler does not.

Your task

Reproduce the failure with bin/run-scheduled jobs/sync.sh, find the setting your shell has and the scheduler does not, and give the job that setting in jobs/sync.env. Do not edit the job or the scheduler wrapper.

On the machine

  • var/log/scheduler.log
  • jobs/sync.sh and bin/run-scheduled
  • env in your own shell, and env.sh

Timeline

Fri 02:00sync.sh exits 3 under the scheduler.
Sat 02:00Exits 3 again.
Sun 02:00Exits 3 again. Depots print labels from Saturday's manifests.
11:40Ivo: "Works fine for me."

Done when

  1. bin/run-scheduled jobs/sync.sh succeeds and reaches the API host your shell uses.
  2. jobs/sync.sh and bin/run-scheduled are unchanged.

Hints

Hint 1

Run bin/run-scheduled jobs/sync.sh and read the error.

Hint 2

env | grep API shows where your shell gets API_HOST.

Hint 3

bin/run-scheduled loads jobs/<name>.env if it exists.

Hint 4

echo "API_HOST=$API_HOST" > jobs/sync.env

Show the solution

Create jobs/sync.env containing API_HOST set to the value `echo $API_HOST` shows in your shell (and DEPOT=west if you like), then run bin/run-scheduled jobs/sync.sh to confirm.