mirror of
https://gitea.com/gitea/runner.git
synced 2026-11-16 21:03:43 +00:00
fix: honor zero and empty values for fetch backoff and idle cleanup (#1418)
`fetch_interval_max: 0` is documented to disable polling backoff but became 5s. Zeros for `workdir_cleanup_age` and `idle_cleanup_interval` were ignored when they came from a YAML merge key or alias, so cleanup still ran, while an empty or null value turned cleanup off. These defaults are now seeded before the file is read, as `cache` already does, so a written 0 means off and an empty value keeps the default. _Written by Claude (Opus 5.5)._ Reviewed-on: https://gitea.com/gitea/runner/pulls/1418 Reviewed-by: bircni <[email protected]> Co-authored-by: silverwind <[email protected]>
This commit is contained in:
1 parent
891f3fde38
commit
1f2ea1b83a
2 files changed
+16
-37
No files matched your search
@@ -255,6 +255,7 @@ metrics:
|
||||
}
|
||||
|
||||
func TestLoadDefault_WorkdirCleanup(t *testing.T) {
|
||||
t.Setenv("EMPTY", "")
|
||||
for _, tc := range []struct {
|
||||
name, yaml string
|
||||
age, interval time.Duration
|
||||
@@ -263,6 +264,8 @@ func TestLoadDefault_WorkdirCleanup(t *testing.T) {
|
||||
{"configured interval", "\nrunner:\n idle_cleanup_interval: 45m\n", 24 * time.Hour, 45 * time.Minute},
|
||||
{"disabled", "\nrunner:\n workdir_cleanup_age: 0s\n idle_cleanup_interval: 0s\n", 0, 0},
|
||||
{"negative", "\nrunner:\n workdir_cleanup_age: -1s\n idle_cleanup_interval: -1s\n", -time.Second, -time.Second},
|
||||
{"disabled through a merge key", "\nx-base: &base\n workdir_cleanup_age: 0s\n idle_cleanup_interval: 0s\nrunner:\n <<: *base\n", 0, 0},
|
||||
{"empty keeps the default", "\nrunner:\n workdir_cleanup_age: ${EMPTY}\n idle_cleanup_interval:\n", 24 * time.Hour, 10 * time.Minute},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
cfg, err := LoadDefault(write(t, tc.yaml))
|
||||
@@ -441,11 +444,14 @@ func TestLoadDefault_ShippedConfigsChangeNothing(t *testing.T) {
|
||||
assert.Empty(t, hook.AllRecords())
|
||||
}
|
||||
|
||||
func TestLoadDefault_ClampsFetchTimeout(t *testing.T) {
|
||||
func TestLoadDefault_ClampsFetchTimeoutAndZeroFetchIntervalMaxDisablesBackoff(t *testing.T) {
|
||||
cfg, err := LoadDefault(write(t, `
|
||||
runner:
|
||||
fetch_timeout: 120s
|
||||
fetch_interval: 1s
|
||||
fetch_interval_max: 0s
|
||||
`))
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, RequestTimeout, cfg.Runner.FetchTimeout)
|
||||
assert.Equal(t, time.Second, cfg.Runner.FetchIntervalMax)
|
||||
}
|
||||
Reference in new issue
Block a user