Repository navigation
root: log host-metadata resolution through the command's logger - #7390
Merged
Merged
Conversation
The SDK's Config.EnsureResolved hands the host-metadata resolver context.Background(), so libs/hostmetadata logs through the process default logger and ignores any logger the command set on its context. MustWorkspaceClient and MustAccountClient now wrap the per-config resolver: it gets the SDK's context plus the command's logger and nothing else, so the request keeps the SDK's user agent and is not tied to the command's cancellation. The resolver is still built only when the SDK asks for it, through the registered factory, so the disk cache and test overrides still apply. When the factory returns nil, the wrapper falls back to the SDK's own fetch, as the SDK does. No output change for existing commands: their context logger is the one root installs as the process default (cmd/root/logger.go). A command that sets its own logger, such as a background auth resolution that should log only at debug level, now keeps host-metadata warnings out of its output. Co-authored-by: Isaac <no-reply@databricks.com>
anton-107
requested review from
andrewnester,
pietern,
rclarey,
simonfaltum and
tejaskochar-db
November 6, 2026 14:02
Collaborator
✅ Integration test reportCommit: 83016f4
Top 3 slowest tests (at least 2 minutes):
|
mihaimitrea-db
requested review from
mihaimitrea-db
and removed request for
tejaskochar-db
November 6, 2026 14:35
mihaimitrea-db
approved these changes
Nov 9, 2026
mihaimitrea-db
left a comment
Contributor
There was a problem hiding this comment.
Change looks good to me.
Collaborator
❌ Integration test reportCommit: fbfa9cb
40 interesting tests: 40 FAIL
Top 50 slowest tests (at least 2 minutes):
|
anton-107
added a commit
that referenced
this pull request
Nov 11, 2026
`aitools install` resolved auth for telemetry in PreRunE, before doing any work, so an unreachable workspace blocked the install for as long as the SDK retried. It now resolves auth in the background while the install runs and waits for it at most 3 s after the command started. Nothing is resolved when `DATABRICKS_CLI_DISABLE_TELEMETRY` is set (new `telemetry.Disabled`). ```diff aitools install - PreRunE: tryConfigureAuth - MustAnyClient(cmd) # blocks while the SDK retries host metadata - RunE: install skills + PreRunE: startTelemetryAuth # returns at once + if telemetry.Disabled → skip + go MustAnyClient(shadow cmd) # shares cmd's flags (--profile), not its context + RunE wrapper + runE: install skills # runs while auth resolves + pending.apply(cmd) # waits until start + 3 s, at most + finished → SetConfigUsed(cmd ctx) + not finished → no config, no upload root: telemetry.Upload ``` The shadow command logs through `debugOnlyHandler`, so a background warning such as `[hostmetadata] failed to fetch host metadata ...` shows only with `--debug` and does not interrupt the install's output or prompts. This relies on root's host-metadata resolver logging through the command's logger (#7390). A panic in the background resolution is recovered and logged at debug level; the install does not fail. Changelog fragment: `.nextchanges/cli/aitools-install-telemetry-auth.md`. Co-authored-by: Isaac <no-reply@databricks.com>
anton-107
added a commit
that referenced
this pull request
Nov 11, 2026
`aitools install` resolved auth for telemetry in PreRunE, before doing any work, so an unreachable workspace blocked the install for as long as the SDK retried. It now resolves auth in the background while the install runs and waits for it at most 3 s after the command started. Nothing is resolved when `DATABRICKS_CLI_DISABLE_TELEMETRY` is set (new `telemetry.Disabled`). ```diff aitools install - PreRunE: tryConfigureAuth - MustAnyClient(cmd) # blocks while the SDK retries host metadata - RunE: install skills + PreRunE: startTelemetryAuth # returns at once + if telemetry.Disabled → skip + go MustAnyClient(shadow cmd) # shares cmd's flags (--profile), not its context + RunE wrapper + runE: install skills # runs while auth resolves + pending.apply(cmd) # waits until start + 3 s, at most + finished → SetConfigUsed(cmd ctx) + not finished → no config, no upload root: telemetry.Upload ``` The shadow command logs through `debugOnlyHandler`, so a background warning such as `[hostmetadata] failed to fetch host metadata ...` shows only with `--debug` and does not interrupt the install's output or prompts. This relies on root's host-metadata resolver logging through the command's logger (#7390). A panic in the background resolution is recovered and logged at debug level; the install does not fail. Changelog fragment: `.nextchanges/cli/aitools-install-telemetry-auth.md`. Co-authored-by: Isaac <no-reply@databricks.com>
anton-107
added a commit
that referenced
this pull request
Nov 11, 2026
`aitools install` resolved auth for telemetry in PreRunE, before doing any work, so an unreachable workspace blocked the install for as long as the SDK retried. It now resolves auth in the background while the install runs and waits for it at most 3 s after the command started. Nothing is resolved when `DATABRICKS_CLI_DISABLE_TELEMETRY` is set (new `telemetry.Disabled`). ```diff aitools install - PreRunE: tryConfigureAuth - MustAnyClient(cmd) # blocks while the SDK retries host metadata - RunE: install skills + PreRunE: startTelemetryAuth # returns at once + if telemetry.Disabled → skip + go MustAnyClient(shadow cmd) # shares cmd's flags (--profile), not its context + RunE wrapper + runE: install skills # runs while auth resolves + pending.apply(cmd) # waits until start + 3 s, at most + finished → SetConfigUsed(cmd ctx) + not finished → no config, no upload root: telemetry.Upload ``` The shadow command logs through `debugOnlyHandler`, so a background warning such as `[hostmetadata] failed to fetch host metadata ...` shows only with `--debug` and does not interrupt the install's output or prompts. This relies on root's host-metadata resolver logging through the command's logger (#7390). A panic in the background resolution is recovered and logged at debug level; the install does not fail. Changelog fragment: `.nextchanges/cli/aitools-install-telemetry-auth.md`. Co-authored-by: Isaac <no-reply@databricks.com>
anton-107
added a commit
that referenced
this pull request
Nov 11, 2026
`aitools install` resolved auth for telemetry in PreRunE, before doing any work, so an unreachable workspace blocked the install for as long as the SDK retried. It now resolves auth in the background while the install runs and waits for it at most 3 s after the command started. Nothing is resolved when `DATABRICKS_CLI_DISABLE_TELEMETRY` is set (new `telemetry.Disabled`). ```diff aitools install - PreRunE: tryConfigureAuth - MustAnyClient(cmd) # blocks while the SDK retries host metadata - RunE: install skills + PreRunE: startTelemetryAuth # returns at once + if telemetry.Disabled → skip + go MustAnyClient(shadow cmd) # shares cmd's flags (--profile), not its context + RunE wrapper + runE: install skills # runs while auth resolves + pending.apply(cmd) # waits until start + 3 s, at most + finished → SetConfigUsed(cmd ctx) + not finished → no config, no upload root: telemetry.Upload ``` The shadow command logs through `debugOnlyHandler`, so a background warning such as `[hostmetadata] failed to fetch host metadata ...` shows only with `--debug` and does not interrupt the install's output or prompts. This relies on root's host-metadata resolver logging through the command's logger (#7390). A panic in the background resolution is recovered and logged at debug level; the install does not fail. Changelog fragment: `.nextchanges/cli/aitools-install-telemetry-auth.md`. Co-authored-by: Isaac <no-reply@databricks.com>
anton-107
added a commit
that referenced
this pull request
Nov 11, 2026
`aitools install` resolved auth for telemetry in PreRunE, before doing any work, so an unreachable workspace blocked the install for as long as the SDK retried. It now resolves auth in the background while the install runs and waits for it at most 3 s after the command started. Nothing is resolved when `DATABRICKS_CLI_DISABLE_TELEMETRY` is set (new `telemetry.Disabled`). ```diff aitools install - PreRunE: tryConfigureAuth - MustAnyClient(cmd) # blocks while the SDK retries host metadata - RunE: install skills + PreRunE: startTelemetryAuth # returns at once + if telemetry.Disabled → skip + go MustAnyClient(shadow cmd) # shares cmd's flags (--profile), not its context + RunE wrapper + runE: install skills # runs while auth resolves + pending.apply(cmd) # waits until start + 3 s, at most + finished → SetConfigUsed(cmd ctx) + not finished → no config, no upload root: telemetry.Upload ``` The shadow command logs through `debugOnlyHandler`, so a background warning such as `[hostmetadata] failed to fetch host metadata ...` shows only with `--debug` and does not interrupt the install's output or prompts. This relies on root's host-metadata resolver logging through the command's logger (#7390). A panic in the background resolution is recovered and logged at debug level; the install does not fail. Changelog fragment: `.nextchanges/cli/aitools-install-telemetry-auth.md`. Co-authored-by: Isaac <no-reply@databricks.com>
anton-107
added a commit
that referenced
this pull request
Nov 11, 2026
`aitools install` resolved auth for telemetry in PreRunE, before doing any work, so an unreachable workspace blocked the install for as long as the SDK retried. It now resolves auth in the background while the install runs and waits for it at most 3 s after the command started. Nothing is resolved when `DATABRICKS_CLI_DISABLE_TELEMETRY` is set (new `telemetry.Disabled`), and a run that logged no event does not wait. ```diff aitools install - PreRunE: tryConfigureAuth - MustAnyClient(cmd) # blocks while the SDK retries host metadata - RunE: install skills + PreRunE: startTelemetryAuth # returns at once + if telemetry.Disabled → skip + go MustAnyClient(shadow cmd) # shares cmd's flags (--profile), not its context + # SkipTokenRefresh: never refreshes an OAuth token + RunE wrapper + runE: install skills # runs while auth resolves + pending.apply(cmd) + no event logged → return + wait until start + 3 s, at most + succeeded → SetConfigUsed(cmd ctx) + failed or not finished → no config, no upload root: telemetry.Upload ``` The background resolution never refreshes an OAuth token. The process may exit before it finishes, and the server rotates the single-use refresh token, so an abandoned refresh could lose the new one and log the user out. The new `root.SkipTokenRefresh` makes `MustWorkspaceClient` and `MustAccountClient` use `auth.CredentialsWithoutRefresh`, whose databricks-cli strategy passes the new `u2m.WithoutRefresh`: the cached token is used only while it is valid, and an expired one fails auth, so nothing is uploaded. The shadow command logs through `debugOnlyHandler`, so a background warning such as `[hostmetadata] failed to fetch host metadata ...` shows only with `--debug` and does not interrupt the install's output or prompts. This relies on root's host-metadata resolver logging through the command's logger (#7390). A panic in the background resolution is recovered and logged at debug level; the install does not fail. Changelog fragment: `.nextchanges/cli/aitools-install-telemetry-auth.md`. Co-authored-by: Isaac <no-reply@databricks.com>
anton-107
added a commit
that referenced
this pull request
Nov 12, 2026
`aitools install` resolved auth for telemetry in PreRunE, before doing any work, so an unreachable workspace blocked the install for as long as the SDK retried. It now resolves auth in the background while the install runs and waits for it at most 3 s after the command started. Nothing is resolved when `DATABRICKS_CLI_DISABLE_TELEMETRY` is set (new `telemetry.Disabled`), and a run that logged no event does not wait. ```diff aitools install - PreRunE: tryConfigureAuth - MustAnyClient(cmd) # blocks while the SDK retries host metadata - RunE: install skills + PreRunE: startTelemetryAuth # returns at once + if telemetry.Disabled → skip + go MustAnyClient(shadow cmd) # shares cmd's flags (--profile), not its context + # SkipTokenRefresh: never refreshes an OAuth token + RunE wrapper + runE: install skills # runs while auth resolves + pending.apply(cmd) + no event logged → return + wait until start + 3 s, at most + succeeded → SetConfigUsed(cmd ctx) + failed or not finished → no config, no upload root: telemetry.Upload ``` The background resolution never refreshes an OAuth token. The process may exit before it finishes, and the server rotates the single-use refresh token, so an abandoned refresh could lose the new one and log the user out. The new `root.SkipTokenRefresh` makes `MustWorkspaceClient` and `MustAccountClient` use `auth.CredentialsWithoutRefresh`, whose databricks-cli strategy passes the new `u2m.WithoutRefresh`: the cached token is used only while it is valid, and an expired one fails auth, so nothing is uploaded. The shadow command logs through `debugOnlyHandler`, so a background warning such as `[hostmetadata] failed to fetch host metadata ...` shows only with `--debug` and does not interrupt the install's output or prompts. This relies on root's host-metadata resolver logging through the command's logger (#7390). A panic in the background resolution is recovered and logged at debug level; the install does not fail. Changelog fragment: `.nextchanges/cli/aitools-install-telemetry-auth.md`. Co-authored-by: Isaac <no-reply@databricks.com>
anton-107
added a commit
that referenced
this pull request
Nov 12, 2026
`aitools install` resolved auth for telemetry in PreRunE, before doing any work, so an unreachable workspace blocked the install for as long as the SDK retried. It now resolves auth in the background while the install runs and waits for it at most 3 s after the command started. Nothing is resolved when `DATABRICKS_CLI_DISABLE_TELEMETRY` is set (new `telemetry.Disabled`), and a run that logged no event does not wait. ```diff aitools install - PreRunE: tryConfigureAuth - MustAnyClient(cmd) # blocks while the SDK retries host metadata - RunE: install skills + PreRunE: startTelemetryAuth # returns at once + if telemetry.Disabled → skip + go MustAnyClient(shadow cmd) # shares cmd's flags (--profile), not its context + # SkipTokenRefresh: never refreshes an OAuth token + RunE wrapper + runE: install skills # runs while auth resolves + pending.apply(cmd) + no event logged → return + wait until start + 3 s, at most + succeeded → SetConfigUsed(cmd ctx) + failed or not finished → no config, no upload root: telemetry.Upload ``` The background resolution never refreshes an OAuth token. The process may exit before it finishes, and the server rotates the single-use refresh token, so an abandoned refresh could lose the new one and log the user out. The new `root.SkipTokenRefresh` makes `MustWorkspaceClient` and `MustAccountClient` use `auth.CredentialsWithoutRefresh`, whose databricks-cli strategy passes the new `u2m.WithoutRefresh`: the cached token is used only while it is valid, and an expired one fails auth, so nothing is uploaded. The shadow command logs through `debugOnlyHandler`, so a background warning such as `[hostmetadata] failed to fetch host metadata ...` shows only with `--debug` and does not interrupt the install's output or prompts. This relies on root's host-metadata resolver logging through the command's logger (#7390). A panic in the background resolution is recovered and logged at debug level; the install does not fail. Changelog fragment: `.nextchanges/cli/aitools-install-telemetry-auth.md`. Co-authored-by: Isaac <no-reply@databricks.com>
anton-107
added a commit
that referenced
this pull request
Nov 12, 2026
`aitools install` resolved auth for telemetry in PreRunE, before doing any work, so an unreachable workspace blocked the install for as long as the SDK retried. It now resolves auth in the background while the install runs and waits for it at most 3 s after the command started. Nothing is resolved when `DATABRICKS_CLI_DISABLE_TELEMETRY` is set (new `telemetry.Disabled`), and a run that logged no event does not wait. ```diff aitools install - PreRunE: tryConfigureAuth - MustAnyClient(cmd) # blocks while the SDK retries host metadata - RunE: install skills + PreRunE: startTelemetryAuth # returns at once + if telemetry.Disabled → skip + go MustAnyClient(shadow cmd) # shares cmd's flags (--profile), not its context + # SkipTokenRefresh: never refreshes an OAuth token + RunE wrapper + runE: install skills # runs while auth resolves + pending.apply(cmd) + no event logged → return + wait until start + 3 s, at most + succeeded → SetConfigUsed(cmd ctx) + failed or not finished → no config, no upload root: telemetry.Upload ``` The background resolution never refreshes an OAuth token. The process may exit before it finishes, and the server rotates the single-use refresh token, so an abandoned refresh could lose the new one and log the user out. The new `root.SkipTokenRefresh` makes `MustWorkspaceClient` and `MustAccountClient` use `auth.CredentialsWithoutRefresh`, whose databricks-cli strategy passes the new `u2m.WithoutRefresh`: the cached token is used only while it is valid, and an expired one fails auth, so nothing is uploaded. The shadow command logs through `debugOnlyHandler`, so a background warning such as `[hostmetadata] failed to fetch host metadata ...` shows only with `--debug` and does not interrupt the install's output or prompts. This relies on root's host-metadata resolver logging through the command's logger (#7390). A panic in the background resolution is recovered and logged at debug level; the install does not fail. Changelog fragment: `.nextchanges/cli/aitools-install-telemetry-auth.md`. Co-authored-by: Isaac <no-reply@databricks.com>
anton-107
added a commit
that referenced
this pull request
Nov 12, 2026
`aitools install` resolved auth for telemetry in PreRunE, before doing any work, so an unreachable workspace blocked the install for as long as the SDK retried. It now resolves auth in the background while the install runs and waits for it at most 3 s after the command started. Nothing is resolved when `DATABRICKS_CLI_DISABLE_TELEMETRY` is set (new `telemetry.Disabled`), and a run that logged no event does not wait. ```diff aitools install - PreRunE: tryConfigureAuth - MustAnyClient(cmd) # blocks while the SDK retries host metadata - RunE: install skills + PreRunE: startTelemetryAuth # returns at once + if telemetry.Disabled → skip + go MustAnyClient(shadow cmd) # shares cmd's flags (--profile), not its context + # SkipTokenRefresh: never refreshes an OAuth token + RunE wrapper + runE: install skills # runs while auth resolves + pending.apply(cmd) + no event logged → return + wait until start + 3 s, at most + succeeded → SetConfigUsed(cmd ctx) + failed or not finished → no config, no upload root: telemetry.Upload ``` The background resolution never refreshes an OAuth token. The process may exit before it finishes, and the server rotates the single-use refresh token, so an abandoned refresh could lose the new one and log the user out. The new `root.SkipTokenRefresh` makes `MustWorkspaceClient` and `MustAccountClient` use `auth.CredentialsWithoutRefresh`, whose databricks-cli strategy passes the new `u2m.WithoutRefresh`: the cached token is used only while it is valid, and an expired one fails auth, so nothing is uploaded. The shadow command logs through `debugOnlyHandler`, so a background warning such as `[hostmetadata] failed to fetch host metadata ...` shows only with `--debug` and does not interrupt the install's output or prompts. This relies on root's host-metadata resolver logging through the command's logger (#7390). A panic in the background resolution is recovered and logged at debug level; the install does not fail. Changelog fragment: `.nextchanges/cli/aitools-install-telemetry-auth.md`. Co-authored-by: Isaac <no-reply@databricks.com>
anton-107
added a commit
that referenced
this pull request
Nov 12, 2026
`aitools install` resolved auth for telemetry in PreRunE, before doing any work, so an unreachable workspace blocked the install for as long as the SDK retried. It now resolves auth in the background while the install runs and waits for it at most 3 s after the command started. Nothing is resolved when `DATABRICKS_CLI_DISABLE_TELEMETRY` is set (new `telemetry.Disabled`), and a run that logged no event does not wait. ```diff aitools install - PreRunE: tryConfigureAuth - MustAnyClient(cmd) # blocks while the SDK retries host metadata - RunE: install skills + PreRunE: startTelemetryAuth # returns at once + if telemetry.Disabled → skip + go MustAnyClient(shadow cmd) # shares cmd's flags (--profile), not its context + # SkipTokenRefresh: never refreshes an OAuth token + RunE wrapper + runE: install skills # runs while auth resolves + pending.apply(cmd) + no event logged → return + wait until start + 3 s, at most + succeeded → SetConfigUsed(cmd ctx) + failed or not finished → no config, no upload root: telemetry.Upload ``` The background resolution never refreshes an OAuth token. The process may exit before it finishes, and the server rotates the single-use refresh token, so an abandoned refresh could lose the new one and log the user out. The new `root.SkipTokenRefresh` makes `MustWorkspaceClient` and `MustAccountClient` use `auth.CredentialsWithoutRefresh`, whose databricks-cli strategy passes the new `u2m.WithoutRefresh`: the cached token is used only while it is valid, and an expired one fails auth, so nothing is uploaded. The shadow command logs through `debugOnlyHandler`, so a background warning such as `[hostmetadata] failed to fetch host metadata ...` shows only with `--debug` and does not interrupt the install's output or prompts. This relies on root's host-metadata resolver logging through the command's logger (#7390). A panic in the background resolution is recovered and logged at debug level; the install does not fail. Changelog fragment: `.nextchanges/cli/aitools-install-telemetry-auth.md`. Co-authored-by: Isaac <no-reply@databricks.com>
anton-107
added a commit
that referenced
this pull request
Nov 12, 2026
`aitools install` resolved auth for telemetry in PreRunE, before doing any work, so an unreachable workspace blocked the install for as long as the SDK retried. It now resolves auth in the background while the install runs and waits for it at most 3 s after the command started. Nothing is resolved when `DATABRICKS_CLI_DISABLE_TELEMETRY` is set (new `telemetry.Disabled`), and a run that logged no event does not wait. ```diff aitools install - PreRunE: tryConfigureAuth - MustAnyClient(cmd) # blocks while the SDK retries host metadata - RunE: install skills + PreRunE: startTelemetryAuth # returns at once + if telemetry.Disabled → skip + go MustAnyClient(shadow cmd) # shares cmd's flags (--profile), not its context + # SkipTokenRefresh: never refreshes an OAuth token + RunE wrapper + runE: install skills # runs while auth resolves + pending.apply(cmd) + no event logged → return + wait until start + 3 s, at most + succeeded → SetConfigUsed(cmd ctx) + failed or not finished → no config, no upload root: telemetry.Upload ``` The background resolution never refreshes an OAuth token. The process may exit before it finishes, and the server rotates the single-use refresh token, so an abandoned refresh could lose the new one and log the user out. The new `root.SkipTokenRefresh` makes `MustWorkspaceClient` and `MustAccountClient` use `auth.CredentialsWithoutRefresh`, whose databricks-cli strategy passes the new `u2m.WithoutRefresh`: the cached token is used only while it is valid, and an expired one fails auth, so nothing is uploaded. The shadow command logs through `debugOnlyHandler`, so a background warning such as `[hostmetadata] failed to fetch host metadata ...` shows only with `--debug` and does not interrupt the install's output or prompts. This relies on root's host-metadata resolver logging through the command's logger (#7390). A panic in the background resolution is recovered and logged at debug level; the install does not fail. Changelog fragment: `.nextchanges/cli/aitools-install-telemetry-auth.md`. Co-authored-by: Isaac <no-reply@databricks.com>
anton-107
added a commit
that referenced
this pull request
Nov 12, 2026
`aitools install` resolved auth for telemetry in PreRunE, before doing any work, so an unreachable workspace blocked the install for as long as the SDK retried. It now resolves auth in the background while the install runs and waits for it at most 3 s after the command started. Nothing is resolved when `DATABRICKS_CLI_DISABLE_TELEMETRY` is set (new `telemetry.Disabled`), and a run that logged no event does not wait. ```diff aitools install - PreRunE: tryConfigureAuth - MustAnyClient(cmd) # blocks while the SDK retries host metadata - RunE: install skills + PreRunE: startTelemetryAuth # returns at once + if telemetry.Disabled → skip + go MustAnyClient(shadow cmd) # shares cmd's flags (--profile), not its context + # SkipTokenRefresh: never refreshes an OAuth token + RunE wrapper + runE: install skills # runs while auth resolves + pending.apply(cmd) + no event logged → return + wait until start + 3 s, at most + succeeded → SetConfigUsed(cmd ctx) + failed or not finished → no config, no upload root: telemetry.Upload ``` The background resolution never refreshes an OAuth token. The process may exit before it finishes, and the server rotates the single-use refresh token, so an abandoned refresh could lose the new one and log the user out. The new `root.SkipTokenRefresh` makes `MustWorkspaceClient` and `MustAccountClient` use `auth.CredentialsWithoutRefresh`, whose databricks-cli strategy passes the new `u2m.WithoutRefresh`: the cached token is used only while it is valid, and an expired one fails auth, so nothing is uploaded. The shadow command logs through `debugOnlyHandler`, so a background warning such as `[hostmetadata] failed to fetch host metadata ...` shows only with `--debug` and does not interrupt the install's output or prompts. This relies on root's host-metadata resolver logging through the command's logger (#7390). A panic in the background resolution is recovered and logged at debug level; the install does not fail. Changelog fragment: `.nextchanges/cli/aitools-install-telemetry-auth.md`. Co-authored-by: Isaac <no-reply@databricks.com>
tedjt
pushed a commit
to tedjt/cli
that referenced
this pull request
Nov 12, 2026
Stacked on databricks#7467. Stacked on: aitools: log install-hint telemetry and bound telemetry uploads ## Summary `aitools install` resolved auth for telemetry in PreRunE, before doing any work, so an unreachable workspace blocked the install for as long as the SDK retried. It now resolves auth in the background while the install runs and waits for it at most 3 s after the command started. Nothing is resolved when `DATABRICKS_CLI_DISABLE_TELEMETRY` is set (new `telemetry.Disabled`), and a run that logged no event does not wait. ```diff aitools install - PreRunE: tryConfigureAuth - MustAnyClient(cmd) # blocks while the SDK retries host metadata - RunE: install skills + PreRunE: startTelemetryAuth # returns at once + if telemetry.Disabled → skip + go MustAnyClient(shadow cmd) # shares cmd's flags (--profile), not its context + # SkipTokenRefresh: never refreshes an OAuth token + RunE wrapper + runE: install skills # runs while auth resolves + pending.apply(cmd) + no event logged → return + wait until start + 3 s, at most + succeeded → SetConfigUsed(cmd ctx) + failed or not finished → no config, no upload root: telemetry.Upload ``` The background resolution never refreshes an OAuth token. The process may exit before it finishes, and the server rotates the single-use refresh token, so an abandoned refresh could lose the new one and log the user out. The new `root.SkipTokenRefresh` makes `MustWorkspaceClient` and `MustAccountClient` use `auth.CredentialsWithoutRefresh`, whose `databricks-cli` strategy passes the new `u2m.WithoutRefresh`: the cached token is used only while it is valid, and an expired one fails auth, so nothing is uploaded. The shadow command logs through `debugOnlyHandler`, so a background warning such as `[hostmetadata] failed to fetch host metadata ...` shows only with `--debug` and does not interrupt the install's output or prompts. This relies on root's host-metadata resolver logging through the command's logger (databricks#7390). A panic in the background resolution is recovered and logged at debug level; the install does not fail. Alternatives considered: resolving auth inside `telemetry.Upload` would serialize it after the install at exit and drop `MustAnyClient`'s account-client fallback and `--profile` handling. Bounding a synchronous PreRunE with the SDK's `HTTPTimeoutSeconds`/`RetryTimeoutSeconds` would still add that wait to every install before any work starts and keep the hostmetadata warning in its output; resolving in the background overlaps auth with the install instead. The deprecated `experimental aitools skills install` alias runs its own install command, so it now copies that command's context back, and the config resolved for telemetry reaches root's upload (before, the alias never uploaded). Changelog fragment: `.nextchanges/cli/aitools-install-telemetry-auth.md`. ## Evidence `aitools install --skills-only --scope=global --agents=claude-code`, skills served locally, fresh HOME and cache per run; before = parent branch binary, after = this branch's head: ```text DATABRICKS_HOST=https://localhost:1 (connection refused; the SDK retries) before: no output, killed by `timeout 120` after 120.0 s after: "Installed 1 skill.", exit 0 in 3.0 s (two runs) with DATABRICKS_CLI_DISABLE_TELEMETRY=1: 0.03 s DATABRICKS_HOST=https://unreachable.test (fails fast) before: "Warn: [hostmetadata] failed to fetch host metadata for https://unreachable.test, will skip for 1m0s" printed above the install output after: no hostmetadata line; exit 0 in 0.1 s ``` Tests at head, all pass locally on Linux and in CI on Linux, macOS and Windows: ```text cmd/aitools TestTelemetryAuth*: ResolvedConfigReachesTheUpload config reaches the upload, --profile seen FailedResolutionUploadsNothing a failed auth leaves no config NoEventDoesNotWait no event logged: no wait, no config SlowResolutionIsBounded command finishes < 2 s, no config FinishedResolutionSurvivesAnExpiredBudget budget 0, ×50 PanicDoesNotFailTheCommand SkippedWhenTelemetryDisabled resolver never called LogsStayOutOfNormalOutput background Warn/Error hidden; own Warn still prints LogsShowAtDebug background lines shown as Debug RunEWithoutPreRun acceptance/cmd/aitools/install-host-metadata no hostmetadata line normally; "Debug: [hostmetadata] ..." with --debug acceptance/cmd/aitools/telemetry/install PAT and databricks-cli with a valid cached token: the install event is uploaded databricks-cli with an expired cached token: no /oidc/v1/token request, no upload, cache unchanged libs/auth/u2m TestToken_WithoutRefresh valid and expiring-soon tokens returned, expired fails; no request libs/auth TestCredentialChainWithoutRefresh, TestCLICredentialsConfigure_NoRefresh cmd/root TestSkipTokenRefresh cmd/aitools TestLegacySkillsInstallKeepsTelemetryAuthConfig the alias's context gets the resolved config ``` ## Merge Danger **Door:** two-way No telemetry schema change, persisted state or config. A revert restores the blocking PreRunE. **Blast Radius:** `aitools install`. `root.SkipTokenRefresh` is new and only `aitools install` sets it; without it `MustWorkspaceClient`, `MustAccountClient` and `PersistentAuth.Token` behave as before. - **Telemetry loss:** an install uploads no event when its auth has not resolved by the later of the end of the install and 3 s after the command started. - **Slow but reachable workspace:** the upload still follows a finished resolution with its own timeout (`DATABRICKS_CLI_TELEMETRY_TIMEOUT`, default 3 s), so after a short install the end can take up to about 6 s. No run waits longer for auth than it did before. - **Unreachable workspace:** every `aitools install` run that logged an event lasts at least 3 s. Runs with nothing to upload (e.g. a flag-validation error) do not wait. The process exits while the SDK is still retrying, before libs/hostmetadata writes its negative-cache entry, so the next run probes the host again. - **Expired U2M token, no event:** an install whose cached `databricks-cli` access token has expired uploads no install event, because the background resolution does not refresh it. This is on purpose: a refresh that the exit can cut short is what can strand a rotated refresh token. The next command that authenticates refreshes the token as usual. Before, the install refreshed it in PreRunE and uploaded the event. - **Expired U2M token without an `auth_type`:** with no `auth_type` (e.g. `DATABRICKS_HOST` from the environment, or a hand-written profile), the SDK chain skips a strategy whose dry run fails, so an expired token moves on to the strategies after `databricks-cli` (metadata service, OIDC, Azure, Google). If one succeeds, e.g. `az` logged in on an Azure host, the event is uploaded with that identity. The default chain would have refreshed and stopped at `databricks-cli`. - **Warnings that can still print:** with the cache off or unusable and the `databricks-cli` strategy, `libs/auth` `ToOAuthArgument` looks up host metadata outside the command's logger; SDK warnings logged on its own `context.Background()` (e.g. missing `oidc_endpoint`) are not filtered either. - **Platforms:** CI runs the tests above on Linux, macOS and Windows; the timings under Evidence were measured on Linux only. This pull request and its description were written by Isaac. Co-authored-by: Isaac <no-reply@databricks.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Host-metadata resolution ignores the logger on the command's context. The SDK's
Config.EnsureResolvedcalls the resolver withcontext.Background(), solibs/hostmetadataalways logs through the process default logger. For most commands you can't tell, because root installs the command's logger as the process default too (cmd/root/logger.go). It does matter when code puts a different logger on the context. For example, work that runs in the background can use a logger that turns its warnings into debug lines. Today, when the host can't be reached, this warning still goes to the user's terminal in the middle of the command's output:The fix gives the config a resolver that brings along the command's logger:
libs/hostmetadatadisk cache and test overrides still apply, and configs with no host build no resolver. When no package registers a factory, it falls back to the SDK's own fetch, as the SDK does.Evidence
New test
TestMustClientResolvesHostMetadataWithCommandLogger(workspace and account clients):auth.go, run throughgo test -overlay):TestMustWorkspaceClientWithoutHostBuildsNoHostMetadataResolverpasses on main too. It is a guard: it fails if the CLI builds the resolver for every client attempt instead of only when the SDK asks for it.go test ./acceptance -run 'TestAccept/(auth|cmd)/'passes with no changes to the expected-output files. That confirms the host-metadata request and the command output are unchanged.Merge Danger
Door: two-way
One commit, with no state, config, or telemetry change. Revert to undo.
Blast Radius: wide
MustWorkspaceClientandMustAccountClientrun for every workspace and account command, so every host-metadata resolution on these configs now goes through the new resolver. We expect no output change, because the command's logger is the process default logger. Commands that load a bundle build their client withb.WorkspaceClientE, which replacescfg, so those commands keep the old behavior. Tested on Linux and macOS. The change has no platform-specific code.This pull request and its description were written by Isaac.