-
Notifications
You must be signed in to change notification settings - Fork 290
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
Provides ExitCode Shutdowner Option; and Wait method to receive it. #989
Merged
Conversation
This file contains 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
sywhang
reviewed
Nov 16, 2022
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.
Took a first pass. Looking good!
Codecov Report
@@ Coverage Diff @@
## master #989 +/- ##
==========================================
+ Coverage 98.32% 98.39% +0.07%
==========================================
Files 39 39
Lines 1908 1994 +86
==========================================
+ Hits 1876 1962 +86
Misses 25 25
Partials 7 7
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
JacobOaks
reviewed
Nov 18, 2022
jasonmills
force-pushed
the
shutdown_code
branch
from
December 5, 2022 21:01
2449bf8
to
eb73d5c
Compare
sywhang
reviewed
Dec 6, 2022
Co-authored-by: Sung Yoon Whang <[email protected]>
Co-authored-by: Sung Yoon Whang <[email protected]>
Co-authored-by: Sung Yoon Whang <[email protected]>
Co-authored-by: Sung Yoon Whang <[email protected]>
Co-authored-by: Sung Yoon Whang <[email protected]>
Co-authored-by: Sung Yoon Whang <[email protected]>
Co-authored-by: Sung Yoon Whang <[email protected]>
Co-authored-by: Sung Yoon Whang <[email protected]>
Co-authored-by: Sung Yoon Whang <[email protected]>
Co-authored-by: Sung Yoon Whang <[email protected]>
jasonmills
force-pushed
the
shutdown_code
branch
from
December 7, 2022 21:48
e1dcb8e
to
29097e2
Compare
sywhang
approved these changes
Dec 7, 2022
sywhang
added a commit
that referenced
this pull request
Jan 9, 2023
This fixes #1015. When Start() is called, it passes StartTimeout to the relayer goroutine, which is monitoring the Stop signal, as well as the OS signal handler. It then exits the goroutine if the start context expires, which would naturally happen if the user uses the default setting (15s timeout) or any finite amount of timeout value. This causes the app to then be not responsive to any OS signals such as SIGTERM or SIGINT. This was a regression introduced in 1.19 release via #989 . To fix this, this commit simply removes the relayer goroutine from selecting on the start context being completed. Verified that all tests are still passing without any goroutine leak, except one test that was triggering a panic to test the panic handler. To prevent that one test from opting out every single test into goleak.VerifyNone(t) in every sub test, I pulled out that panic test into a separate test package so that we can continue to use goleak.VerifyNone() method in app_test.
abhinav
added a commit
to abhinav/fx
that referenced
this pull request
Apr 29, 2023
We added support for changing the exit code for a Shutdowner with the ExitCode option in uber-go#989, but this was somehow not respected by App.Run. This changes App.Run to use the same underlying machinery (`Wait()`) to decide on the exit code to use. Resolves uber-go#1074
abhinav
added a commit
to abhinav/fx
that referenced
this pull request
Apr 29, 2023
We added support for changing the exit code for a Shutdowner with the ExitCode option in uber-go#989, but this was somehow not respected by App.Run. This changes App.Run to use the same underlying machinery (`Wait()`) to decide on the exit code to use. Resolves uber-go#1074
sywhang
pushed a commit
that referenced
this pull request
Apr 29, 2023
We added support for changing the exit code for a Shutdowner with the ExitCode option in #989, but this was somehow not respected by App.Run. This changes App.Run to use the same underlying machinery (`Wait()`) to decide on the exit code to use. To test this, we add a new internal/e2e submodule that will hold full, end-to-end integration tests. These can be full Fx applications that we run tests against. This is a submodule so that it can have dependencies that are not desirable as direct dependencies of Fx, and it's inside the internal/ directory so that it can consume Fx-internal packages (like testutil). The included regression test verifies the behavior described in #1074. An Fx program using App.Run, and shut down with Shutdowner.Shutdown and an explicit exit code, does not exit with the requested exit code. Failure before the fix: ``` % go test --- FAIL: TestShutdownExitCode (0.01s) writer.go:40: [Fx] PROVIDE fx.Lifecycle <= go.uber.org/fx.New.func1() writer.go:40: [Fx] PROVIDE fx.Shutdowner <= go.uber.org/fx.(*App).shutdowner-fm() writer.go:40: [Fx] PROVIDE fx.DotGraph <= go.uber.org/fx.(*App).dotGraph-fm() writer.go:40: [Fx] INVOKE go.uber.org/fx/internal/e2e/shutdowner_run_exitcode.main.func1() writer.go:40: [Fx] RUNNING writer.go:40: [Fx] TERMINATED main_test.go:46: Error Trace: [..]/fx/internal/e2e/shutdowner_run_exitcode/main_test.go:46 Error: An error is expected but got nil. Test: TestShutdownExitCode FAIL exit status 1 FAIL go.uber.org/fx/internal/e2e/shutdowner_run_exitcode 0.016s ``` Resolves #1074 --- There's a follow up to this: abhinav#1. It depends on the e2e test machinery, so I'll make a PR out of it once this is merged.
JacobOaks
pushed a commit
that referenced
this pull request
Jun 25, 2024
closes #1212, and fixes a regression from #989. Previously we would only register signal handlers if the user intended to use them. #989 changed this behavior [here](https://github.com/uber-go/fx/pull/989/files#diff-6c4b6ed7dc8834cef100f50dae61c30ffe7775a3f3f6f5a557517cb740c44a2dR649). This regression meant that if you only used app.Start()/app.Stop(), fx would register signal handlers for no reason as the user didn't use app.Done/app.Wait.
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.
This PR provides an option for those who take dependencies on the
Shutdowner
interface to call theShutdown
method with anExitCode
option, in addition it add aWait
method to the application to allow for main programs to wait for the application to be shutdown and to exit with a given exit code.Please note that this PR refactors the existing signal relay functionality, and alters application lifecycle slightly. Now
Done
will not receive anos.Signal
on the channel it returns unless a given FX application has been started.