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

Make distributor log ingester details when a push request fails #6801

Merged
merged 3 commits into from
Dec 4, 2023

Conversation

duricanikolic
Copy link
Contributor

@duricanikolic duricanikolic commented Dec 4, 2023

What this PR does

Currently, if an ingester fails to push a request, the distributor that triggered the push loggs an error message like this:

msg="push error" err="failed pushing to ingester: <original error>"

This message doesn't contain any detail about which ingester was involved. This PR enriches the logged error with ingester's ID, so the improved log message will have the following format:

msg="push error" err="failed pushing to ingester <ingester ID>: <original error>"

Checklist

  • Tests updated.
  • [na] Documentation added.
  • [na] CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX].
  • [na] about-versioning.md updated with experimental features.

…logs

Signed-off-by: Yuri Nikolic <durica.nikolic@grafana.com>
@duricanikolic duricanikolic self-assigned this Dec 4, 2023
@duricanikolic duricanikolic requested a review from a team as a code owner December 4, 2023 07:24
@duricanikolic duricanikolic changed the title Yuri/better err msgs Make distributor log ingester details when a push request fails Dec 4, 2023
Signed-off-by: Yuri Nikolic <durica.nikolic@grafana.com>
@@ -20,6 +20,10 @@ import (
"github.com/grafana/mimir/pkg/mimirpb"
)

var (
ingesterID = "ingester-25"
Copy link
Collaborator

Choose a reason for hiding this comment

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

[nit] As a general good practice, I suggest to not define such generic global variables (BTW it could be a const) because it may be easy to misuse in tests. Instead, you could just define this const in each test where it's used (they're few).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have implemented this fix. Thank you

@@ -65,7 +65,7 @@ import (
)

var (
errFail = httpgrpc.Errorf(http.StatusInternalServerError, "Fail")
errFail = status.Error(codes.Internal, "Fail")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why 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.

errFail is used in mockIngester struct as an example of error returned by that ingester client. After the recent error handling refactoring, it is expected that ingesters will not return errors with HTTP status codes anymore. This is still the default behaviour, but will soon be deprecated.
As a consequence, I replaced the current errFail value with an error with a pure gRPC code.
It is worth noting that this change could be done in a separate PR.

@@ -1139,8 +1139,8 @@ func TestDistributor_PushQuery(t *testing.T) {
assert.EqualError(t, err, tc.expectedError.Error())

// Assert that downstream gRPC statuses are passed back upstream
_, ok := httpgrpc.HTTPResponseFromError(err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why 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.

This change is related to the change discussed above.
The previous version of this test was ensuring that the error returned by distributor.QueryStream() was produced by using the httpgrpc package. This is, anyway, not true. Before error handling improvement, it was the case sometimes, but after error handling improvement it is not the case anymore. The reason why the test was not failing was because we were using errFail defined as httpgrpc.Errorf(http.StatusInternalServerError, "Fail") as the only error returned by mockIngester, and that made the test successful.
Again, this could be done in a separate PR.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok I see.

Copy link
Collaborator

@pracucci pracucci Dec 4, 2023

Choose a reason for hiding this comment

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

I'm fine with the change in this PR, but as a general good practice I recommend to keep each PR focused on a single scope (ideally what the PR title says). As a retrospective, this test fix may have been a dedicated PR, which would have been easier to understand and in the future easier to track when we look back at code changes via git (each PR commits are squashed into a single commit).

Just a feedback for the next time.

Signed-off-by: Yuri Nikolic <durica.nikolic@grafana.com>
Copy link
Collaborator

@pracucci pracucci left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@duricanikolic duricanikolic merged commit 4dd4e9a into main Dec 4, 2023
28 checks passed
@duricanikolic duricanikolic deleted the yuri/better-err-msgs branch December 4, 2023 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants