Skip to content

Commit cd5d5cc

Browse files
committed
docs(supervisor): describe the pod count as an estimate, not exact
1 parent 45b05f1 commit cd5d5cc

2 files changed

Lines changed: 14 additions & 10 deletions

File tree

.server-changes/pod-count-exact-list.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ area: supervisor
33
type: improvement
44
---
55

6-
Self-hosted Kubernetes deployments now pause and resume pulling new work at their exact configured thresholds, rather than slightly early or late.
6+
Self-hosted Kubernetes deployments now measure running-task count more accurately when deciding whether to pause pulling new work, so the safeguard engages closer to its configured thresholds.

apps/supervisor/src/clients/kubernetes.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,18 @@ function getKubeConfig() {
5353
export { k8s };
5454

5555
/**
56-
* createPodCountFetcher counts pod objects in a namespace with a single `limit=1`
57-
* list: one pod transferred, no informer, no watch cache. Population is
58-
* `remainingItemCount + items.length`.
56+
* createPodCountFetcher sizes a namespace's pod collection with a single `limit=1`
57+
* list: one pod transferred, no informer, no watch cache.
58+
*
59+
* This is an ESTIMATE, not an exact count. Kubernetes documents `remainingItemCount`
60+
* as intended for estimating collection size and reserves the right not to set it or
61+
* make it exact. Counting exactly would mean paginating the whole collection, which is
62+
* what this deliberately avoids. Treat the value as a tight estimate from a quorum read
63+
* at request time, and set thresholds with that in mind.
5964
*
6065
* Two request-shape constraints, both load-bearing. A label or field selector makes
6166
* the apiserver omit `remainingItemCount` entirely, and setting `resourceVersion`
6267
* serves a cached count instead of a quorum read - so neither is passed.
63-
*
64-
* `remainingItemCount` is only set when the list is truncated, so `_continue` is the
65-
* truncation signal: absent means the returned page is the whole collection.
6668
*/
6769
export function createPodCountFetcher(
6870
api: K8sApi,
@@ -94,12 +96,14 @@ export function createPodCountFetcher(
9496
}
9597

9698
/**
97-
* podCountFromList turns a `limit=1` pod list into a population.
99+
* podCountFromList turns a `limit=1` pod list into a population estimate.
98100
*
99101
* `remainingItemCount` is only set when the list is truncated, so `_continue` is the
100102
* truncation signal: absent means the returned page is the whole collection and its
101-
* length is already the answer. Truncated without a usable estimate is unknowable, so
102-
* it throws rather than guessing a low number the brake would act on.
103+
* length is exact. When truncated the total leans on `remainingItemCount`, which is
104+
* documented as an estimate - so the result is an estimate too. Truncated without a
105+
* usable count is unknowable, so it throws rather than returning a low number the
106+
* caller would act on.
103107
*/
104108
export function podCountFromList(list: {
105109
items: unknown[];

0 commit comments

Comments
 (0)