balena-io-modules / balena-preload

Script for preloading containers onto balena device images
https://www.balena.io/
Apache License 2.0
35 stars 8 forks source link

Error handling: python `sh` output is truncated, and uncaught exceptions are not converted to JSON #233

Closed pdcastro closed 3 years ago

pdcastro commented 3 years ago

Currently, the output of commands (such as dockerd) executed with the python 'sh' module is truncated, for example:

  RAN: /usr/local/bin/dockerd --storage-driver=aufs --data-root=/tmp/tmpay62r387/docker --host=tcp://0.0.0.0:56360

  STDOUT:

  STDERR:
time="2020-09-23T19:52:59.762672297Z" level=warning msg="[!] DON'T BIND ON ANY IP ADDRESS WITHOUT setting --tlsverify IF YOU DON'T KNOW WHAT YOU'RE DOING [!]"
time="2020-09-23T19:52:59.764371255Z" level=info msg="libcontainerd: started new docker-containerd process" pid=233
time="2020-09-23T19:52:59Z" level=info msg="starting containerd" module=containerd revision=89623f28b87a6004d4b785663257362d1658a729 version=v1.0.0
time="2020-09-23T19:52:59Z" level=info msg="setting subreaper..." module=containerd
time="2020-09-23T19:52:59Z" level=info msg="changing OOM score to -500" module=containerd
time="2020-09-23T19:52:59Z" level=info msg="loading plugin "io.containerd.content.v1.content"..." module=containerd type=io.containerd.content.v1
tim... (3787 more, please see e.stderr)

Also, the interprocess communication between preload.js and preload.py exchanges JSON objects over stdin / stdout, but unexpected exceptions are not always captured and converted to JSON.

pdcastro commented 3 years ago

Connects-to: balena-io/balena-cli/issues/2045

pdcastro commented 3 years ago

This issue is resolved by a combination of PRs #239, #240 and #241.