Repository navigation
Description
mcli --json batch status ALIAS JOBID treats a missing live metric as successful completion of the command: it cancels the metrics request and exits 0 without emitting a result. A job can exist before it has live metrics, so this can discard subsequent progress and completion events.
Confirmed with the real CLI and local Admin API fixtures on main at 18ea0a1ae04f69c7ae7c8f8b11329109ae7dcf71; the affected branches also exist in mcli 20261025. Suggested priority: P2.
In mainBatchStatus, a successful DescribeBatchJob selects the live metrics path. BatchJobs == nil or a missing Jobs[jobID] calls cancel() before printing anything. The main goroutine wakes on the context and returns nil. The persisted-status fallback is only considered when Describe reports no such job.
Reproduction protocol:
-
Return a successful YAML response from
GET /minio/admin/v3/describe-jobforjob(the local fixture usedversion: v1). -
Run
mcli --json batch status a jobagainst the fixture alias. -
Flush this event from
GET /minio/admin/v3/metrics, keeping the stream open:{"hosts":[],"aggregated":{"batchJobs":{"jobs":{}}},"final":false} -
Schedule a second event 200 ms later with
batchJobs.jobs.jobcontaining{"jobID":"job","jobType":"replicate","complete":true,"replicate":{"objects":2,"bytesTransferred":1024}}.
Actual: exit 0 and empty stdout/stderr after the first event. As a control, sending the complete event first prints {"status":"complete","metric":...} and exits 0. A separate nil-BatchJobs fixture also reproduces the silent exit, but the empty Jobs map is the server-native case supporting the queued-job scenario.
SILO saves the job before queueing it, and its metrics report returns an empty Jobs map when the requested job has no metrics entry. This supports a real pending window. The CLI failure is reproduced; a live queue-saturation reproduction was not performed, so its frequency under load is not established.
Represent pending/temporarily unavailable metrics explicitly. Continue observing an existing job, or consult an appropriate persisted/status source before deciding it has ended. Distinguish pending, missing/expired, unavailable, completed and failed states. Missing telemetry must not become an empty successful command. Retrying the status query must not create/restart a batch job.
Regression acceptance:
- An initial empty Jobs map followed by a completed/failed job is not cut off; the terminal result is emitted exactly once.
- Missing BatchJobs, an empty map, and a map containing only other job IDs are handled deliberately; human mode must also tolerate missing metrics.
- A truly missing/expired job and unavailable persisted status yield an explicit result/error rather than silent success or an unbounded unexplained wait.
- Completed/failed jobs, request/stream errors, stream closure and cancellation have bounded, tested behavior in JSON and human modes.
- Preserve the existing job result schema where practical and test actual CLI output/exit behavior.
This is a separate lifecycle issue from #49: the command waits, then cancels itself because metrics are absent. A synthetic final=true event with a nonterminal job was also explored during review, but is not being claimed here as an independently reproduced production defect.
Related: #52 covers site-resync status states; #54 is an independent arithmetic defect in the batch status renderer.
Activity
Fix client identity isolation and status reporting (pgsty#55)