fix(agent): apply agent settings as they are when jobs are handed out #175

Merged
Sebi merged 1 commits from fix/agent-settings-after-poll into main 2026-11-29 15:40:23 +00:00
Owner

Fixes the CI failure of v0.16.0 in TestCheckerNetwork ("org checker reaching the private address once allowed").

Cause

  • agentJobs used the agent row read by the auth middleware at the start of its long poll (up to 20 s). Jobs handed out at the end of the poll carried the allow_private value from before any change made meanwhile, so a change only took effect one poll later. This bug already existed.
  • Since #174, the run after a monitor's first one comes on its phase, up to 1.5 intervals later instead of exactly one. Together with the stale run, the test's 20 s window was no longer enough.

Fix

  • When a poll returns jobs, the API reads the agent again before resolving them. That is one extra query per non-empty poll; empty polls are unchanged. An agent deleted during the poll gets 401.
  • The test waits 30 s: one run already handed out, then the next on the phase.

Tests

  • TestCheckerNetwork 3× in a row: green. The whole internal/api package and golangci-lint: green.

🤖 Generated with Claude Code

https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3

Fixes the CI failure of v0.16.0 in `TestCheckerNetwork` ("org checker reaching the private address once allowed"). ## Cause - `agentJobs` used the agent row read by the auth middleware at the start of its long poll (up to 20 s). Jobs handed out at the end of the poll carried the `allow_private` value from before any change made meanwhile, so a change only took effect one poll later. This bug already existed. - Since #174, the run after a monitor's first one comes on its phase, up to 1.5 intervals later instead of exactly one. Together with the stale run, the test's 20 s window was no longer enough. ## Fix - When a poll returns jobs, the API reads the agent again before resolving them. That is one extra query per non-empty poll; empty polls are unchanged. An agent deleted during the poll gets 401. - The test waits 30 s: one run already handed out, then the next on the phase. ## Tests - `TestCheckerNetwork` 3× in a row: green. The whole `internal/api` package and golangci-lint: green. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
Sebi added 1 commit 2026-11-29 15:37:18 +00:00
fix(agent): apply agent settings as they are when jobs are handed out
ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (pull_request) Waiting for needed jobs
ci / image (push) Skipped
ci / test (pull_request) Successful in 8m51s
ci / lint (pull_request) Successful in 10m46s
ci / build (pull_request) In progress
4246e37384
The jobs endpoint read the agent, and with it allow_private, before its
long poll of up to 20 seconds, so jobs handed out afterwards could carry
a setting changed in the meantime and the change only applied a poll
later. It now reads the agent again when the poll returns jobs.

TestCheckerNetwork also waits for two runs at most: the next run after a
monitor's first one is on its phase now, up to one and a half intervals
later.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
Sebi merged commit 61a50ee6f0 into main 2026-11-29 15:40:23 +00:00
Sebi deleted branch fix/agent-settings-after-poll 2026-11-29 15:40:27 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ZB-Server/uptimesebi#175