BUG/MINOR: main: exit with non-zero code on panic - #850
Merged
Conversation
A panic during startup (e.g. Kubernetes API unreachable in external mode) is recovered in main's deferred handler, which printed the error but left exitCode at 0. Under systemd with Restart=on-failure the process was considered cleanly stopped and never restarted. Set exitCode to 1 in the recover branch.
oktalz
force-pushed
the
fix-exit-code-on-panic
branch
from
September 3, 2026 11:23
8dc0f9b to
df311c1
Compare
Member
|
@locker95 thx! |
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.
When the controller runs in external mode and the Kubernetes API is unreachable at startup,
k8s.Newends up inlogger.Panicf. The deferred recover in main prints the error butexitCodeis still 0 at that point, so the process exits successfully. Under systemd withRestart=on-failurethe unit is considered cleanly stopped and is never restarted, leaving the ingress controller down until someone notices.Set
exitCodeto 1 in the recover branch so a panic still prints the same message but reports failure to the init system.Fixes #834