From 22ae2677a8316713de62461d27f7471e2f17f951 Mon Sep 17 00:00:00 2001 From: "ben.hansen" Date: Thu, 12 Nov 2026 20:01:44 +0000 Subject: [PATCH 1/8] [CNXT-2599] Repeat run and logs links after streaming --- cmd/air/logs.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/cmd/air/logs.go b/cmd/air/logs.go index 949c0e21d36..417a220c889 100644 --- a/cmd/air/logs.go +++ b/cmd/air/logs.go @@ -7,10 +7,13 @@ import ( "io" "slices" "strconv" + "time" "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" + "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" + "github.com/databricks/cli/libs/log" "github.com/databricks/databricks-sdk-go" "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/databricks-sdk-go/service/iam" @@ -189,6 +192,9 @@ func runLogs(ctx context.Context, cmd *cobra.Command, req logRequest) error { } out := cmd.OutOrStdout() + if !req.jsonOutput { + defer printLogLinks(ctx, w, out, req) + } success, err := fetchLogs(ctx, w, out, req, status) if err != nil { if errors.Is(err, apierr.ErrResourceDoesNotExist) { @@ -242,3 +248,30 @@ func fetchLogs(ctx context.Context, w *databricks.WorkspaceClient, out io.Writer } return success, err } + +// printLogLinks leaves browser links below the streamed output, including on +// failure. Link enrichment is best-effort and cannot change the run's exit code. +func printLogLinks(ctx context.Context, w *databricks.WorkspaceClient, out io.Writer, req logRequest) { + renderer, colorOn := cmdio.NewRenderer(ctx, out) + p := newPalette(renderer) + runURL := dashboardURL(w.Config.Host, req.runID, 0) + fmt.Fprintln(out) + fmt.Fprintln(out, "View job run at: "+link(colorOn, p.blue, runURL, runURL)) + + ctx, cancel := context.WithTimeout(ctx, 2*time.Second) + defer cancel() + run, err := w.Jobs.GetRun(ctx, jobs.GetRunRequest{RunId: req.runID}) + if err != nil { + log.Debugf(ctx, "air: could not fetch run for final logs link: %v", err) + return + } + _, taskRunID, err := resolveLogAttempt(run, req.attempt) + if err != nil { + log.Debugf(ctx, "air: could not resolve task for final logs link: %v", err) + return + } + if ids := mlflowIDsForTask(ctx, w, taskRunID); ids != nil { + url := mlflowLogsURL(w.Config.Host, ids) + fmt.Fprintln(out, "View logs at: "+link(colorOn, p.blue, url, url)) + } +} From d0d4ad7de9475eadb7d599e935863eb6a45232f2 Mon Sep 17 00:00:00 2001 From: "ben.hansen" Date: Thu, 12 Nov 2026 20:02:17 +0000 Subject: [PATCH 2/8] Add release note --- .nextchanges/air/final-log-links.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 .nextchanges/air/final-log-links.md diff --git a/.nextchanges/air/final-log-links.md b/.nextchanges/air/final-log-links.md new file mode 100644 index 00000000000..291f8c014d2 --- /dev/null +++ b/.nextchanges/air/final-log-links.md @@ -0,0 +1 @@ +* Repeat run and logs links after AIR log streaming ends. ([#7571](https://github.com/databricks/cli/pull/7571)) From 88ac116af5a119b2affcf72b3716735c7159e2d3 Mon Sep 17 00:00:00 2001 From: "ben.hansen" Date: Thu, 12 Nov 2026 20:04:54 +0000 Subject: [PATCH 3/8] Limit final links to live log streams --- cmd/air/logs.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/air/logs.go b/cmd/air/logs.go index 417a220c889..1b143882483 100644 --- a/cmd/air/logs.go +++ b/cmd/air/logs.go @@ -192,7 +192,7 @@ func runLogs(ctx context.Context, cmd *cobra.Command, req logRequest) error { } out := cmd.OutOrStdout() - if !req.jsonOutput { + if !req.jsonOutput && !req.staticView && !status.terminal() { defer printLogLinks(ctx, w, out, req) } success, err := fetchLogs(ctx, w, out, req, status) From b4d9a2d384bc9ad607d4de3f41e531469fc1ae2a Mon Sep 17 00:00:00 2001 From: "ben.hansen" Date: Thu, 12 Nov 2026 20:06:14 +0000 Subject: [PATCH 4/8] Use workspace-host run links without an org hint --- cmd/air/logs.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/air/logs.go b/cmd/air/logs.go index 1b143882483..98e78444066 100644 --- a/cmd/air/logs.go +++ b/cmd/air/logs.go @@ -7,6 +7,7 @@ import ( "io" "slices" "strconv" + "strings" "time" "github.com/databricks/cli/cmd/root" @@ -254,7 +255,7 @@ func fetchLogs(ctx context.Context, w *databricks.WorkspaceClient, out io.Writer func printLogLinks(ctx context.Context, w *databricks.WorkspaceClient, out io.Writer, req logRequest) { renderer, colorOn := cmdio.NewRenderer(ctx, out) p := newPalette(renderer) - runURL := dashboardURL(w.Config.Host, req.runID, 0) + runURL := fmt.Sprintf("%s/jobs/runs/%d", strings.TrimRight(w.Config.Host, "/"), req.runID) fmt.Fprintln(out) fmt.Fprintln(out, "View job run at: "+link(colorOn, p.blue, runURL, runURL)) From f4653ef64682f15687b313d147eeee5a05bbb1de Mon Sep 17 00:00:00 2001 From: "ben.hansen" Date: Thu, 12 Nov 2026 21:42:28 +0000 Subject: [PATCH 5/8] Remove minor AIR output change release note --- .nextchanges/air/final-log-links.md | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .nextchanges/air/final-log-links.md diff --git a/.nextchanges/air/final-log-links.md b/.nextchanges/air/final-log-links.md deleted file mode 100644 index 291f8c014d2..00000000000 --- a/.nextchanges/air/final-log-links.md +++ /dev/null @@ -1 +0,0 @@ -* Repeat run and logs links after AIR log streaming ends. ([#7571](https://github.com/databricks/cli/pull/7571)) From 9e079b7061f234c3c6b84705ed8e9cc41c9e3320 Mon Sep 17 00:00:00 2001 From: "ben.hansen" Date: Thu, 12 Nov 2026 23:17:57 +0000 Subject: [PATCH 6/8] Repeat only the job run link after streaming --- cmd/air/logs.go | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/cmd/air/logs.go b/cmd/air/logs.go index 98e78444066..4672a70f258 100644 --- a/cmd/air/logs.go +++ b/cmd/air/logs.go @@ -8,13 +8,11 @@ import ( "slices" "strconv" "strings" - "time" "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/flags" - "github.com/databricks/cli/libs/log" "github.com/databricks/databricks-sdk-go" "github.com/databricks/databricks-sdk-go/apierr" "github.com/databricks/databricks-sdk-go/service/iam" @@ -194,7 +192,7 @@ func runLogs(ctx context.Context, cmd *cobra.Command, req logRequest) error { out := cmd.OutOrStdout() if !req.jsonOutput && !req.staticView && !status.terminal() { - defer printLogLinks(ctx, w, out, req) + defer printJobRunLink(ctx, out, w.Config.Host, req.runID) } success, err := fetchLogs(ctx, w, out, req, status) if err != nil { @@ -250,29 +248,11 @@ func fetchLogs(ctx context.Context, w *databricks.WorkspaceClient, out io.Writer return success, err } -// printLogLinks leaves browser links below the streamed output, including on -// failure. Link enrichment is best-effort and cannot change the run's exit code. -func printLogLinks(ctx context.Context, w *databricks.WorkspaceClient, out io.Writer, req logRequest) { +// printJobRunLink leaves the run link below the streamed output, including on failure. +func printJobRunLink(ctx context.Context, out io.Writer, host string, runID int64) { renderer, colorOn := cmdio.NewRenderer(ctx, out) p := newPalette(renderer) - runURL := fmt.Sprintf("%s/jobs/runs/%d", strings.TrimRight(w.Config.Host, "/"), req.runID) + runURL := fmt.Sprintf("%s/jobs/runs/%d", strings.TrimRight(host, "/"), runID) fmt.Fprintln(out) fmt.Fprintln(out, "View job run at: "+link(colorOn, p.blue, runURL, runURL)) - - ctx, cancel := context.WithTimeout(ctx, 2*time.Second) - defer cancel() - run, err := w.Jobs.GetRun(ctx, jobs.GetRunRequest{RunId: req.runID}) - if err != nil { - log.Debugf(ctx, "air: could not fetch run for final logs link: %v", err) - return - } - _, taskRunID, err := resolveLogAttempt(run, req.attempt) - if err != nil { - log.Debugf(ctx, "air: could not resolve task for final logs link: %v", err) - return - } - if ids := mlflowIDsForTask(ctx, w, taskRunID); ids != nil { - url := mlflowLogsURL(w.Config.Host, ids) - fmt.Fprintln(out, "View logs at: "+link(colorOn, p.blue, url, url)) - } } From d1bc4f6464b4ec2a8628a87dd98da2de12e56081 Mon Sep 17 00:00:00 2001 From: "ben.hansen" Date: Thu, 12 Nov 2026 23:24:45 +0000 Subject: [PATCH 7/8] Cover final AIR run links and add release note --- .nextchanges/air/final-log-links.md | 1 + cmd/air/logs_test.go | 31 +++++++++++++++++++++++++- cmd/air/run_watch_test.go | 34 ++++++++++++++++++++++------- 3 files changed, 57 insertions(+), 9 deletions(-) create mode 100644 .nextchanges/air/final-log-links.md diff --git a/.nextchanges/air/final-log-links.md b/.nextchanges/air/final-log-links.md new file mode 100644 index 00000000000..2ef18bb94b3 --- /dev/null +++ b/.nextchanges/air/final-log-links.md @@ -0,0 +1 @@ +* Repeat the Jobs run link after live log streaming ends. ([#7571](https://github.com/databricks/cli/pull/7571)) diff --git a/cmd/air/logs_test.go b/cmd/air/logs_test.go index 857339360f8..25e063fcc16 100644 --- a/cmd/air/logs_test.go +++ b/cmd/air/logs_test.go @@ -286,7 +286,7 @@ func TestLogsCommandPrintsGuidanceWhenStreamingIsInterrupted(t *testing.T) { err := cmd.RunE(cmd, []string{"5"}) require.ErrorIs(t, err, root.ErrAlreadyPrinted) - assert.Contains(t, buf.String(), "Streaming logs interrupted.") + assert.Contains(t, buf.String(), "View job run at: "+srv.URL+"/jobs/runs/5\n\nStreaming logs interrupted.") assert.Contains(t, buf.String(), "To check status:\ndatabricks air get 5 -p 'team profile'") assert.Contains(t, buf.String(), "To resume streaming logs:\ndatabricks air logs 5 -p 'team profile'") } @@ -340,3 +340,32 @@ func TestLogsPastRetryOfActiveRunIsStatic(t *testing.T) { // streamer must not re-poll (that is the loop this test guards against). assert.Equal(t, 1, getRunHits) } + +func TestLogsCommandRepeatsRunLinkAfterStreaming(t *testing.T) { + for _, result := range []string{"SUCCESS", "FAILED"} { + for _, output := range []flags.Output{flags.OutputText, flags.OutputJSON} { + t.Run(result+"/"+string(output), func(t *testing.T) { + srv := watchServer(t, result) + var buf bytes.Buffer + ctx := cmdio.InContext(t.Context(), cmdio.NewIO(t.Context(), output, nil, &buf, &buf, "", "")) + ctx = cmdctx.SetWorkspaceClient(ctx, newTestWorkspaceClient(t, srv.URL)) + cmd := withOutput(newLogsCommand(), output) + cmd.SetContext(ctx) + cmd.SetOut(&buf) + + err := cmd.RunE(cmd, []string{"777"}) + if result == "FAILED" { + require.ErrorIs(t, err, root.ErrAlreadyPrinted) + } else { + require.NoError(t, err) + } + if output == flags.OutputJSON { + 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()) + } + }) + } + } +} diff --git a/cmd/air/run_watch_test.go b/cmd/air/run_watch_test.go index 52a859de21b..471871ea02a 100644 --- a/cmd/air/run_watch_test.go +++ b/cmd/air/run_watch_test.go @@ -8,7 +8,9 @@ import ( "net/http" "net/http/httptest" "strings" + "sync/atomic" "testing" + "time" "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" @@ -18,11 +20,15 @@ import ( "github.com/stretchr/testify/require" ) -// watchServer serves submit, the auth probe, a terminal runs/get, and a single -// page of Bricklens logs — everything `air run --watch` touches after submit. +// watchServer serves submit, the auth probe, a RUNNING-to-terminal transition, +// and a page of Bricklens logs. // resultState is the terminal result the run reports (e.g. SUCCESS, FAILED). func watchServer(t *testing.T, resultState string) *httptest.Server { t.Helper() + oldPollInterval := bricklensPollInterval + bricklensPollInterval = time.Millisecond + t.Cleanup(func() { bricklensPollInterval = oldPollInterval }) + var runGets atomic.Int32 runGet := `{ "run_id": 777, "start_time": 1700000000000, @@ -35,12 +41,18 @@ func watchServer(t *testing.T, resultState string) *httptest.Server { case strings.HasSuffix(r.URL.Path, "/jobs/runs/submit"): _, _ = w.Write([]byte(`{"run_id": 777}`)) case r.URL.Path == "/api/2.2/jobs/runs/get": + if runGets.Add(1) == 1 { + _, _ = w.Write([]byte(`{"run_id":777,"start_time":1700000000000,"state":{"life_cycle_state":"RUNNING"},"tasks":[{"run_id":778,"attempt_number":0}]}`)) + return + } _, _ = w.Write([]byte(runGet)) case strings.HasPrefix(r.URL.Path, "/api/2.0/ai-training/workflows/by-run-id/"): - _, _ = w.Write([]byte(`{"log_records": [ - {"time_unix_nano": 1700000002000000000, "body": "step 2", "node_index": 0}, - {"time_unix_nano": 1700000001000000000, "body": "step 1", "node_index": 0} - ]}`)) + first := `{"time_unix_nano":1700000001000000000,"body":"step 1","node_index":0}` + second := `{"time_unix_nano":1700000002000000000,"body":"step 2","node_index":0}` + if r.URL.Query().Get("ascending") == "false" { + first, second = second, first + } + _, _ = fmt.Fprintf(w, `{"log_records":[%s,%s]}`, first, second) default: // Me() probe, workspace-id, SDK config discovery. _, _ = w.Write([]byte(`{"userName": "u@example.com", "workspace_id": 1}`)) @@ -122,7 +134,8 @@ compute: func TestRunWatchStreamsLogs(t *testing.T) { var buf bytes.Buffer - err := runWatchCmd(t, flags.OutputText, &buf, watchServer(t, "SUCCESS").URL) + srv := watchServer(t, "SUCCESS") + err := runWatchCmd(t, flags.OutputText, &buf, srv.URL) require.NoError(t, err) out := buf.String() @@ -137,6 +150,7 @@ func TestRunWatchStreamsLogs(t *testing.T) { assert.Contains(t, out, "───") // The submitted run's logs stream through, oldest-first. assert.Contains(t, out, "step 1\nstep 2") + assert.True(t, strings.HasSuffix(out, "\n\nView job run at: "+srv.URL+"/jobs/runs/777\n"), out) } func TestRunWatchMultinodeIdentifiesStreamedNode(t *testing.T) { @@ -162,6 +176,7 @@ func TestRunWatchJSONEmitsSubmittedThenLogs(t *testing.T) { assert.Contains(t, all, `"type":"LOG"`) assert.Contains(t, all, `"line":"step 1"`) assert.NotContains(t, all, "Monitoring run and streaming logs") + assert.NotContains(t, all, "View job run at:") // The last line is the closing terminal-status envelope carrying SUCCESS. assert.Contains(t, lines[len(lines)-1], `"status":"SUCCESS"`) assert.Contains(t, lines[len(lines)-1], `"run_id":"777"`) @@ -175,15 +190,18 @@ func TestRunWatchJSONFailedRunTerminalEnvelope(t *testing.T) { require.ErrorIs(t, err, root.ErrAlreadyPrinted) lines := strings.Split(strings.TrimSpace(buf.String()), "\n") assert.Contains(t, lines[len(lines)-1], `"status":"FAILED"`) + assert.NotContains(t, buf.String(), "View job run at:") } func TestRunWatchFailedRunExitsNonZero(t *testing.T) { var buf bytes.Buffer // A run that ends FAILED streams its logs but exits non-zero, surfaced as // ErrAlreadyPrinted (the output was already written). - err := runWatchCmd(t, flags.OutputText, &buf, watchServer(t, "FAILED").URL) + srv := watchServer(t, "FAILED") + err := runWatchCmd(t, flags.OutputText, &buf, srv.URL) require.ErrorIs(t, err, root.ErrAlreadyPrinted) assert.Contains(t, buf.String(), "step 1\nstep 2") + assert.True(t, strings.HasSuffix(buf.String(), "\n\nView job run at: "+srv.URL+"/jobs/runs/777\n"), buf.String()) } func TestHandleWatchResultPrintsProfileAwareResumeCommand(t *testing.T) { From 3ff3882c78522c529101234272fc486c3959c424 Mon Sep 17 00:00:00 2001 From: "ben.hansen" Date: Thu, 12 Nov 2026 23:43:21 +0000 Subject: [PATCH 8/8] Reuse submitted run URL in streaming footer --- cmd/air/format.go | 8 ++++++-- cmd/air/format_test.go | 1 + cmd/air/logs.go | 11 +++++++---- cmd/air/logs_test.go | 17 ++++++++++++++++- cmd/air/logstream.go | 2 ++ cmd/air/run.go | 1 + cmd/air/runsubmit.go | 6 ++---- 7 files changed, 35 insertions(+), 11 deletions(-) diff --git a/cmd/air/format.go b/cmd/air/format.go index 89e2420fd3b..20711a9c159 100644 --- a/cmd/air/format.go +++ b/cmd/air/format.go @@ -254,9 +254,13 @@ func roundMillisToSeconds(ms int64) int64 { // dashboardURL builds {host}/jobs/runs/{id}?o={workspace_id}, matching Python // (cli_entrypoint.py:1911). The ?o= workspace id deep-links to the right -// workspace on multi-workspace accounts. +// workspace on multi-workspace accounts. An unknown (zero) workspace ID omits it. func dashboardURL(host string, runID, workspaceID int64) string { - return fmt.Sprintf("%s/jobs/runs/%d?o=%d", strings.TrimRight(host, "/"), runID, workspaceID) + url := fmt.Sprintf("%s/jobs/runs/%d", strings.TrimRight(host, "/"), runID) + if workspaceID == 0 { + return url + } + return fmt.Sprintf("%s?o=%d", url, workspaceID) } // formatDuration turns a number of seconds into a compact human string such as diff --git a/cmd/air/format_test.go b/cmd/air/format_test.go index 7b4bbc80154..c76260d28cb 100644 --- a/cmd/air/format_test.go +++ b/cmd/air/format_test.go @@ -170,6 +170,7 @@ func TestDurationSeconds(t *testing.T) { func TestDashboardURL(t *testing.T) { // The ?o= workspace id and a trailing-slash-trimmed host, matching Python. assert.Equal(t, "https://example.test/jobs/runs/123?o=42", dashboardURL("https://example.test/", 123, 42)) + assert.Equal(t, "https://example.test/jobs/runs/123", dashboardURL("https://example.test/", 123, 0)) } func TestLatestAttemptNumber(t *testing.T) { diff --git a/cmd/air/logs.go b/cmd/air/logs.go index 4672a70f258..ea5c1407cfd 100644 --- a/cmd/air/logs.go +++ b/cmd/air/logs.go @@ -7,7 +7,6 @@ import ( "io" "slices" "strconv" - "strings" "github.com/databricks/cli/cmd/root" "github.com/databricks/cli/libs/cmdctx" @@ -192,7 +191,12 @@ func runLogs(ctx context.Context, cmd *cobra.Command, req logRequest) error { out := cmd.OutOrStdout() if !req.jsonOutput && !req.staticView && !status.terminal() { - defer printJobRunLink(ctx, out, w.Config.Host, req.runID) + runURL := req.runURL + if runURL == "" { + workspaceID, _ := strconv.ParseInt(w.Config.WorkspaceID, 10, 64) + runURL = dashboardURL(w.Config.Host, req.runID, workspaceID) + } + defer printJobRunLink(ctx, out, runURL) } success, err := fetchLogs(ctx, w, out, req, status) if err != nil { @@ -249,10 +253,9 @@ func fetchLogs(ctx context.Context, w *databricks.WorkspaceClient, out io.Writer } // printJobRunLink leaves the run link below the streamed output, including on failure. -func printJobRunLink(ctx context.Context, out io.Writer, host string, runID int64) { +func printJobRunLink(ctx context.Context, out io.Writer, runURL string) { renderer, colorOn := cmdio.NewRenderer(ctx, out) p := newPalette(renderer) - runURL := fmt.Sprintf("%s/jobs/runs/%d", strings.TrimRight(host, "/"), runID) fmt.Fprintln(out) fmt.Fprintln(out, "View job run at: "+link(colorOn, p.blue, runURL, runURL)) } diff --git a/cmd/air/logs_test.go b/cmd/air/logs_test.go index 25e063fcc16..240b1a57498 100644 --- a/cmd/air/logs_test.go +++ b/cmd/air/logs_test.go @@ -278,6 +278,7 @@ func TestLogsCommandPrintsGuidanceWhenStreamingIsInterrupted(t *testing.T) { var buf bytes.Buffer client := newTestWorkspaceClient(t, srv.URL) client.Config.Profile = "team profile" + client.Config.WorkspaceID = "42" ctx = cmdio.InContext(ctx, cmdio.NewIO(ctx, flags.OutputText, nil, &buf, &buf, "", "")) ctx = cmdctx.SetWorkspaceClient(ctx, client) cmd := withOutput(newLogsCommand(), flags.OutputText) @@ -286,7 +287,7 @@ func TestLogsCommandPrintsGuidanceWhenStreamingIsInterrupted(t *testing.T) { err := cmd.RunE(cmd, []string{"5"}) require.ErrorIs(t, err, root.ErrAlreadyPrinted) - assert.Contains(t, buf.String(), "View job run at: "+srv.URL+"/jobs/runs/5\n\nStreaming logs interrupted.") + assert.Contains(t, buf.String(), "View job run at: "+srv.URL+"/jobs/runs/5?o=42\n\nStreaming logs interrupted.") assert.Contains(t, buf.String(), "To check status:\ndatabricks air get 5 -p 'team profile'") assert.Contains(t, buf.String(), "To resume streaming logs:\ndatabricks air logs 5 -p 'team profile'") } @@ -369,3 +370,17 @@ func TestLogsCommandRepeatsRunLinkAfterStreaming(t *testing.T) { } } } + +func TestRunLogsPreservesSubmittedRunURL(t *testing.T) { + srv := watchServer(t, "SUCCESS") + var buf bytes.Buffer + ctx := cmdctx.SetWorkspaceClient(cmdio.MockDiscard(t.Context()), newTestWorkspaceClient(t, srv.URL)) + cmd := withOutput(&cobra.Command{}, flags.OutputText) + cmd.SetContext(ctx) + cmd.SetOut(&buf) + runURL := srv.URL + "/jobs/runs/777?o=42" + + err := runLogs(ctx, cmd, logRequest{runID: 777, runURL: runURL, attempt: -1, tailLines: -1}) + require.NoError(t, err) + assert.True(t, strings.HasSuffix(buf.String(), "\n\nView job run at: "+runURL+"\n"), buf.String()) +} diff --git a/cmd/air/logstream.go b/cmd/air/logstream.go index 11c03d86d47..a431ecb6af1 100644 --- a/cmd/air/logstream.go +++ b/cmd/air/logstream.go @@ -87,6 +87,8 @@ var errBricklensFeatureDisabled = errors.New("bricklens logs unavailable; fallin // same flags. windowMinutes and tailLines are mutually exclusive. type logRequest struct { runID int64 + // runURL preserves the URL already shown by air run --watch. + runURL string // node is the node index to fetch; node 0 always exists. node int // nodeSet distinguishes an explicit --node 0 from the default, so a download diff --git a/cmd/air/run.go b/cmd/air/run.go index 91c16a80aa2..eb87acadc82 100644 --- a/cmd/air/run.go +++ b/cmd/air/run.go @@ -223,6 +223,7 @@ field, pass its path to -h as a separate argument: maxRetries := cfg.maxRetries() req := logRequest{ runID: runID, + runURL: dashboardURL, attempt: -1, tailLines: -1, jsonOutput: jsonOut, diff --git a/cmd/air/runsubmit.go b/cmd/air/runsubmit.go index f01198d2b7a..56716493528 100644 --- a/cmd/air/runsubmit.go +++ b/cmd/air/runsubmit.go @@ -8,7 +8,6 @@ import ( "fmt" "net/http" "path" - "strconv" "strings" "time" "uuid" @@ -332,7 +331,7 @@ func stageRunArtifacts(ctx context.Context, launchWriter fileWriter, items []upl // payload, and submit it. It // returns the new run_id and its dashboard URL. showProgress enables the stderr // staging spinner (text mode only). -func submitWorkload(ctx context.Context, w *databricks.WorkspaceClient, cfg *runConfig, configPath, idempotencyKey string, showProgress bool) (runID int64, dashboardURL string, err error) { +func submitWorkload(ctx context.Context, w *databricks.WorkspaceClient, cfg *runConfig, configPath, idempotencyKey string, showProgress bool) (runID int64, runURL string, err error) { start := time.Now() var snap snapshotResult defer func() { logRunEvent(ctx, cfg, snap, runID, time.Since(start), err) }() @@ -446,8 +445,7 @@ func submitWorkload(ctx context.Context, w *databricks.WorkspaceClient, cfg *run return 0, "", err } - dashboardURL = strings.TrimRight(w.Config.Host, "/") + "/jobs/runs/" + strconv.FormatInt(runID, 10) - return runID, dashboardURL, nil + return runID, dashboardURL(w.Config.Host, runID, 0), nil } func submittedContainers(cfg *runConfig, funcDir string) []submittedContainer {