diff --git a/cmd/tapir/scheduler.go b/cmd/tapir/scheduler.go index 41af918..037cc72 100644 --- a/cmd/tapir/scheduler.go +++ b/cmd/tapir/scheduler.go @@ -143,8 +143,18 @@ func runScheduler( return // disabled } - pass := 0 - runDiscoveryPass(ctx, pass, lister, runUser, log) + // Derive the rotation offset from wall-clock, NOT an in-memory counter. A + // counter reset to 0 on every pod restart always hands the lead to the + // first-listed user — so frequent deploys re-starve whoever is last (exactly + // what happened to the first pilot user during a deploy-heavy session). A + // time-based offset advances with real time and is identical across restarts, + // so the lead rotates fairly regardless of how often the pod bounces. + runPass := func() { + pass := int(time.Now().Unix() / int64(interval/time.Second)) + runDiscoveryPass(ctx, pass, lister, runUser, log) + } + + runPass() ticker := time.NewTicker(interval) defer ticker.Stop() @@ -153,8 +163,7 @@ func runScheduler( case <-ctx.Done(): return case <-ticker.C: - pass++ - runDiscoveryPass(ctx, pass, lister, runUser, log) + runPass() } } }