Fix scheduler cleanup edge cases
Some checks failed
ci / openapi (push) Failing after 6s
ci / agent (push) Failing after 5s
ci / server (push) Failing after 7s
ci / stack-smoke (push) Has been skipped
ci / web (push) Failing after 6s

This commit is contained in:
Stanislav Rossovskii
2026-06-23 20:04:08 +04:00
parent a94e0deaba
commit 762c48e96b
5 changed files with 69 additions and 20 deletions

View File

@@ -217,7 +217,7 @@ func (c *Config) Validate() error {
return fmt.Errorf("check %q: timeout must be > 0", ch.ID)
}
if ch.Interval.Duration < 0 {
return fmt.Errorf("check %q: interval must be > 0", ch.ID)
return fmt.Errorf("check %q: interval must not be negative", ch.ID)
}
ch.Cron = strings.TrimSpace(ch.Cron)
hasInterval := ch.Interval.Duration > 0

View File

@@ -123,6 +123,29 @@ func TestValidateCheckScheduleChoice(t *testing.T) {
}
}
func TestValidateNegativeIntervalMessage(t *testing.T) {
_, err := Load(writeTmp(t, `
agent_id = "host-1"
state_dir = "/tmp/x"
[server]
enabled = true
url = "http://localhost"
[[checks]]
id = "c1"
command = "true"
interval = "-1s"
timeout = "5s"
`))
if err == nil {
t.Fatal("expected negative interval error")
}
if !strings.Contains(err.Error(), "interval must not be negative") {
t.Fatalf("unexpected error: %v", err)
}
}
func TestLoadResourceLimits(t *testing.T) {
c, err := Load(writeTmp(t, `
agent_id = "host-1"