mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 02:41:25 +00:00
Merge pull request #99125 from tkashem/apf-response-header-fix
apf: set response headers for rejected requests
This commit is contained in:
commit
7ab447fd4d
@ -122,12 +122,7 @@ func WithPriorityAndFairness(
|
|||||||
served = true
|
served = true
|
||||||
innerCtx := context.WithValue(ctx, priorityAndFairnessKey, classification)
|
innerCtx := context.WithValue(ctx, priorityAndFairnessKey, classification)
|
||||||
innerReq := r.Clone(innerCtx)
|
innerReq := r.Clone(innerCtx)
|
||||||
|
setResponseHeaders(classification, w)
|
||||||
// We intentionally set the UID of the flow-schema and priority-level instead of name. This is so that
|
|
||||||
// the names that cluster-admins choose for categorization and priority levels are not exposed, also
|
|
||||||
// the names might make it obvious to the users that they are rejected due to classification with low priority.
|
|
||||||
w.Header().Set(flowcontrol.ResponseHeaderMatchedPriorityLevelConfigurationUID, string(classification.PriorityLevelUID))
|
|
||||||
w.Header().Set(flowcontrol.ResponseHeaderMatchedFlowSchemaUID, string(classification.FlowSchemaUID))
|
|
||||||
|
|
||||||
handler.ServeHTTP(w, innerReq)
|
handler.ServeHTTP(w, innerReq)
|
||||||
}
|
}
|
||||||
@ -140,6 +135,8 @@ func WithPriorityAndFairness(
|
|||||||
}
|
}
|
||||||
}, execute)
|
}, execute)
|
||||||
if !served {
|
if !served {
|
||||||
|
setResponseHeaders(classification, w)
|
||||||
|
|
||||||
if isMutatingRequest {
|
if isMutatingRequest {
|
||||||
epmetrics.DroppedRequests.WithContext(ctx).WithLabelValues(epmetrics.MutatingKind).Inc()
|
epmetrics.DroppedRequests.WithContext(ctx).WithLabelValues(epmetrics.MutatingKind).Inc()
|
||||||
} else {
|
} else {
|
||||||
@ -158,3 +155,15 @@ func StartPriorityAndFairnessWatermarkMaintenance(stopCh <-chan struct{}) {
|
|||||||
startWatermarkMaintenance(watermark, stopCh)
|
startWatermarkMaintenance(watermark, stopCh)
|
||||||
startWatermarkMaintenance(waitingMark, stopCh)
|
startWatermarkMaintenance(waitingMark, stopCh)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func setResponseHeaders(classification *PriorityAndFairnessClassification, w http.ResponseWriter) {
|
||||||
|
if classification == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// We intentionally set the UID of the flow-schema and priority-level instead of name. This is so that
|
||||||
|
// the names that cluster-admins choose for categorization and priority levels are not exposed, also
|
||||||
|
// the names might make it obvious to the users that they are rejected due to classification with low priority.
|
||||||
|
w.Header().Set(flowcontrol.ResponseHeaderMatchedPriorityLevelConfigurationUID, string(classification.PriorityLevelUID))
|
||||||
|
w.Header().Set(flowcontrol.ResponseHeaderMatchedFlowSchemaUID, string(classification.FlowSchemaUID))
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user