-
Notifications
You must be signed in to change notification settings - Fork 206
cmd: harden main lifecycle and panic handling #1954
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
base: main
Are you sure you want to change the base?
cmd: harden main lifecycle and panic handling #1954
Conversation
Refactors `cmd/main.go` to use the main delegate pattern to ensure proper application lifecycle management. Changes: - Delegates logic to a `run()` function to ensure `defer` statements execute before `os.Exit` is called. - Adds top-level panic recovery to capture and log stack traces during initialization, aiding in debugging crash loops. - Initializes a bootstrap logger to capture startup errors before the controller runtime manager is fully configured.
✅ Deploy Preview for gateway-api-inference-extension ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: LukeAVanDrie The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
Hi @LukeAVanDrie. Thanks for your PR. I'm waiting for a github.com member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
/ok-to-test |
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
This PR hardens the
cmd/main.goentrypoint by refactoring the application lifecycle to use a dedicatedrun()function.Reasoning:
os.Exitimmediately terminates the program, preventing pendingdeferstatements from executing. By delegating logic torun()and checking the error inmain, we ensure the stack unwinds and cleanups happen before the exit code is set.recover()handler. If the application panics during initialization (e.g., bad config, nil pointer), this ensures the stack trace is logged as a structured error rather than printing to stderr and exiting silently. This is critical for debugging K8s CrashLoopBackOff states.Which issue(s) this PR fixes:
N/A
Does this PR introduce a user-facing change?: