Description
What happened?
According to the documentation https://kubernetes.io/docs/concepts/cluster-administration/flow-control/#seats-occupied-by-a-request , the APIServer's APF (API Priority and Fairness) calculates seats for each request as a reference to measure the consumption of each API. Specifically, List requests determine the number of seats based on the number of objects returned.
However, in actual usage, I have observed that all List requests (regardless of the number of objects) are assigned only 1 seat by APF.
For example, I have 1w+ pods in cluster, seat expected to be 10.
apiserver_flowcontrol_work_estimated_seats_bucket{flow_schema="list-pods",priority_level="list-pods",le="1"} 84
apiserver_flowcontrol_work_estimated_seats_bucket{flow_schema="list-pods",priority_level="list-pods",le="2"} 84
apiserver_flowcontrol_work_estimated_seats_bucket{flow_schema="list-pods",priority_level="list-pods",le="4"} 84
apiserver_flowcontrol_work_estimated_seats_bucket{flow_schema="list-pods",priority_level="list-pods",le="10"} 84
apiserver_flowcontrol_work_estimated_seats_bucket{flow_schema="list-pods",priority_level="list-pods",le="+Inf"} 84
I found that the seat calculation for List requests happens at
and every request hit the error:
.
So I add some debug log in objectCountTracker
set, found that objectCountTracker
is nil, so it will never update the object count, which will cause ObjectCountNotFoundErr
in APF list estimator.
kubernetes/staging/src/k8s.io/apiserver/pkg/registry/generic/registry/store.go
Lines 1673 to 1675 in 2642d82
What did you expect to happen?
In APF (API Priority and Fairness), the seats for a List request should increase with the number of objects returned, rather than always being 1.
How can we reproduce it (as minimally and precisely as possible)?
There is my apf config.
apiVersion: flowcontrol.apiserver.k8s.io/v1beta3
kind: PriorityLevelConfiguration
metadata:
name: list-pods
spec:
limited:
nominalConcurrencyShares: 1
borrowingLimitPercent: 0
limitResponse:
queuing:
handSize: 5
queueLengthLimit: 0
queues: 5
type: Queue
type: Limited
---
apiVersion: flowcontrol.apiserver.k8s.io/v1beta3
kind: FlowSchema
metadata:
name: list-pods
spec:
distinguisherMethod:
type: ByUser
matchingPrecedence: 100
priorityLevelConfiguration:
name: list-pods
rules:
- resourceRules:
- apiGroups:
- '*'
clusterScope: true
namespaces:
resources:
- pods
verbs:
- list
subjects:
- group:
name: system:authenticated
kind: Group
Anything else we need to know?
No response
Kubernetes version
Server Version: v1.32.2
Cloud provider
OS version
# On Linux:
$ cat /etc/os-release
# paste output here
$ uname -a
# paste output here
# On Windows:
C:\> wmic os get Caption, Version, BuildNumber, OSArchitecture
# paste output here