Skip to content

fix: warn when config pre-loading times out and make the timeout configurable#3287

Open
jtprogru wants to merge 1 commit into
devspace-sh:mainfrom
jtprogru:fix/config-preload-timeout-3213
Open

fix: warn when config pre-loading times out and make the timeout configurable#3287
jtprogru wants to merge 1 commit into
devspace-sh:mainfrom
jtprogru:fix/config-preload-timeout-3213

Conversation

@jtprogru

Copy link
Copy Markdown

What issue type does this pull request address?
/kind bug

What does this pull request do? Which issues does it resolve?
Fixes #3213

Config pre-loading in BuildRoot (used to register custom commands and dynamic pipeline flags) is cancelled after a hardcoded 10s timeout. When variable resolution takes longer (e.g. secrets fetched via an external CLI in the vars block), the failure was swallowed entirely: parseConfig returned the partial config with a nil error, the dynamic pipeline flags were silently never registered, and the command later died with an unrelated fatal unknown flag: --apps.

This PR surfaces the timeout and makes it configurable:

  • When pre-loading exceeds the timeout, DevSpace now prints a clear warning explaining that custom commands, pipeline flags and variables defined in the config might be unavailable for this run, and how to raise the timeout. On a fatal error such as unknown flag, the warning is printed right before the error so the failure is explained.
  • The timeout can be changed via a new DEVSPACE_PRELOAD_TIMEOUT environment variable: a duration such as 30s/1m, plain seconds such as 30, or 0 to disable the timeout entirely (the plain-seconds path guards against int64 overflow by treating overflowing values as "no timeout").
  • Pre-load log messages are deferred until the log-level flags are parsed, so --silent suppresses the warning and shell completions (__complete) stay silent instead of emitting the warning on every TAB press.
  • The underlying load error is preserved (Unwrap) and logged at debug level, so --debug reveals the real cause, e.g. fill variable BLAH with command 'sleep 12 && …': context deadline exceeded — previously it was discarded.
  • RawConfig.GetEnv now skips the variable resolver when its context is already cancelled, avoiding doomed command executions (spawn + immediate kill) for every env lookup after a timeout.
  • The pre-loading timeout is documented in the variables docs (From Command section), including the note that the variable must be set in the process environment because it is read before .env files are loaded.

Please provide a short message that should be published in the DevSpace release notes
Fixed an issue where slow variable resolution during config pre-loading caused confusing unknown flag errors; DevSpace now prints a clear warning and the timeout is configurable via DEVSPACE_PRELOAD_TIMEOUT (0 disables it).

What else do we need to know?
Verified manually against the reproduction from #3213 (a vars command sleeping 12s plus a pipeline flag): the default run now prints the warning before unknown flag: --apps; with DEVSPACE_PRELOAD_TIMEOUT=30s, =13 (plain seconds) or =0 the flag is registered and parsed correctly; --silent suppresses the warning; --debug shows the underlying cause; invalid values (abc, negative) warn and fall back to the 10s default; fast configs behave exactly as before. go test ./cmd, go vet and golangci-lint (repo config) pass with no new issues.

One known limitation kept out of scope: when the timeout does fire, pipeline commands still hard-fail on their dynamic flags — cobra rejects them before RunE. A deeper fix would be adopting the DisableFlagParsing + late-registration pattern that devspace run already uses (which is why devspace run survives a pre-load timeout), but that requires refactoring the shared RunPipelineCmd plumbing and seems better suited for a follow-up. Happy to open an issue for it or take a stab in a separate PR if you agree with the direction.

…igurable

Config pre-loading (used to register custom commands and dynamic pipeline
flags) was cancelled after a hardcoded 10s timeout. When variable resolution
took longer than that, the error was swallowed and commands later failed with
unrelated errors like 'unknown flag: --apps'.

- print a clear warning when pre-loading exceeds the timeout, explaining that
  custom commands, pipeline flags and variables from the config might be
  unavailable for this run
- defer pre-load log messages until the log level flags are parsed so --silent
  suppresses them, shell completions stay silent, and on fatal errors such as
  'unknown flag' the warning is flushed right before the error
- keep the underlying load error (Unwrap) and log it at debug level so --debug
  reveals the real cause, e.g. which variable timed out
- allow overriding the timeout via the DEVSPACE_PRELOAD_TIMEOUT environment
  variable (a duration such as 30s or plain seconds; 0 disables the timeout,
  and the plain-seconds path guards against int64 overflow)
- skip the variable resolver in RawConfig.GetEnv when its context is already
  cancelled to avoid doomed command executions after a timeout
- document the pre-loading timeout in the variables docs

Fixes devspace-sh#3213
@netlify

netlify Bot commented Jul 18, 2026

Copy link
Copy Markdown

Deploy Preview for devspace-docs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit b7632f9
🔍 Latest deploy log https://app.netlify.com/projects/devspace-docs/deploys/6a5bbc9bc124fc0008297a7e
😎 Deploy Preview https://deploy-preview-3287--devspace-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Variable resolution cannot exceed 10 seconds

1 participant