coreos / rpm-ostree

⚛📦 Hybrid image/package system with atomic upgrades and package layering
https://coreos.github.io/rpm-ostree
Other
857 stars 195 forks source link

rpm script output not always printed #4468

Open champtar opened 1 year ago

champtar commented 1 year ago

rpm scripts outputs are often not printed, so we potentially missing important errors or warnings

Host system details Alma 8.8 build host (rpm-ostree 2022.10...)

Expected vs actual behavior

# rpm-ostree compose tree --unified-core

Checking out packages... done
Running pre scripts... 18 done
⠙ Running post scripts... zlib
readline.post: install-info: No such file or directory for /usr/share/info/history.info
⠒ Running post scripts... readline
⠂ Running post scripts... nettle
⠂ Running post scripts... file-libs
[...]
⠓ Running post scripts... grub2-tools
grub2-tools.post: install-info: No such file or directory for /usr/share/info/grub2.info.gz
⠉ Running post scripts... cockpit-ws

Expected: ALL ouputs from rpm scripts are printed (put |& cat after the command)

``` Input state hash: XXX Relabeling...done Checking out packages...done Running pre scripts...18 done Running post scripts...done Running posttrans scripts...24 done Writing rpmdb...done readline.post: install-info: No such file or directory for /usr/share/info/history.info readline.post: install-info: No such file or directory for /usr/share/info/rluserman.info sed.post: install-info: No such file or directory for /usr/share/info/sed.info.gz nettle.post: install-info: No such file or directory for /usr/share/info/nettle.info grep.post: install-info: No such file or directory for /usr/share/info/grep.info.gz diffutils.post: install-info: No such file or directory for /usr/share/info/diffutils.info gettext.post: install-info: No such file or directory for /usr/share/info/gettext.info.gz binutils.post: install-info: No such file or directory for /usr/share/info/as.info.gz binutils.post: install-info: No such file or directory for /usr/share/info/binutils.info.gz binutils.post: install-info: No such file or directory for /usr/share/info/gprof.info.gz binutils.post: install-info: No such file or directory for /usr/share/info/ld.info.gz binutils.post: install-info: No such file or directory for /usr/share/info/standards.info.gz systemd-udev.post: Failed to create directory /var/lib/systemd: Read-only file system device-mapper-event.post: rpm-ostree-systemctl: Ignored non-preset command: enable dm-event.socket chrony.post: rpm-ostree-systemctl: Ignored non-preset command: daemon-reload wget.post: install-info: No such file or directory for /usr/share/info/wget.info.gz grub2-tools.post: install-info: No such file or directory for /usr/share/info/grub2.info.gz grub2-tools.post: install-info: No such file or directory for /usr/share/info/grub2-dev.info.gz cockpit-ws.post: libsemanage.semanage_direct_install_info: Overriding cockpit module at lower priority 100 with module at priority 200. lvm2.post: rpm-ostree-systemctl: Ignored non-preset command: enable lvm2-monitor.service lvm2.post: rpm-ostree-systemctl: Ignored non-preset command: enable lvm2-lvmpolld.socket epel-release.post: Many EPEL packages require the CodeReady Builder (CRB) repository. epel-release.post: It is recommended that you run /usr/bin/crb enable to enable the CRB repository. Regenerating rpmdb for target Relabeling...done Executing postprocessing script ```

note that when using the workaround the *.post outputs are printed pretty late (should be between post and posttrans lines)

Steps to reproduce it Replace bwrap with a small script to log, look at the logs

mv /usr/bin/bwrap /usr/bin/bwrap-original
cat > /usr/bin/bwrap <<'EOF'
#!/bin/bash
mkdir -p /tmp/bwrap-logs
bwrap-original "$@" |& tee /tmp/bwrap-logs/$$
EOF

As a workaround you can also add |& cat after the command

I think we need to stop the spinner and or flush stdout and or set the buffering mode to line somewhere.

Would you like to work on the issue? No

cgwalters commented 1 year ago

Yeah, the current state is just embarrassing.

I think we need to stop the spinner and or flush stdout and or set the buffering mode to line somewhere.

Mmm...I think rather instead we should buffer stdout/stderr from scripts to an O_TMPFILE or so, and then display it at the end?

Or I guess, after each script is run, detect if we had any output, and if so then stop spinner, output and then restart.

champtar commented 1 year ago

I think it's already buffered from quickly looking at the code https://github.com/coreos/rpm-ostree/blob/4de52c41c5ec8f348cec9f30613d4e30ff0fbc71/src/libpriv/rpmostree-scripts.cxx#L257 but haven't tried to troubleshoot further as I have a workaround