Skip to content
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

Merged
merged 4 commits into from
Oct 3, 2022

Conversation

arielshaqed
Copy link
Contributor

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.

@arielshaqed arielshaqed requested a review from nopcoder October 2, 2022 12:12
@arielshaqed arielshaqed added area/gateway Changes to the gateway bug Something isn't working include-changelog PR description should be included in next release changelog pr/merge-if-approved Reviewer: please feel free to merge if no major comments labels Oct 2, 2022
@arielshaqed arielshaqed linked an issue Oct 2, 2022 that may be closed by this pull request
@@ -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]
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

YIKES!

@@ -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
Copy link
Contributor

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

Copy link
Contributor

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

@@ -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
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed operationID entirely :-)

Copy link
Contributor Author

@arielshaqed arielshaqed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

PTAL...

@@ -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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed operationID entirely :-)

Copy link
Contributor

@nopcoder nopcoder left a 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!

@@ -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
Copy link
Contributor

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

@nopcoder nopcoder merged commit 4a247d6 into master Oct 3, 2022
@nopcoder nopcoder deleted the bugfix/s3-gw-report-failures-to-metrics branch October 3, 2022 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/gateway Changes to the gateway bug Something isn't working include-changelog PR description should be included in next release changelog pr/merge-if-approved Reviewer: please feel free to merge if no major comments
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Correctly report status code and operation ID on S3 gateway
2 participants