If I run:
gcloud run jobs execute foo --project myproj --region us-central1 --format json
It returns a big, beautiful data structure for the Execution resource that was generated in the cloud. This happens whether or not the execution ends up failing.
However, if I run:
gcloud run jobs execute foo --project myproj --region us-central1 --format json --wait
If the job fails, I get nothing – just a few lines of plain-text error reporting written to STDERR. Nothing structured that I can write tooling around.
X Creating execution... Task foo-8vn7q-task0 failed with message: The container exited with an error.
✓ Provisioning resources...
✓ Starting execution...
X Running execution... 0 / 1 complete
Executing job failed
ERROR: (gcloud.run.jobs.execute) The execution failed.
View details about this execution by running:
gcloud run jobs executions describe foo-8vn7q
Or visit https://console.cloud.google.com/run/jobs/executions/details/us-central1/foo-8vn7q/tasks?project=xxx
Why? Waiting longer should yield more data, not less. Why is gcloud punishing me for waiting? Why not still return the Execution record, but with the failure state recorded? (The same output produced by gcloud run jobs executions describe
after-the-fact.)
Futhermore… I’d be willing to have my tool compensate for this by, in the event of gcloud returning a non-zero exit code on execution, follow it up with a describe
command — if that command had a --wait
flag I could use that would block until job execution completes. But it doesn’t. So that just leaves polling.
In the meantime, I’m just going to have my tool disallow the --wait
flag for executions in order to avoid this situation entirely.