mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 10:51:29 +00:00
Merge pull request #112557 from marseel/fix_list_estimator
Fix list estimator for lists that are executed as gets
This commit is contained in:
commit
497e0dfd33
@ -50,6 +50,15 @@ func (e *listWorkEstimator) estimate(r *http.Request, flowSchemaName, priorityLe
|
|||||||
return WorkEstimate{InitialSeats: e.config.MaximumSeats}
|
return WorkEstimate{InitialSeats: e.config.MaximumSeats}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if requestInfo.Name != "" {
|
||||||
|
// Requests with metadata.name specified are usually executed as get
|
||||||
|
// requests in storage layer so their width should be 1.
|
||||||
|
// Example of such list requests:
|
||||||
|
// /apis/certificates.k8s.io/v1/certificatesigningrequests?fieldSelector=metadata.name%3Dcsr-xxs4m
|
||||||
|
// /api/v1/namespaces/test/configmaps?fieldSelector=metadata.name%3Dbig-deployment-1&limit=500&resourceVersion=0
|
||||||
|
return WorkEstimate{InitialSeats: e.config.MinimumSeats}
|
||||||
|
}
|
||||||
|
|
||||||
query := r.URL.Query()
|
query := r.URL.Query()
|
||||||
listOptions := metav1.ListOptions{}
|
listOptions := metav1.ListOptions{}
|
||||||
if err := metav1.Convert_url_Values_To_v1_ListOptions(&query, &listOptions, nil); err != nil {
|
if err := metav1.Convert_url_Values_To_v1_ListOptions(&query, &listOptions, nil); err != nil {
|
||||||
|
@ -256,6 +256,34 @@ func TestWorkEstimator(t *testing.T) {
|
|||||||
countErr: errors.New("unknown error"),
|
countErr: errors.New("unknown error"),
|
||||||
initialSeatsExpected: maximumSeats,
|
initialSeatsExpected: maximumSeats,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "request verb is list, metadata.name specified",
|
||||||
|
requestURI: "http://server/apis/foo.bar/v1/events?fieldSelector=metadata.name%3Dtest",
|
||||||
|
requestInfo: &apirequest.RequestInfo{
|
||||||
|
Verb: "list",
|
||||||
|
Name: "test",
|
||||||
|
APIGroup: "foo.bar",
|
||||||
|
Resource: "events",
|
||||||
|
},
|
||||||
|
counts: map[string]int64{
|
||||||
|
"events.foo.bar": 799,
|
||||||
|
},
|
||||||
|
initialSeatsExpected: minimumSeats,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "request verb is list, metadata.name, resourceVersion and limit specified",
|
||||||
|
requestURI: "http://server/apis/foo.bar/v1/events?fieldSelector=metadata.name%3Dtest&limit=500&resourceVersion=0",
|
||||||
|
requestInfo: &apirequest.RequestInfo{
|
||||||
|
Verb: "list",
|
||||||
|
Name: "test",
|
||||||
|
APIGroup: "foo.bar",
|
||||||
|
Resource: "events",
|
||||||
|
},
|
||||||
|
counts: map[string]int64{
|
||||||
|
"events.foo.bar": 799,
|
||||||
|
},
|
||||||
|
initialSeatsExpected: minimumSeats,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "request verb is create, no watches",
|
name: "request verb is create, no watches",
|
||||||
requestURI: "http://server/apis/foo.bar/v1/foos",
|
requestURI: "http://server/apis/foo.bar/v1/foos",
|
||||||
|
Loading…
Reference in New Issue
Block a user