-
Notifications
You must be signed in to change notification settings - Fork 10.3k
etcdmain: centralize exit handling #21081
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?
Conversation
|
Hi @majiayu000. 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. DetailsInstructions 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. |
|
This doesn't follow the proposal at #21032 (comment), please align. |
6e32546 to
68a3f58
Compare
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: majiayu000, serathius The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
Please sign the DCO |
68a3f58 to
eeb0047
Compare
Signed-off-by: majiayu000 <[email protected]>
eeb0047 to
2f8b52b
Compare
|
Sorry for the dco, caused by a new computer. |
|
/ok-to-test |
|
@majiayu000: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. DetailsInstructions 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. I understand the commands that are listed here. |
Codecov Report❌ Patch coverage is
Additional details and impacted files
... and 17 files with indirect coverage changes @@ Coverage Diff @@
## main #21081 +/- ##
==========================================
+ Coverage 68.44% 68.48% +0.03%
==========================================
Files 429 429
Lines 35281 35303 +22
==========================================
+ Hits 24149 24178 +29
+ Misses 9732 9729 -3
+ Partials 1400 1396 -4 Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
|
Please fix: |
| case errors.Is(perr, flag.ErrHelp): | ||
| fmt.Println(flagsline) | ||
| os.Exit(0) | ||
| return ErrExitOK |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about returning nil here?
without ErrExitOK, it's easy to handle error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the comment!
The reason for using ErrExitOK instead of nil is to control the execution flow.
In startEtcdOrProxyV2Error, we call cfg.parse(args). If cfg.parse returns nil (as suggested for the --help case), the function would assume everything is fine and continue to execute the subsequent logic (initializing the logger and eventually calling startEtcd to boot up the server).
For --help and --version, we want to terminate the flow immediately and exit with 0. Since we wanted to avoid calling os.Exit deeply inside config.go, returning a specific sentinel error ErrExitOK allows us to bubble up this "exit request" to the main entry point and handle it gracefully there.
What\n- funnel startEtcdOrProxyV2 exit paths through a single osutil.Exit call\n- convert config parsing help/version/flag exits into exit errors\n- add a small exit code helper for etcdmain\n\n## Why\nFollow-up to #21032 (step 2 after #21062) to unify exit calls.\n\n## Testing\n- not run (not requested)