fix: roll the API out without cutting off checkers
ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / test (pull_request) Canceled after 4m25s
ci / lint (pull_request) Canceled after 4m26s
ci / build (pull_request) Canceled after 0s
ci / image (pull_request) Canceled after 0s
ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / test (pull_request) Canceled after 4m25s
ci / lint (pull_request) Canceled after 4m26s
ci / build (pull_request) Canceled after 0s
ci / image (pull_request) Canceled after 0s
Checkers long-poll the API for up to 25 seconds, longer than a shutdown waits for requests, so a rollout cut their polls off (GOAWAY, timeouts). A draining API now ends long polls within about a second, empty, and the checker's next poll reaches another instance. The chart rolls the API and status page servers one pod at a time with maxUnavailable 0, and a new pod serves for 5 seconds before an old one goes, so the ingress has picked it up. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
1 parent
a6bc50b39d
commit
963c677e1c
7 files changed
+95
-5
No files matched your search
+24
-3
@@ -32,7 +32,9 @@ const (
|
||||
ctxAgent = "api.agent"
|
||||
ctxInstance = "api.instance"
|
||||
maxJobWait = 25 * time.Second
|
||||
maxJobBatch = 200
|
||||
// drainingPollHold is how long a draining instance still holds a poll.
|
||||
drainingPollHold = time.Second
|
||||
maxJobBatch = 200
|
||||
)
|
||||
|
||||
func (s *Server) mountAgentAPI(r gin.IRouter) {
|
||||
@@ -197,8 +199,27 @@ func (s *Server) agentJobs(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
wait := min(time.Duration(req.WaitMS)*time.Millisecond, maxJobWait)
|
||||
entries, err := s.sched.Take(ctx, instance, min(req.Max, maxJobBatch), wait)
|
||||
if err != nil && ctx.Err() == nil {
|
||||
// A draining instance ends long polls within a second or so, empty, so
|
||||
// the shutdown is not held up and the checker's next poll reaches
|
||||
// another instance. It still holds them that second, so checkers that
|
||||
// poll again at once do not spin against it.
|
||||
pollCtx, stop := context.WithCancel(ctx)
|
||||
defer stop()
|
||||
if s.draining != nil {
|
||||
go func() {
|
||||
select {
|
||||
case <-s.draining:
|
||||
select {
|
||||
case <-time.After(drainingPollHold):
|
||||
case <-pollCtx.Done():
|
||||
}
|
||||
stop()
|
||||
case <-pollCtx.Done():
|
||||
}
|
||||
}()
|
||||
}
|
||||
entries, err := s.sched.Take(pollCtx, instance, min(req.Max, maxJobBatch), wait)
|
||||
if err != nil && pollCtx.Err() == nil {
|
||||
internalError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user