fix(lib): maybe_reload_networkd must not fail EXIT trap when EC2_IF_INITIAL_SETUP is unset#145
Open
mjnowen wants to merge 2 commits intoamazonlinux:mainfrom
Open
fix(lib): maybe_reload_networkd must not fail EXIT trap when EC2_IF_INITIAL_SETUP is unset#145mjnowen wants to merge 2 commits intoamazonlinux:mainfrom
mjnowen wants to merge 2 commits intoamazonlinux:mainfrom
Conversation
… needed maybe_reload_networkd runs under an EXIT trap with set -e. The branch that skips networkctl reload used `[ -v EC2_IF_INITIAL_SETUP ] && debug ...`. When EC2_IF_INITIAL_SETUP is unset (typical refresh runs), the test fails with status 1, the trap returns non-zero, and systemd reports failure even though setup-policy-routes completed successfully.
joeysk2012
reviewed
Mar 25, 2026
Addressed review: applied the same fix as in amazonlinux#144’s intent everywhere [ -v EC2_IF_INITIAL_SETUP ] && debug appears in lib/lib.sh (get_meta, maybe_reload_networkd else branch, and the EXIT trap in register_networkd_reloader) so none of these return non-zero when the variable is unset under set -e.
Contributor
|
Looks good. |
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.
refresh-policy-routes@.service(oneshot) often exited 1 after a successful run becausemaybe_reload_networkdreturned non-zero from theEXITtrap when nonetworkctl reloadwas required andEC2_IF_INITIAL_SETUPwas unset.Before
journalctl -u 'refresh-policy-routes@ens5.service' -o catAfter
Change
In
maybe_reload_networkd, replace:[ -v EC2_IF_INITIAL_SETUP ] && debug "No networkd reload needed"with an
if [ -v EC2_IF_INITIAL_SETUP ]; then debug ...; fiso the else branch does not end on a failing[when the variable is unset.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.