fix(init): propagate lxc-autostart exit status in lxc-containers - #4709
Open
SudhanshuMatrix wants to merge 1 commit into
Open
SudhanshuMatrix wants to merge 1 commit into
SudhanshuMatrix wants to merge 1 commit into
Conversation
The start section in lxc-containers was executing 'rm -f' immediately after 'lxc-autostart'. This masked the exit status of the autostart action, causing the script to always return 0. By saving the exit status to a variable before removing the lock file, we ensure the correct exit code is propagated to the service manager (e.g. systemd or OpenRC). Signed-off-by: Sudhanshu Singh <sudhanshuwriterblc@gmail.com>
SudhanshuMatrix
force-pushed
the
fix/autostart-exit-code
branch
from
July 13, 2026 05:50
061ee2b to
900f3b8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR addresses an issue where the
lxc-containershelper script masks the exit status of thelxc-autostartcommand and always returns0upon starting.Since systemd (via
lxc.service), SysVinit, and OpenRC utilize this script to initialize and autostart containers, the service manager would report that the unit successfully started even when container autostarting partially or completely failed. As a consequence, failures during startup went unnoticed by monitoring tools and administrators relying on service exit status.Fixes #4661
Changes
start)case block inconfig/init/common/lxc-containers.in.lxc-autostartto a local variableres(usingres=$?).rm -f "$lockdir"/lxc.exit $resto return the original exit status oflxc-autostartback to the invoking init wrapper.Technical Context & Impact
/var/lock/subsys/lxc(or/var/lock/lxc) acts as a transient lock to prevent concurrent container startup runs. Removing it at the end of the start block is a necessary cleanup step regardless of success or failure. By caching$?first, we preventrmfrom overwriting the exit code.dash,bash, or genericsh).Type=oneshotservicelxc.serviceusinglxc-containers start)lxc-containers start)lxc-containers start)Verification & Testing
build/config/init/common/lxc-containers.lxc-autostartand0on successful runs.