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 (push) Skipped
ci / test (pull_request) Successful in 8m51s
ci / lint (pull_request) Successful in 10m46s
ci / build (pull_request) Successful in 10m26s
ci / image (pull_request) Successful in 5m8s

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
This commit is contained in:
Sebastian UnterschützandClaude Opus 5.5 committed 2026-11-29 16:37:08 +01:00
1 parent 9d1d6a2544
commit 4246e37384
2 files changed
+22 -2

No files matched your search

+19 -1
View File
@@ -227,7 +227,25 @@ func (s *Server) agentJobs(c *gin.Context) {
internalError(c, err) internalError(c, err)
return return
} }
jobs, orgs, err := s.resolveJobs(ctx, agentOf(c), entries) agent := agentOf(c)
if len(entries) > 0 {
// The long poll may have waited for a while: settings such as
// allow_private apply to the jobs as they are now.
err := s.db.Tx(ctx, tenant.System(), func(q *store.Queries) error {
var err error
agent, err = q.GetAgentByHash(ctx, HashToken(bearerToken(c)))
return err
})
if errors.Is(err, pgx.ErrNoRows) {
fail(c, http.StatusUnauthorized, "unauthenticated")
return
}
if err != nil {
internalError(c, err)
return
}
}
jobs, orgs, err := s.resolveJobs(ctx, agent, entries)
if err != nil { if err != nil {
internalError(c, err) internalError(c, err)
return return
+3 -1
View File
@@ -85,7 +85,9 @@ func TestCheckerNetwork(t *testing.T) {
} }
waitResult := func(id string, ok bool, what string) { waitResult := func(id string, ok bool, what string) {
t.Helper() t.Helper()
waitFor(t, 20*time.Second, what, func() bool { // Two runs at most: the one already handed out, then the next on
// the monitor's phase, up to one and a half intervals later.
waitFor(t, 30*time.Second, what, func() bool {
got, msg, seen := latestOf(owner, id) got, msg, seen := latestOf(owner, id)
return seen && got == ok && (ok || strings.Contains(msg, "non-public")) return seen && got == ok && (ok || strings.Contains(msg, "non-public"))
}) })