Merge pull request #105647 from wojtek-t/disable_pf_for_watches

Disable P&F for watch requests
This commit is contained in:
Kubernetes Prow Robot 2021-10-13 02:53:50 -07:00 committed by GitHub
commit f0e80a6f10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 126 additions and 117 deletions

View File

@ -41,6 +41,12 @@ const (
) )
func (e *mutatingWorkEstimator) estimate(r *http.Request) WorkEstimate { func (e *mutatingWorkEstimator) estimate(r *http.Request) WorkEstimate {
// TODO(wojtekt): Remove once we tune the algorithm to not fail
// scalability tests.
return WorkEstimate{
InitialSeats: 1,
}
requestInfo, ok := apirequest.RequestInfoFrom(r.Context()) requestInfo, ok := apirequest.RequestInfoFrom(r.Context())
if !ok { if !ok {
// no RequestInfo should never happen, but to be on the safe side // no RequestInfo should never happen, but to be on the safe side
@ -51,7 +57,6 @@ func (e *mutatingWorkEstimator) estimate(r *http.Request) WorkEstimate {
AdditionalLatency: eventAdditionalDuration, AdditionalLatency: eventAdditionalDuration,
} }
} }
watchCount := e.countFn(requestInfo) watchCount := e.countFn(requestInfo)
// The cost of the request associated with the watchers of that event // The cost of the request associated with the watchers of that event

View File

@ -252,132 +252,136 @@ func TestWorkEstimator(t *testing.T) {
countErr: errors.New("unknown error"), countErr: errors.New("unknown error"),
initialSeatsExpected: maximumSeats, initialSeatsExpected: maximumSeats,
}, },
{ // TODO(wojtekt): Reenable these tests after tuning algorithm to
name: "request verb is create, no watches", // not fail scalability tests.
requestURI: "http://server/apis/foo.bar/v1/foos", /*
requestInfo: &apirequest.RequestInfo{ {
Verb: "create", name: "request verb is create, no watches",
APIGroup: "foo.bar", requestURI: "http://server/apis/foo.bar/v1/foos",
Resource: "foos", requestInfo: &apirequest.RequestInfo{
Verb: "create",
APIGroup: "foo.bar",
Resource: "foos",
},
initialSeatsExpected: 1,
finalSeatsExpected: 0,
additionalLatencyExpected: 0,
}, },
initialSeatsExpected: 1, {
finalSeatsExpected: 0, name: "request verb is create, watches registered",
additionalLatencyExpected: 0, requestURI: "http://server/apis/foo.bar/v1/foos",
}, requestInfo: &apirequest.RequestInfo{
{ Verb: "create",
name: "request verb is create, watches registered", APIGroup: "foo.bar",
requestURI: "http://server/apis/foo.bar/v1/foos", Resource: "foos",
requestInfo: &apirequest.RequestInfo{ },
Verb: "create", watchCount: 29,
APIGroup: "foo.bar", initialSeatsExpected: 1,
Resource: "foos", finalSeatsExpected: 3,
additionalLatencyExpected: 5 * time.Millisecond,
}, },
watchCount: 29, {
initialSeatsExpected: 1, name: "request verb is create, watches registered, no additional latency",
finalSeatsExpected: 3, requestURI: "http://server/apis/foo.bar/v1/foos",
additionalLatencyExpected: 5 * time.Millisecond, requestInfo: &apirequest.RequestInfo{
}, Verb: "create",
{ APIGroup: "foo.bar",
name: "request verb is create, watches registered, no additional latency", Resource: "foos",
requestURI: "http://server/apis/foo.bar/v1/foos", },
requestInfo: &apirequest.RequestInfo{ watchCount: 5,
Verb: "create", initialSeatsExpected: 1,
APIGroup: "foo.bar", finalSeatsExpected: 0,
Resource: "foos", additionalLatencyExpected: 0,
}, },
watchCount: 5, {
initialSeatsExpected: 1, name: "request verb is create, watches registered, maximum is exceeded",
finalSeatsExpected: 0, requestURI: "http://server/apis/foo.bar/v1/foos",
additionalLatencyExpected: 0, requestInfo: &apirequest.RequestInfo{
}, Verb: "create",
{ APIGroup: "foo.bar",
name: "request verb is create, watches registered, maximum is exceeded", Resource: "foos",
requestURI: "http://server/apis/foo.bar/v1/foos", },
requestInfo: &apirequest.RequestInfo{ watchCount: 199,
Verb: "create", initialSeatsExpected: 1,
APIGroup: "foo.bar", finalSeatsExpected: 20,
Resource: "foos", additionalLatencyExpected: 5 * time.Millisecond,
}, },
watchCount: 199, {
initialSeatsExpected: 1, name: "request verb is update, no watches",
finalSeatsExpected: 20, requestURI: "http://server/apis/foo.bar/v1/foos/myfoo",
additionalLatencyExpected: 5 * time.Millisecond, requestInfo: &apirequest.RequestInfo{
}, Verb: "update",
{ APIGroup: "foo.bar",
name: "request verb is update, no watches", Resource: "foos",
requestURI: "http://server/apis/foo.bar/v1/foos/myfoo", },
requestInfo: &apirequest.RequestInfo{ initialSeatsExpected: 1,
Verb: "update", finalSeatsExpected: 0,
APIGroup: "foo.bar", additionalLatencyExpected: 0,
Resource: "foos",
}, },
initialSeatsExpected: 1, {
finalSeatsExpected: 0, name: "request verb is update, watches registered",
additionalLatencyExpected: 0, requestURI: "http://server/apis/foor.bar/v1/foos/myfoo",
}, requestInfo: &apirequest.RequestInfo{
{ Verb: "update",
name: "request verb is update, watches registered", APIGroup: "foo.bar",
requestURI: "http://server/apis/foor.bar/v1/foos/myfoo", Resource: "foos",
requestInfo: &apirequest.RequestInfo{ },
Verb: "update", watchCount: 29,
APIGroup: "foo.bar", initialSeatsExpected: 1,
Resource: "foos", finalSeatsExpected: 3,
additionalLatencyExpected: 5 * time.Millisecond,
}, },
watchCount: 29, {
initialSeatsExpected: 1, name: "request verb is patch, no watches",
finalSeatsExpected: 3, requestURI: "http://server/apis/foo.bar/v1/foos/myfoo",
additionalLatencyExpected: 5 * time.Millisecond, requestInfo: &apirequest.RequestInfo{
}, Verb: "patch",
{ APIGroup: "foo.bar",
name: "request verb is patch, no watches", Resource: "foos",
requestURI: "http://server/apis/foo.bar/v1/foos/myfoo", },
requestInfo: &apirequest.RequestInfo{ initialSeatsExpected: 1,
Verb: "patch", finalSeatsExpected: 0,
APIGroup: "foo.bar", additionalLatencyExpected: 0,
Resource: "foos",
}, },
initialSeatsExpected: 1, {
finalSeatsExpected: 0, name: "request verb is patch, watches registered",
additionalLatencyExpected: 0, requestURI: "http://server/apis/foo.bar/v1/foos/myfoo",
}, requestInfo: &apirequest.RequestInfo{
{ Verb: "patch",
name: "request verb is patch, watches registered", APIGroup: "foo.bar",
requestURI: "http://server/apis/foo.bar/v1/foos/myfoo", Resource: "foos",
requestInfo: &apirequest.RequestInfo{ },
Verb: "patch", watchCount: 29,
APIGroup: "foo.bar", initialSeatsExpected: 1,
Resource: "foos", finalSeatsExpected: 3,
additionalLatencyExpected: 5 * time.Millisecond,
}, },
watchCount: 29, {
initialSeatsExpected: 1, name: "request verb is delete, no watches",
finalSeatsExpected: 3, requestURI: "http://server/apis/foo.bar/v1/foos/myfoo",
additionalLatencyExpected: 5 * time.Millisecond, requestInfo: &apirequest.RequestInfo{
}, Verb: "delete",
{ APIGroup: "foo.bar",
name: "request verb is delete, no watches", Resource: "foos",
requestURI: "http://server/apis/foo.bar/v1/foos/myfoo", },
requestInfo: &apirequest.RequestInfo{ initialSeatsExpected: 1,
Verb: "delete", finalSeatsExpected: 0,
APIGroup: "foo.bar", additionalLatencyExpected: 0,
Resource: "foos",
}, },
initialSeatsExpected: 1, {
finalSeatsExpected: 0, name: "request verb is delete, watches registered",
additionalLatencyExpected: 0, requestURI: "http://server/apis/foo.bar/v1/foos/myfoo",
}, requestInfo: &apirequest.RequestInfo{
{ Verb: "delete",
name: "request verb is delete, watches registered", APIGroup: "foo.bar",
requestURI: "http://server/apis/foo.bar/v1/foos/myfoo", Resource: "foos",
requestInfo: &apirequest.RequestInfo{ },
Verb: "delete", watchCount: 29,
APIGroup: "foo.bar", initialSeatsExpected: 1,
Resource: "foos", finalSeatsExpected: 3,
additionalLatencyExpected: 5 * time.Millisecond,
}, },
watchCount: 29, */
initialSeatsExpected: 1,
finalSeatsExpected: 3,
additionalLatencyExpected: 5 * time.Millisecond,
},
} }
for _, test := range tests { for _, test := range tests {