Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6281a07

Browse files
authored
Merge pull request#133061 from serathius/apf_list
Account for caching and maximum object size when estimating LIST request
2 parents9212246 +9905989 commit6281a07

File tree

2 files changed

+379
-90
lines changed

2 files changed

+379
-90
lines changed

‎staging/src/k8s.io/apiserver/pkg/util/flowcontrol/request/list_work_estimator.go

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ import (
3333
const (
3434
bytesPerSeat=100_000
3535
cacheWithStreamingMaxMemoryUsage=1_000_000
36+
// 1.5MB is the recommended client request size in byte
37+
// the etcd server should accept. See
38+
// https://github.com/etcd-io/etcd/blob/release-3.4/embed/config.go#L56.
39+
maxObjectSize=1_500_000
40+
infiniteObjectCount=1_000_000_000
3641
)
3742

3843
funcnewListWorkEstimator(countFnstatsGetterFunc,config*WorkEstimatorConfig,maxSeatsFnmaxSeatsFunc)*listWorkEstimator {
@@ -89,21 +94,24 @@ func (e *listWorkEstimator) estimate(r *http.Request, flowSchemaName, priorityLe
8994
}
9095
}
9196
// TODO: Check whether watchcache is enabled.
97+
varlistFromStoragebool
9298
result,err:=delegator.ShouldDelegateListMeta(&listOptions, delegator.CacheWithoutSnapshots{})
9399
iferr!=nil {
94-
returnWorkEstimate{InitialSeats:maxSeats}
100+
// Assume worse case where we need to reach to etcd.
101+
listFromStorage=true
102+
}else {
103+
listFromStorage=result.ShouldDelegate
95104
}
96-
listFromStorage:=result.ShouldDelegate
97105
isListFromCache:=requestInfo.Verb=="watch"||!listFromStorage
98106

99107
stats,err:=e.statsGetterFn(key(requestInfo))
100108
switch {
101109
caseerr==ObjectCountStaleErr:
102110
// object count going stale is indicative of degradation, so we should
103-
// be conservative here andallocate maximumseats to this list request.
111+
// be conservative here andreturn maximumobject count and size.
104112
// NOTE: if a CRD is removed, its count will go stale first and then the
105113
// pruner will eventually remove the CRD from the cache.
106-
returnWorkEstimate{InitialSeats:maxSeats}
114+
stats= storage.Stats{ObjectCount:infiniteObjectCount,EstimatedAverageObjectSizeBytes:maxObjectSize}
107115
caseerr==ObjectCountNotFoundErr:
108116
// there are multiple scenarios in which we can see this error:
109117
// a. the type is truly unknown, a typo on the caller's part.
@@ -120,9 +128,9 @@ func (e *listWorkEstimator) estimate(r *http.Request, flowSchemaName, priorityLe
120128
returnWorkEstimate{InitialSeats:minSeats}
121129
caseerr!=nil:
122130
// we should never be here since Get returns either ObjectCountStaleErr or
123-
// ObjectCountNotFoundErr, returnmaximumSeats to be on the safe side.
131+
// ObjectCountNotFoundErr, returnmaximum object count and size.
124132
klog.ErrorS(err,"Unexpected error from object count tracker")
125-
returnWorkEstimate{InitialSeats:maxSeats}
133+
stats= storage.Stats{ObjectCount:infiniteObjectCount,EstimatedAverageObjectSizeBytes:maxObjectSize}
126134
}
127135

128136
varseatsuint64
@@ -172,9 +180,8 @@ func (e *listWorkEstimator) seatsBasedOnObjectCount(stats storage.Stats, listOpt
172180
}
173181

174182
func (e*listWorkEstimator)seatsBasedOnObjectSize(stats storage.Stats,listOptions metav1.ListOptions,isListFromCachebool,matchesSinglebool)uint64 {
175-
// Size not available, fallback to count based estimate
176183
ifstats.EstimatedAverageObjectSizeBytes<=0&&stats.ObjectCount!=0 {
177-
returne.seatsBasedOnObjectCount(stats,listOptions,isListFromCache,matchesSingle)
184+
stats.EstimatedAverageObjectSizeBytes=maxObjectSize
178185
}
179186
limited:=stats.ObjectCount
180187
iflistOptions.Limit>0&&listOptions.Limit<limited {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp