-
Notifications
You must be signed in to change notification settings - Fork 202
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
dapr run
shut down app and daprd gracefully
#696
Conversation
Codecov Report
@@ Coverage Diff @@
## master #696 +/- ##
==========================================
+ Coverage 21.82% 21.92% +0.10%
==========================================
Files 29 29
Lines 1535 1537 +2
==========================================
+ Hits 335 337 +2
Misses 1159 1159
Partials 41 41
Continue to review full report at Codecov.
|
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.
@pkedy Is there a specific reason to load a DLL file to call an event in windows? Is there any other simpler way to do this?
@artursouza @wcs1only Thoughts on this change?
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.
nit: there is a commented out line of code. If not needed, please, remove.
@@ -359,10 +359,9 @@ func testRun(t *testing.T) { | |||
output, err := spawn.Command(daprPath, "run", "--dapr-http-port", "9999", "--", "bash", "-c", "curl -v http://localhost:9999/v1.0/shutdown; sleep 10; exit 1") | |||
t.Log(output) | |||
require.NoError(t, err, "run failed") | |||
assert.Contains(t, output, "Exited App successfully", "App should be shutdown before it has a chance to return non-zero") | |||
//assert.Contains(t, output, "Exited App successfully", "App should be shutdown before it has a chance to return non-zero") |
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.
Why is this commented out?
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.
I was trying to keep that check, but I could not find a way too. I'll put a comment there instead.
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.
Is the output different from what was expected?
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.
Its been a while since I was working on this, but the issue is that if you send curl
a CRTL-C/interrupt, it still comes back with a non-zero exit code depending on the OS. We need a process that exits with 0
even if sent an interrupt/ctrl-c.
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.
Have you tried trap
? Also, it is not curl that is getting interrupted here, it is the sleep.
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.
Thought about it but avoided that in case we can get Windows docker working for GitHub actions. (That would also assume Windows would have some form of curl installed)
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.
In the grand scheme of things, Im not 💯 sure we really should test the exit code of the app, just that it ran and existed. In Daprd, it has explicit code to exit with 0
if it is interrupted. Most apps don't do that.
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.
Windows github actions has curl. This test works on windows today.
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.
In the grand scheme of things, Im not 💯 sure we really should test the exit code of the app, just that it ran and existed. In Daprd, it has explicit code to exit with
0
if it is interrupted. Most apps don't do that.
That's fine if they don't do that. There is no harm in telling the user what the return code was.
@mukundansundar Depending on a DLL is a problem. We should avoid that. I saw that the latest version does not have that so I am fine with this. |
assert.Contains(t, output, "Exited App successfully", "App should be shutdown before it has a chance to return non-zero") | ||
// It would be ideal to check that the spawned app existed with a non-zero | ||
// exit code, however when sending a SIGINT/CTRL-C to curl, it does not. | ||
// In the future we could find a program that returns 0 in this scenario. |
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.
You might as well not have have this test at all without this check. The exit 1 is how we tell the difference between "shutdown received and respected" vs "shutdown ignored".
willardstanley@Willards-MacBook-Pro cli % bash -c 'trap "exit 0" SIGINT; sleep 200; exit 12'; echo $?
^C0
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.
But it doesn't even have to be that sophisticated you could just change exit 1
to echo -e "\nSHOULD_NEVER_GET_EXECUTED"
and then do a NotContains"== APP == SHOULD_NEVER_GET_EXECUTED"
on the output. The point is, we shouldn't just turn off a test like this...
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.
Litmus test: If you mangle the curl URL, so that the shutdown API doesn't get called, does the test fail like it should?
Did you run the E2E tests on windows? When I run them on my Windows box for this change, they fail quite hard.
It looks like the parent process is getting the interrupt as well. I suspect that you need to set the CREATE_NEW_PROCESS_GROUP on the processes that the CLI spawns in order to safely send a CTL_BREAK to them. See https://docs.microsoft.com/en-us/windows/win32/procthread/process-creation-flags for more info.
|
…them immediately. This allows the processes to clean up appropriately.
dec9403
to
b43ffa1
Compare
@pkedy Is this PR still valid? |
@mukundansundar Yes, I think this is still valid. Last I looked at it the tests were hanging. Now that #835 is in, I'll take another look. |
This pull request has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions! |
This pull request has been automatically closed because it has not had activity in the last 37 days. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions! |
@pkedy Can this PR be reopened and will you be looking into this? |
Send the running app and dapr an interrupt signal instead of killing them immediately. This allows the processes to clean up appropriately.
Description
This PR makes a change to send interrupt signals to the application and daprd processes and waits for them to shutdown gracefully instead of killing them immediately. The user will see the 5 second delay for outstanding requests to finish.
Issue reference
Resolves #695
Checklist
Please make sure you've completed the relevant tasks for this PR, out of the following list: