Merge ~ogayot/curtin:system-install-log-stderr into curtin:master
Status: | Work in progress |
---|---|
Proposed branch: | ~ogayot/curtin:system-install-log-stderr |
Merge into: | curtin:master |
Diff against target: |
115 lines (+23/-17) 2 files modified
curtin/distro.py (+5/-4) tests/unittests/test_distro.py (+18/-13) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Server Team CI bot | continuous-integration | Approve | |
curtin developers | Pending | ||
Review via email: mp+462051@code.launchpad.net |
Commit message
system-install: log output of commands if they fail
Signed-off-by: Olivier Gayot <email address hidden>
Description of the change
If a subcommand fails as part of a `curtin system-install` invocation, curtin tries to show its output. Sadly, the output of the subcommand is not captured, so there is nothing to show.
Example:
Mar 08 14:23:46 ubuntu-server subiquity_
Mar 08 14:23:46 ubuntu-server systemd[1]: target-proc.mount: Deactivated successfully.
Mar 08 14:23:46 ubuntu-server subiquity_
Mar 08 14:23:46 ubuntu-server subiquity_
Mar 08 14:23:46 ubuntu-server subiquity_
Mar 08 14:23:46 ubuntu-server subiquity_
Mar 08 14:23:46 ubuntu-server subiquity_
Mar 08 14:23:46 ubuntu-server subiquity_
Mar 08 14:23:46 ubuntu-server subiquity_
Mar 08 14:23:46 ubuntu-server curtin_
NOTE that in the example above, the output of curtin system-install was redirected to the journal.
This change captures the output of subcommands so that there is something to show if a subcommand fails:
system install failed for ['openssh-server']: Unexpected error while running command.
Command: ['unshare', '--fork', '--pid', '--mount-
Exit code: 100
Reason: -
Stdout: Reading package lists...
Building dependency tree...
Reading state information...
0 upgraded, 0 newly installed, 0 to remove and 130 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up openssh-server (1:9.6p1-3ubuntu2) ...
needrestart is being skipped since dpkg has failed
Stderr: E: Can not write log (Is /dev/pts mounted?) - posix_openpt (19: No such device)
Failed to connect to bus: No data available
dpkg: error processing package openssh-server (--configure):
installed openssh-server package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
E: Sub-process /usr/bin/dpkg returned an error code (1)
PASSED: Continuous integration, rev:f322a954602 4fb20acf029a0a7 2580d6c6ec6178 /jenkins. canonical. com/server- team/job/ curtin- ci/249/ /jenkins. canonical. com/server- team/job/ curtin- ci/nodes= metal-amd64/ 249/ /jenkins. canonical. com/server- team/job/ curtin- ci/nodes= metal-arm64/ 249/ /jenkins. canonical. com/server- team/job/ curtin- ci/nodes= metal-ppc64el/ 249/ /jenkins. canonical. com/server- team/job/ curtin- ci/nodes= metal-s390x/ 249/
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
Click here to trigger a rebuild: /jenkins. canonical. com/server- team/job/ curtin- ci/249/ /rebuild
https:/