diff --git a/filters/shedder/admission.go b/filters/shedder/admission.go index d884522aa6..dcd7add75e 100644 --- a/filters/shedder/admission.go +++ b/filters/shedder/admission.go @@ -83,12 +83,14 @@ func (m mode) String() string { } const ( - counterPrefix = "shedder.admission_control." - admissionControlSpanName = "admission_control" - admissionControlKey = "shedder:admission_control" - admissionControlValue = "reject" - minWindowSize = 1 - maxWindowSize = 100 + counterPrefix = "shedder.admission_control." + admissionControlSpanName = "admission_control" + admissionSignalHeaderKey = "Admission-Control" + admissionSignalHeaderValue = "true" + admissionControlKey = "shedder:admission_control" + admissionControlValue = "reject" + minWindowSize = 1 + maxWindowSize = 100 ) type Options struct { @@ -422,7 +424,11 @@ func (ac *admissionControl) Request(ctx filters.FilterContext) { if ac.mode != active { return } + + header := make(http.Header) + header.Set(admissionSignalHeaderKey, admissionSignalHeaderValue) ctx.Serve(&http.Response{ + Header: header, StatusCode: http.StatusServiceUnavailable, }) } @@ -433,6 +439,9 @@ func (ac *admissionControl) Response(ctx filters.FilterContext) { if ctx.StateBag()[admissionControlKey] == admissionControlValue { return } + if ctx.Response().Header.Get(admissionControlKey) != "" { + return + } if ctx.Response().StatusCode < 499 { ac.successCounter.Add(1)