-
Notifications
You must be signed in to change notification settings - Fork 184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(postinstall): ignore systemctl commands when systemd is not running #874
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, can you add a changelog note? Also, could you expand on why this is needed in chrooted setups?
Hi, I've added a changelog. When working in a chrooted environment, you're effectively isolating a portion of the filesystem and running commands within that confined space. However, systemd (the init system) is not running as PID 1 inside the chroot. This leads to issues when trying to use systemctl, as it relies on communicating with the systemd daemon, which is responsible for managing services and units. $ systemctl daemon-reload
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down Many systemd-related commands, such as In our scenario, we use a chroot environment in our CI/CD pipeline to build system images and install For package managers like dpkg, this leads to the following issues:
Therefore, this fix would be very beneficial for CI/CD pipelines. |
Understood, thanks! I understand the problem but I am not sure this is the right solution for it: unconditionally passing regardless of any errors can hide meaningful issues for users in other environments where systemd would typically work. If there is a way to check if we are in chrooted environment where systemd does not work at all, I would prefer to add such a check instead of ignoring errors |
As @netsandbox mentioned in #767, Systemd RPM macros append On Debian, most packages use
Examining the source code confirms that Debian also ignores if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ]; then
if [ -d /run/systemd/system ]; then
systemctl --system daemon-reload >/dev/null || true
if [ -n "$2" ]; then
_dh_action=#RESTART_ACTION#
else
_dh_action=start
fi
deb-systemd-invoke $_dh_action #UNITFILES# >/dev/null || true
fi
fi If the main concern is suppressing meaningful errors, we could add checks like Would you prefer this approach, or should I make any modifications? |
Thanks for being patient with me and providing all this context :)
I think this is a reasonable approach. I understand and sympathize with distro maintainers not wanting to troubleshoot this every time for every package, but given that, for our particular case, this seems to work fine for most users, I would rather take the gentler approach of checking here. We can always go more aggressive with |
The changes make it much clearer now—looks great. 🚀 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks! Will make a small change on the release note
Based on #767. This avoids package manager like
dpkg
to fail in chrooted setups.