Uploaded image for project: 'Mender'
  1. Mender
  2. MEN-5098

Capture and pretty print output from scripts executed by the Mender client

    XMLWordPrintable

    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.

      See https://github.com/mendersoftware/mender/blob/b19a8068ac2a55ec8e3b9628df0e0ca89e90c859/system/system.go#L90

      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

        Attachments

          Activity

            People

            Assignee:
            oleorhagen Ole Petter Orhagen
            Reporter:
            oleorhagen Ole Petter Orhagen
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: