Details
-
Type:
Task
-
Status: Done
-
Priority:
(None)
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: None
-
Labels:None
-
Story Points:8
-
Backlog:yes
-
Days in progress:0
Description
Currently, any command executed by the client, such as inventory scripts, do only write to the syslog through stdout. This causes the output to show up over multiple lines, and seemingly inline in the logs.
Example: (made up)
Sep 23 07:26:57 qemux86-64 mender[297]: time="2021-09-23T07:26:57Z" level=info msg="Output (stderr) from command \"/usr/share/mender/identity/mender-device-identity\": using interface /sys/class/net/enp0s3" Sep 23 07:26:57 qemux86-64 mender[297]: time="2021-09-23T07:26:57Z" level=error msg="Failure occurred while executing authorization request: Method: Post, URL: https://docker.mender.io/api/devices/v1/authentication/auth_requests" Sep 23 07:26:57 qemux86-64 mender[297]: time="2021-09-23T07:26:57Z" level=error msg="Authorize failed: transient error: authorization request failed: transient error: authorization request failed: Unknown url.Error type: dial tcp: lookup docker.mender.io on 10.0.2.3:53: no such host" Sep 23 07:26:57 qemux86-64 mender[297]: time="2021-09-23T07:26:57Z" level=info msg="State transition: authorize [Sync] -> authorize-wait [Idle]" ... using interface /sys/class/net/enp0s3 .... ....
https://github.com/mendersoftware/mender-configure-module/pull/34#pullrequestreview-760690196
is a good idea of what is going on.
However, the suggested fix is not so straight forward, due to the non-closing semantics of the golang cmd/exec interface on Stdout/Stderr, which means closing/flushing the buffer is not done automatically by the command executor, and this will somehow have to be closed, or worked around in some other way.
The fix will thus have to buffer the input, and write it out line per line.
Acceptance criteria:
- Pretty print command from commands executed by scripts executed by the Mender client