-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Fix hangs in core SDK when monitor unavailable #7734
Merged
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
67d2613
to
6d8e588
Compare
|
EvanBoyle
approved these changes
Aug 10, 2021
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.
Nice find! Fix appears unsurprising, but I am not an expert on our python runtime. May want to get a second opinion (perhaps Justin?).
justinvp
approved these changes
Aug 11, 2021
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.
LGTM
t0yv0
added a commit
that referenced
this pull request
Aug 11, 2021
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.
Description
History
Problem
In the above PR we have replaced
sys.exit(1)
with not raising an exception in cases when the monitor service becomes unresponsive over gRPC, which is typical of shutdown scenarios. Unfortunately this means that various exception handlers and try_finally blocks for register_resource and similar are not firing in this case. I have read and stepped through the code and I do not think the code path is properly handled outside of the exception handlers. In particular, futures are left dangling. This can cause hangs if something is waiting on those futures. This can include the genericwait_for_rpcs
waiter.The user reports a failing program in #7036 that triggers this condition:
In the register_resource of
gcp.serviceaccount.Account
, futures are created that are not fulfilled, likely because an error in validating the Account props get detected elsewhere and causes monitor gRPC server termination. The use of Auto API seems essential to create this asynchrony.Fix
The suggested fix is throwing RunError which is included in the SDK to represent "quiet" errors in this situation. Throwing an error triggers the usual exception handlers. The hangs are removed, and the user receives a compact "error: Resource monitor has terminated, shutting down". Unfortunately, https://github.com/pulumi/pulumi/pull/6249/files comes without a test so this might be accidentally regressing what that PR was fixing.
Issues
Fixes #7036
Checklist