-
Notifications
You must be signed in to change notification settings - Fork 368
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
Correctly report status code and operation ID on S3 gateway #4293
Conversation
pkg/gateway/handler.go
Outdated
@@ -126,7 +126,7 @@ func NewHandler(region string, catalog catalog.Interface, multipartsTracker mult | |||
func (h *handler) ServeHTTP(w http.ResponseWriter, req *http.Request) { | |||
setDefaultContentType(w, req) | |||
o := req.Context().Value(ContextKeyOperation).(*operations.Operation) | |||
operationHandler := h.operationHandlers[o.OperationID] | |||
operationHandler := h.operationHandlers[o.FooOperationID] |
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.
can we revert this change?
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.
YIKES!
pkg/gateway/middleware.go
Outdated
@@ -127,7 +127,8 @@ func DurationHandler(next http.Handler) http.Handler { | |||
o := ctx.Value(ContextKeyOperation).(*operations.Operation) | |||
start := time.Now() | |||
mrw := httputil.NewMetricResponseWriter(w) | |||
next.ServeHTTP(w, req) | |||
next.ServeHTTP(mrw, req) | |||
operationID := o.OperationID |
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.
can revert this one too
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.
Still we don't use this one, based on diff
pkg/gateway/middleware.go
Outdated
@@ -175,7 +176,7 @@ func OperationLookupHandler(next http.Handler) http.Handler { | |||
ctx := req.Context() | |||
o := ctx.Value(ContextKeyOperation).(*operations.Operation) | |||
repoID := ctx.Value(ContextKeyRepositoryID).(string) | |||
var operationID operations.OperationID | |||
operationID := operations.OperationIDOperationNotFound |
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.
I think we need to update the structure (o.OperationID) at this point as we do return in case of an error.
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.
removed operationID
entirely :-)
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.
Thanks!
PTAL...
pkg/gateway/middleware.go
Outdated
@@ -175,7 +176,7 @@ func OperationLookupHandler(next http.Handler) http.Handler { | |||
ctx := req.Context() | |||
o := ctx.Value(ContextKeyOperation).(*operations.Operation) | |||
repoID := ctx.Value(ContextKeyRepositoryID).(string) | |||
var operationID operations.OperationID | |||
operationID := operations.OperationIDOperationNotFound |
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.
removed operationID
entirely :-)
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 one unused local var I think we can remove, but looks good - thanks!
pkg/gateway/middleware.go
Outdated
@@ -127,7 +127,8 @@ func DurationHandler(next http.Handler) http.Handler { | |||
o := ctx.Value(ContextKeyOperation).(*operations.Operation) | |||
start := time.Now() | |||
mrw := httputil.NewMetricResponseWriter(w) | |||
next.ServeHTTP(w, req) | |||
next.ServeHTTP(mrw, req) | |||
operationID := o.OperationID |
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.
Still we don't use this one, based on diff
Previously we incorrectly reported only status 200. Also some unknown
operations are misreported as "", meaning Grafana makes up a long
incomprehensible list of labels for them.