New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bugfix missing metrics and test cases to ensure terminated request metrics is not missing #93877
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ import ( | |
"context" | ||
"fmt" | ||
"net/http" | ||
"sync" | ||
"sync/atomic" | ||
|
||
fcv1a1 "k8s.io/api/flowcontrol/v1alpha1" | ||
|
@@ -62,6 +63,9 @@ var waitingMark = &requestWatermark{ | |
mutatingObserver: fcmetrics.ReadWriteConcurrencyObserverPairGenerator.Generate(1, 1, []string{epmetrics.MutatingKind}).RequestsWaiting, | ||
} | ||
|
||
// apfStartOnce is used to avoid sharing one-time mutex with maxinflight handler | ||
var apfStartOnce sync.Once | ||
|
||
var atomicMutatingExecuting, atomicReadOnlyExecuting int32 | ||
var atomicMutatingWaiting, atomicReadOnlyWaiting int32 | ||
|
||
|
@@ -78,6 +82,8 @@ func WithPriorityAndFairness( | |
} | ||
startOnce.Do(func() { | ||
startRecordingUsage(watermark) | ||
}) | ||
apfStartOnce.Do(func() { | ||
Comment on lines
+85
to
+86
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is not addressing an actual bug because either There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right. Separating |
||
startRecordingUsage(waitingMark) | ||
}) | ||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
|
@@ -144,6 +150,11 @@ func WithPriorityAndFairness( | |
} | ||
}, execute) | ||
if !served { | ||
if isMutatingRequest { | ||
epmetrics.DroppedRequests.WithLabelValues(epmetrics.MutatingKind).Inc() | ||
} else { | ||
epmetrics.DroppedRequests.WithLabelValues(epmetrics.ReadOnlyKind).Inc() | ||
} | ||
epmetrics.RecordRequestTermination(r, requestInfo, epmetrics.APIServerComponent, http.StatusTooManyRequests) | ||
tooManyRequests(r, w) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a note that all these globals make it impossible to e.g. install a second APF filter with different settings for long-running requests, which might be one thing we eventually want to do.
Not asking for a change now.