From da46d23386adeb9c2cfaf642fd05ee345d93f6e3 Mon Sep 17 00:00:00 2001 From: Anshul Gupta Date: Sun, 15 Nov 2026 04:49:27 +0000 Subject: [PATCH 1/3] air logs: print waiting status when stderr is not a terminal The "waiting for run to start" spinner degrades to nothing on a non-interactive stderr, so agents and CI saw no output at all while a run provisioned, and killed `air logs` as hung. Print each new waiting status as one stderr line instead. Co-authored-by: Isaac (cherry picked from commit 0a2112c46e3462e3a661a1313825a3e7a2e2683b) --- .nextchanges/air/logs-non-tty-status.md | 1 + cmd/air/logs_test.go | 3 +- cmd/air/logstream.go | 12 ++++++++ cmd/air/logstream_test.go | 41 +++++++++++++++++++++++++ 4 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 .nextchanges/air/logs-non-tty-status.md diff --git a/.nextchanges/air/logs-non-tty-status.md b/.nextchanges/air/logs-non-tty-status.md new file mode 100644 index 00000000000..0fde8b463fc --- /dev/null +++ b/.nextchanges/air/logs-non-tty-status.md @@ -0,0 +1 @@ +* `air logs` and `air run --watch` now print the waiting status (for example `Waiting for accelerator compute capacity...`) as a line on stderr when stderr is not a terminal, instead of printing nothing until the run produces logs. diff --git a/cmd/air/logs_test.go b/cmd/air/logs_test.go index 224df3e374b..6d18adb29f2 100644 --- a/cmd/air/logs_test.go +++ b/cmd/air/logs_test.go @@ -480,7 +480,8 @@ func TestLogsCommandRepeatsRunLinkAfterStreaming(t *testing.T) { assert.Contains(t, buf.String(), `"line":"step 2"`) assert.NotContains(t, buf.String(), "View job run at:") } else { - assert.Equal(t, "step 1\nstep 2\n\nView job run at: "+srv.URL+"/jobs/runs/777\n", buf.String()) + // stderr shares buf and is not a TTY, so the waiting status prints as a line. + assert.Equal(t, "Waiting for run to start (node 0)...\nstep 1\nstep 2\n\nView job run at: "+srv.URL+"/jobs/runs/777\n", buf.String()) } }) } diff --git a/cmd/air/logstream.go b/cmd/air/logstream.go index a431ecb6af1..79ed5e18b3e 100644 --- a/cmd/air/logstream.go +++ b/cmd/air/logstream.go @@ -393,6 +393,12 @@ func (st *bricklensStreamer) serverStatusMessage() string { return normalizeStatusMessage(out.AiRuntimeTaskOutput.StatusMessage) } +// logWaitingStatus prints a waiting status as a plain stderr line, for terminals +// that can't show the spinner. +func (st *bricklensStreamer) logWaitingStatus(msg string) { + cmdio.LogProgress(st.ctx, msg) +} + // reportStatusChange fires onStatusChange when the run's display state differs // from the last reported one. func (st *bricklensStreamer) reportStatusChange() { @@ -427,6 +433,12 @@ func (st *bricklensStreamer) run() (bool, error) { defer sp.Close() st.onFirstLog = sp.Close st.updateSpinner = sp.Update + // A non-interactive stderr (agents, CI, pipes) gets no spinner, which made + // a provisioning run look hung. Print each new waiting status as one line + // instead; the caller only calls updateSpinner when the text changes. + if cmdio.GetInteractiveMode(st.ctx) == cmdio.InteractiveModeNone { + st.updateSpinner = st.logWaitingStatus + } } firstIteration := true diff --git a/cmd/air/logstream_test.go b/cmd/air/logstream_test.go index 37ac5405d4d..5bb60caa344 100644 --- a/cmd/air/logstream_test.go +++ b/cmd/air/logstream_test.go @@ -436,6 +436,47 @@ func TestWaitingSpinnerText(t *testing.T) { newStreamer(t, "", "TERMINATED", "PENDING").waitingSpinnerText()) } +func TestStreamBricklensPrintsWaitingStatusWithoutTTY(t *testing.T) { + original := bricklensPollInterval + bricklensPollInterval = time.Millisecond + t.Cleanup(func() { bricklensPollInterval = original }) + + var runGets int + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch { + case strings.HasSuffix(r.URL.Path, "/logs"): + if runGets < 4 { + _, _ = w.Write([]byte(`{"log_records":[]}`)) + return + } + _, _ = w.Write([]byte(`{"log_records":[{"record_id":"a","time_unix_nano":20000000000,"body":"training"}]}`)) + case r.URL.Path == "/api/2.2/jobs/runs/get": + runGets++ + if runGets < 4 { + _, _ = w.Write([]byte(`{"run_id":1,"state":{"life_cycle_state":"PENDING"},"tasks":[{"run_id":2,"attempt_number":0}]}`)) + return + } + _, _ = w.Write([]byte(`{"run_id":1,"start_time":10000,"state":{"life_cycle_state":"TERMINATED","result_state":"SUCCESS"},"tasks":[{"run_id":2,"attempt_number":0}]}`)) + case r.URL.Path == "/api/2.2/jobs/runs/get-output": + _, _ = w.Write([]byte(`{"ai_runtime_task_output":{"status_message":"STATUS: Waiting for GPU capacity"}}`)) + default: + _, _ = w.Write([]byte(`{}`)) + } + })) + t.Cleanup(srv.Close) + + // Buffers are not TTYs, so this is the agent/CI case where no spinner renders. + var stdout, stderr bytes.Buffer + ctx := cmdio.InContext(t.Context(), cmdio.NewIO(t.Context(), flags.OutputText, nil, &stdout, &stderr, "", "")) + ok, err := streamBricklensLogs(ctx, newTestWorkspaceClient(t, srv.URL), &stdout, + logRequest{runID: 1, attempt: -1, tailLines: -1}, + logRunStatus{lifeCycleState: "PENDING", startTimeMs: 10_000}) + require.NoError(t, err) + assert.True(t, ok) + assert.Equal(t, "Waiting for GPU capacity...\n", stderr.String()) + assert.Contains(t, stdout.String(), "training") +} + func TestEmitLogLineJSON(t *testing.T) { var buf bytes.Buffer emitLogLine(&buf, logRequest{node: 2, jsonOutput: true}, "hello") From 5ce70fc5fccfe9211b64eff2b25e05d7ccb5ef65 Mon Sep 17 00:00:00 2001 From: Anshul Gupta Date: Mon, 16 Nov 2026 04:26:29 +0000 Subject: [PATCH 2/3] Add PR link to changelog fragment Co-authored-by: Isaac --- .nextchanges/air/logs-non-tty-status.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.nextchanges/air/logs-non-tty-status.md b/.nextchanges/air/logs-non-tty-status.md index 0fde8b463fc..97439059dfb 100644 --- a/.nextchanges/air/logs-non-tty-status.md +++ b/.nextchanges/air/logs-non-tty-status.md @@ -1 +1 @@ -* `air logs` and `air run --watch` now print the waiting status (for example `Waiting for accelerator compute capacity...`) as a line on stderr when stderr is not a terminal, instead of printing nothing until the run produces logs. +* `air logs` and `air run --watch` now print the waiting status (for example `Waiting for accelerator compute capacity...`) as a line on stderr when stderr is not a terminal, instead of printing nothing until the run produces logs. ([#7651](https://github.com/databricks/cli/pull/7651)) From d45082508a1af704aa5ded1ff55d8bcd89e21df6 Mon Sep 17 00:00:00 2001 From: Anshul Gupta Date: Mon, 16 Nov 2026 05:02:54 +0000 Subject: [PATCH 3/3] Point changelog fragment at #7657 Co-authored-by: Isaac --- .nextchanges/air/logs-non-tty-status.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.nextchanges/air/logs-non-tty-status.md b/.nextchanges/air/logs-non-tty-status.md index 97439059dfb..8e73b6ac45b 100644 --- a/.nextchanges/air/logs-non-tty-status.md +++ b/.nextchanges/air/logs-non-tty-status.md @@ -1 +1 @@ -* `air logs` and `air run --watch` now print the waiting status (for example `Waiting for accelerator compute capacity...`) as a line on stderr when stderr is not a terminal, instead of printing nothing until the run produces logs. ([#7651](https://github.com/databricks/cli/pull/7651)) +* `air logs` and `air run --watch` now print the waiting status (for example `Waiting for accelerator compute capacity...`) as a line on stderr when stderr is not a terminal, instead of printing nothing until the run produces logs. ([#7657](https://github.com/databricks/cli/pull/7657))