feat: add lightspeed commands to skip update check for fast exit#7629
feat: add lightspeed commands to skip update check for fast exit#7629rajeshkamal5050 merged 7 commits intomainfrom
Conversation
Extensions using AzureDeveloperCLICredential spawn 'azd auth token' as a subprocess with a 10-second timeout. The background update check goroutine (60s timeout) was blocking process exit in main.go, causing 'signal: killed' errors when the update check was slow (e.g., after laptop wake, DNS stalls). This change adds a Lightspeed property to ActionDescriptorOptions that marks commands requiring fast exit. The update check goroutine is now started inside ExecuteWithAutoInstall after command identification — lightspeed commands skip it entirely, so the process exits immediately after producing output. Changes: - Add Lightspeed bool field to ActionDescriptorOptions - Propagate lightspeed to cobra annotations in CobraBuilder - Move fetchLatestVersion from main.go into startUpdateCheck() in auto_install.go - Start update check only after rootCmd.Find(), skip for lightspeed commands - Return ExecuteResult from ExecuteWithAutoInstall with LatestVersion channel - Mark 'auth token' as Lightspeed: true Fixes #7360 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR addresses slow background update checks blocking azd process exit for commands that must return quickly (notably azd auth token invoked by AzureDeveloperCLICredential with a 10s subprocess timeout). It introduces a per-command “lightspeed” marker so the update check is only started for commands where it’s acceptable to delay exit.
Changes:
- Add
LightspeedtoActionDescriptorOptionsand propagate it into Cobra command annotations. - Move update-check goroutine startup from
main.gointoExecuteWithAutoInstall, skipping it for lightspeed commands. - Update tests to validate annotation propagation and lightspeed detection behavior.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
cli/azd/main.go |
Removes early update-check startup; consumes ExecuteWithAutoInstall result and only waits for update-check when started. |
cli/azd/cmd/actions/action_descriptor.go |
Adds Lightspeed option to command descriptors. |
cli/azd/cmd/cobra_builder.go |
Propagates Lightspeed to cmd.Annotations["lightspeed"]. |
cli/azd/cmd/auth.go |
Marks auth token as a lightspeed command. |
cli/azd/cmd/auto_install.go |
Adds ExecuteResult, moves update-check logic here, starts it only after command identification and only for non-lightspeed commands. |
cli/azd/cmd/cobra_builder_test.go |
Adds unit test validating annotation propagation. |
cli/azd/cmd/auto_install_integration_test.go |
Updates tests for new return type and adds a lightspeed detection test. |
- Restore parse-error log for invalid AZD_SKIP_UPDATE_CHECK values - Accept context parameter in startUpdateCheck for tracing/cancellation - Set AZD_SKIP_UPDATE_CHECK in test to avoid real HTTP calls Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The channel is nil only for lightspeed commands (goroutine never starts). When AZD_SKIP_UPDATE_CHECK skips the check, the channel is closed without a value rather than being nil. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use --output unknown to fail fast before touching the credential/provider stack. The test only needs to verify IsLightspeed detection, not actual token acquisition. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Directly test the core behavioral change: lightspeed commands must have LatestVersion == nil (no goroutine started), non-lightspeed commands must have LatestVersion != nil (goroutine started, even when AZD_SKIP_UPDATE_CHECK short-circuits it). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Define AnnotationLightspeed = "azd.lightspeed" in cmd/actions package and reference it from cobra_builder.go, auto_install.go, and tests. Uses azd. namespace prefix to avoid collisions with extension annotations. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash: pwsh: WindowsPowerShell install MSI install Standalone Binary
MSI
Documentationlearn.microsoft.com documentationtitle: Azure Developer CLI reference
|
jongio
left a comment
There was a problem hiding this comment.
The core approach is solid - moving the update check after command identification and skipping it for lightspeed commands directly fixes the timeout issue from #7360.
Things to address:
-
fetchLatestVersion()in main.go (lines 153-188) is now dead code. The call was removed but the function definition wasn't.docs/design/azd-update.mdalso references it in two places (lines 54, 107). Both should be cleaned up. -
cspell-lint CI is failing (17 hits). Add "lightspeed" to
.vscode/cspell.yaml.
Description
Fixes #7360
Extensions using
AzureDeveloperCLICredentialspawnazd auth tokenas a subprocess with a 10-second timeout (hardcoded in the Go Azure SDK). The background update check goroutine inmain.gohad a 60-second timeout and was blocking process exit via<-latest, causingsignal: killederrors when the update check was slow (e.g., after laptop wake, DNS stalls, corporate proxy delays).Root Cause
When
azd auth tokenruns as a subprocess:main.go:65—fetchLatestVersiongoroutine launches an HTTP call to check for updatesmain.go:76— The token command runs and writes output in millisecondsmain.go:86—<-latestblocks process exit until the update check finishessignal: killedSolution
Add a
Lightspeedproperty toActionDescriptorOptionsthat marks commands requiring fast exit. The update check goroutine is now started insideExecuteWithAutoInstallafter command identification — lightspeed commands skip it entirely, so the process exits immediately after producing output.No duplicate command lists: the lightspeed flag is defined once in the command descriptor and automatically propagated via cobra annotations.
Changes
cmd/actions/action_descriptor.goLightspeed boolfieldcmd/cobra_builder.gocmd.Annotations["lightspeed"]cmd/auth.goauth tokenasLightspeed: truecmd/auto_install.goExecuteResultstruct;startUpdateCheck()helper; goroutine starts only for non-lightspeed commandsmain.gofetchLatestVersion; consumesExecuteResult.LatestVersionchannelTesting
Test_LightspeedAnnotation— Verifies annotation propagation from descriptor to cobra commandTestExecuteWithAutoInstall_LightspeedDetection— Verifiesauth tokenis detected as lightspeed,versionis notTestExecuteWithAutoInstall_ReturnsCommandErrorWithoutPanicForOutputFlags— Updated for new return type