Repository navigation
[Bug] Drop pool policy activity records of pods that stopped reporting - #2885
varungup90 merged 1 commit into
Conversation
Records were added by observe and never removed, so the map grew with every replaced pod until the controller restarted. Stamp each record with the time it was last observed and sweep the ones unseen for five minutes, at most once a minute. Signed-off-by: Ankit Jha <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request introduces a mechanism to clean up stale activity records of pods that have stopped reporting in the poolPolicyManager. It tracks the last seen time for each activity record and periodically sweeps the activity map to remove records older than 5 minutes, bounded to run at most once per minute. Comprehensive unit tests are also added to verify this behavior. I have no feedback to provide.
varungup90
left a comment
There was a problem hiding this comment.
Reviewed the activity retention/sweep changes and their interaction with pool reconciliation, request-counter baselines, KV allocation, and idle-sleep decisions. No actionable issues found.
The sweep and observation updates use the same mutex; the sweep timestamp is manager-wide, so multiple pools share the scan throttle. Expiry deliberately discards an unobserved baseline, and the next observation reinitializes it without treating historical completions as new activity.
Validation at this commit:
go test ./pkg/controller/modelclaim/ -count=1passed.go test -race -ldflags=-linkmode=external ./pkg/controller/modelclaim/ -count=1passed.- An additional temporary test in an isolated worktree passed under the race detector, covering the retention boundary, global sweep throttling across two pools, baseline reinitialization after expiry, and subsequent completion deltas. The temporary test was removed after validation.
git diff --checkpassed.
Cluster/envtest integration tests were not run.
Pull Request Description
Problem.
poolPolicyManager.activitygets a record for every pod and engine the pool policy observes, and nothing removes it. Every replaced pod leaves records behind until the controller restarts.Root cause.
observeonly adds and updates entries. Nothing inpool_policy_controller.godeletes them.Fix. Each record now carries the time it was last observed.
begin, which runs once per pool per cycle, sweeps records unseen for 5 minutes. The sweep scans the whole map, so it runs at most once a minute, which keeps the cost at one pass over the records per minute no matter how many pools run. A live pod is observed every 10 seconds (DefaultRequeueDuration), so it never ages out.A model that is asleep is not observed, so its record can age out too. When it wakes up it starts from a fresh baseline and its decisions wait for the next snapshot, which is what a controller restart already does (see the comment on
poolPolicyManager).Tests.
TestPoolPolicyManagerDropsActivityOfPodsThatStopReporting: a replaced pod's record stays inside the window and is gone after it, the new pod's record staysTestPoolPolicyManagerKeepsTheBaselineOfAnObservedPod: a pod observed every interval for 5 minutes keeps its counter baseline and still reports the right deltaTestPoolPolicyManagerSweepsAtMostOncePerInterval: a sweep inside the interval is skippedChecks run:
go test -race ./pkg/controller/modelclaim/passes. On macOS I used-ldflags=-linkmode=externalto avoid amissing LC_UUIDabort.golangci-lint run ./pkg/controller/modelclaim/...reports 0 issues.Related Issues
Resolves: #2883