Skip to content

BUG/MINOR: main: exit with non-zero code on panic - #850

Merged
oktalz merged 1 commit into
haproxytech:masterfrom
locker95:fix-exit-code-on-panic
Sep 3, 2026
Merged

BUG/MINOR: main: exit with non-zero code on panic#850
oktalz merged 1 commit into
haproxytech:masterfrom
locker95:fix-exit-code-on-panic

Conversation

@locker95

@locker95 locker95 commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

When the controller runs in external mode and the Kubernetes API is unreachable at startup, k8s.New ends up in logger.Panicf. The deferred recover in main prints the error but exitCode is still 0 at that point, so the process exits successfully. Under systemd with Restart=on-failure the unit is considered cleanly stopped and is never restarted, leaving the ingress controller down until someone notices.

Set exitCode to 1 in the recover branch so a panic still prints the same message but reports failure to the init system.

Fixes #834

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
oktalz force-pushed the fix-exit-code-on-panic branch from 8dc0f9b to df311c1 Compare September 3, 2026 11:23
@oktalz
oktalz merged commit e904182 into haproxytech:master Sep 3, 2026
8 checks passed
@oktalz

oktalz commented Sep 3, 2026

Copy link
Copy Markdown
Member

@locker95 thx!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

External mode: controller exits with status 0 after fatal Kubernetes API initialization failure

2 participants