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
Fix mimirtool error logging #3180
Conversation
Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
8d86f5f
to
712a5ac
Compare
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.
LGTM (except for a CHANGELOG typo).
Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
pkg/mimirtool/client/client.go
Outdated
} else { | ||
errMsg = fmt.Sprintf("server returned HTTP status %s: %s", r.Status, msg) | ||
errMsg = fmt.Sprintf("server returned HTTP status: %s, body: %s", r.Status, msg) |
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.
Maybe this should be %q
, so any funny characters are visible?
I can see arguments on both sides whether newline or \n
is easier for the reader, but a \t
would definitely be clearer than some whitespace.
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.
pushed that change in da755e9
}).Debugln(errMsg) | ||
return errConflict | ||
} | ||
|
||
log.WithFields(log.Fields{ | ||
"status": r.Status, | ||
"msg": msg, |
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.
Why did this change? I don't see it mentioned in the commit description.
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.
without this removal, the error message is repeated. errMsg
already contains msg
mimir/pkg/mimirtool/client/client.go
Lines 180 to 194 in 465cbff
msg := string(bodyHead) | |
var errMsg string | |
if msg == "" { | |
errMsg = fmt.Sprintf("server returned HTTP status: %s", r.Status) | |
} else { | |
errMsg = fmt.Sprintf("server returned HTTP status: %s, body: %s", r.Status, msg) | |
} | |
if r.StatusCode == http.StatusNotFound { | |
log.WithFields(log.Fields{ | |
"status": r.Status, | |
}).Debugln(errMsg) | |
return ErrResourceNotFound | |
} |
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 noticed the same as @dimitarvdimitrov is saying, figured that's why msg
gets removed.
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.
actually I went ahead and did some more changes. even with the removed msg
(and with %q
), there was still duplication
time="2022-10-11T07:28:28Z" level=error msg="server returned HTTP status: 400 Bad Request, body: \"block upload is disabled\\n\"" status="400 Bad Request"
in da755e9 I changed this to
time="2022-10-11T07:45:02Z" level=error msg=response body="block upload is disabled\n" status="400 Bad Request"
and an example flow is for a failed blocks upload
time="2022-10-11T07:45:02Z" level=info msg=Backfilling blocks=/shared/01GF301Z9T3CX0YK0VZ5B18MWJ user=anonymous
time="2022-10-11T07:45:02Z" level=info msg="making request to start block upload" block=01GF301Z9T3CX0YK0VZ5B18MWJ file=meta.json path=/shared/01GF301Z9T3CX0YK0VZ5B18MWJ
time="2022-10-11T07:45:02Z" level=error msg=response body="block upload is disabled\n" status="400 Bad Request"
time="2022-10-11T07:45:02Z" level=error msg="failed uploading block" error="request to start block upload failed: POST request to http://compactor:8080/api/v1/upload/block/01GF301Z9T3CX0YK0VZ5B18MWJ/start failed: server returned HTTP status: 400 Bad Request, body: \"block upload is disabled\\n\"" path=/shared/01GF301Z9T3CX0YK0VZ5B18MWJ
time="2022-10-11T07:45:02Z" level=info msg="finished uploading blocks" already_exists=0 failed=1 succeeded=0
mimirtool: error: blocks failed to upload 1 block(s), try --help
Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
can you please take another look @bboreham? |
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.
This looks very useful to me. LGTM!
* Fix mimirtool error logging Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com> * Add changelog entry Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com> * Update CHANGELOG.md * Update backfill test Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com> * Remove duplication from log lines Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com> Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
* Fix mimirtool error logging Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com> * Add changelog entry Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com> * Update CHANGELOG.md * Update backfill test Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com> * Remove duplication from log lines Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com> Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
Signed-off-by: Dimitar Dimitrov dimitar.dimitrov@grafana.com
What this PR does
When provided with
--log.level=debug
and a request fails mimirtool should print out some part of the response for easier debugging. Instead it uses a scanner which only reads the first token from the response.The first token is by default the first line. Which in some cases can be fairly useless.
This PR
errMsg
andmsg
)Which issue(s) this PR fixes or relates to
Fixes #
Checklist
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]