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
@@ -0,0 +1,34 @@
|
||||
package api_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
|
||||
"git.zb-server.de/ZB-Server/uptimesebi/internal/agentapi"
|
||||
)
|
||||
|
||||
func TestLongPollsEndWhenDraining(t *testing.T) {
|
||||
e := newEnv(t)
|
||||
tok, _ := e.platformChecker(t, uniq("eu-"))
|
||||
drain := make(chan struct{})
|
||||
e.api.EndLongPollsOn(drain)
|
||||
client := agentapi.NewClient(e.srv.URL, tok, uuid.New(), "test").WithHTTPClient(e.srv.Client())
|
||||
|
||||
go func() { time.Sleep(300 * time.Millisecond); close(drain) }()
|
||||
start := time.Now()
|
||||
jobs, err := client.Jobs(context.Background(), 10, 20*time.Second)
|
||||
if err != nil || len(jobs) != 0 {
|
||||
t.Fatalf("Jobs() while draining = %v, %v; want no jobs and no error", jobs, err)
|
||||
}
|
||||
if took := time.Since(start); took > 3*time.Second {
|
||||
t.Errorf("a long poll ran %v after draining began, want it to end within about a second", took)
|
||||
}
|
||||
// Once draining, polls answer at once.
|
||||
start = time.Now()
|
||||
if _, err := client.Jobs(context.Background(), 10, 20*time.Second); err != nil || time.Since(start) > 2*time.Second {
|
||||
t.Errorf("a poll on a draining instance took %v (%v)", time.Since(start), err)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user