[mender-client] Missing request_id in logs after customer device being dismissed/rejected

Description

What is wrong: request_id is missing in /var/log/syslog after device being dismissed/rejected:

 How to reproduce:

  1. Login to HM

  2. Accept new device

  3. Reject/dismiss the device

  4. Inspect /var/log/syslog on device

Device: raspberry pi 3

pi@raspberrypi:~ $ mender --version
3.1.0 runtime: go1.14.7

 

* After dismissing: level=error msg="(request_id: ): Got unexpected HTTP status when submitting to inventory 401"
* After rejecting: level=warning msg="Failed to refresh inventory: failed to submit inventory data: (request_id: ): Got unexpected HTTP status when submitting to inventory 401"
* level=error msg="Error receiving scheduled update data: (request_id: ): client not authorized"
* level=info msg="Handling error state, current error: transient error: (request_id: ): client not authorized"
* level=warning msg="Failed to refresh inventory: failed to submit inventory data: (request_id: ): Got unexpected HTTP status when submitting to inventory 429"

 

Expected result: request_id is properly shown in /var/log/syslog after device is rejected/dismissed

 

Affects versions

Environment

raspberry pi 3

Checklist

Activity

Show:

Mikael Torp-Holte August 18, 2022 at 11:54 AM
Edited

To me it doesnt make sense to have it if request id is absent. There is already a check for serverErrMsg

https://github.com/mendersoftware/mender/pull/1026

in case rest agrees ^

slightly smiling face

Maciej Tomczuk August 17, 2022 at 7:54 PM

This part of code is responsible for appending request_id to logs in mender client - theoretically we might add it only if header exists:

// APIError is an error type returned after receiving an error message from the // server. It wraps a regular error with the request_id - and if // the server returns an error message, this is also returned. type APIError struct { error reqID string serverErrMsg string } func NewAPIError(err error, resp *http.Response) *APIError { a := APIError{ error: err, reqID: resp.Header.Get("request_id"), } if resp.StatusCode >= 400 && resp.StatusCode < 600 { a.serverErrMsg = unmarshalErrorMessage(resp.Body) } return &a } func (a *APIError) Error() string { err := fmt.Sprintf("(request_id: %s): %s", a.reqID, a.error.Error()) if a.serverErrMsg != "" { return err + fmt.Sprintf(" server error message: %s", a.serverErrMsg) } return err }

Maciej Tomczuk August 17, 2022 at 7:42 PM

thanks for reviewing this! do you think it makes sense to remove `request_id` from mentioned logs?

Mikael Torp-Holte August 17, 2022 at 3:35 PM
Edited


As it turns out, if the device is not authenticated then the backend will reply with an empty body:

https://docs.mender.io/api/#device-api-device-inventory-assign-attributes-responses

So technically its not a bug, even though it seems that way.

Either we can cease to append the "request_id" string if the header does not exist (client), or we add the header to responses with respect to this and similar endpoints (backend). (we might even ignore this issue entirely?)

thoughts?

Fixed

Details

Assignee

Reporter

Priority

Days in progress

0

Backlog

yes

Zendesk Support

Checklist

Created October 4, 2021 at 11:44 AM
Updated September 28, 2022 at 9:14 AM
Resolved September 28, 2022 at 9:14 AM

Flag notifications