You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: warn when config pre-loading times out and make the timeout configurable
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#3213
Signed-off-by: Mikhail Savin <jtprogru@gmail.com>
// preloadTimeoutError is returned by parseConfig if pre-loading the config was
377
+
// cancelled because it took longer than the configured timeout
378
+
typepreloadTimeoutErrorstruct {
379
+
timeout time.Duration
380
+
errerror
381
+
}
382
+
383
+
func (e*preloadTimeoutError) Error() string {
384
+
returnfmt.Sprintf("pre-loading the config took longer than %s and was cancelled, which usually means resolving a variable or expression took too long. Custom commands, pipeline flags and variables defined in the config might be unavailable for this run. You can increase this timeout via the %s environment variable (0 disables it), e.g. %s=30s", e.timeout, DevSpacePreloadTimeoutEnv, DevSpacePreloadTimeoutEnv)
385
+
}
386
+
387
+
func (e*preloadTimeoutError) Unwrap() error {
388
+
returne.err
389
+
}
390
+
391
+
// preloadTimeout returns the timeout for pre-loading the config, 0 meaning no timeout
392
+
funcpreloadTimeout() time.Duration {
393
+
value:=os.Getenv(DevSpacePreloadTimeoutEnv)
394
+
ifvalue=="" {
395
+
returndefaultPreloadTimeout
396
+
}
397
+
398
+
timeout, err:=time.ParseDuration(value)
399
+
iferr!=nil {
400
+
// also allow specifying plain seconds, e.g. DEVSPACE_PRELOAD_TIMEOUT=30
401
+
seconds, convErr:=strconv.Atoi(value)
402
+
ifconvErr!=nil {
403
+
deferPreloadLog(logrus.WarnLevel, fmt.Sprintf("Invalid value %q for %s, falling back to %s: %v", value, DevSpacePreloadTimeoutEnv, defaultPreloadTimeout, err))
// converting to a duration would overflow; treat as no timeout
408
+
return0
409
+
}
410
+
timeout=time.Duration(seconds) *time.Second
411
+
}
412
+
iftimeout<0 {
413
+
deferPreloadLog(logrus.WarnLevel, fmt.Sprintf("Invalid value %q for %s, falling back to %s: timeout must not be negative", value, DevSpacePreloadTimeoutEnv, defaultPreloadTimeout))
Copy file name to clipboardExpand all lines: docs/pages/configuration/variables.mdx
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -73,6 +73,10 @@ vars:
73
73
args: ["rev-parse", "HEAD"]
74
74
```
75
75
76
+
:::warning Pre-Loading Timeout
77
+
Before executing a command, DevSpace pre-loads the config (including resolving variables from commands) to make custom commands and pipeline flags available. This pre-loading is limited to 10 seconds by default. If resolving all variables takes longer than that, DevSpace prints a warning and custom commands and pipeline flags defined in the config will be unavailable for this run. You can change this timeout via the `DEVSPACE_PRELOAD_TIMEOUT` environment variable, e.g. `DEVSPACE_PRELOAD_TIMEOUT=30s` (plain seconds such as `30` also work, and `0` disables the timeout entirely). Note that `DEVSPACE_PRELOAD_TIMEOUT` must be set in the process environment: it is read before `.env` files (loaded via `DEVSPACE_ENV_FILE`) and config variables are processed, so setting it there has no effect.
78
+
:::
79
+
76
80
77
81
### From User Input (Question)
78
82
DevSpace can also ask the user to provide a value for a variable and you can provide a custom question and configure other input attributes for the question:
0 commit comments