-
Notifications
You must be signed in to change notification settings - Fork 354
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 graceful shutdown when intermediate or init process errors or panic #238
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
utam0k
reviewed
Aug 28, 2021
Comment on lines
+113
to
+121
unistd::close(self.receiver.as_raw_fd())?; | ||
|
||
Ok(()) | ||
} | ||
|
||
pub fn close_sender(&self) -> Result<()> { | ||
unistd::close(self.sender.as_raw_fd())?; | ||
|
||
Ok(()) |
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.
How about this code?
Suggested change
unistd::close(self.receiver.as_raw_fd())?; | |
Ok(()) | |
} | |
pub fn close_sender(&self) -> Result<()> { | |
unistd::close(self.sender.as_raw_fd())?; | |
Ok(()) | |
unistd::close(self.receiver.as_raw_fd()) | |
} | |
pub fn close_sender(&self) -> Result<()> { | |
unistd::close(self.sender.as_raw_fd()) |
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.
unistd functions will return a different error type than anyhow result, so we have to use ?
for a conversion.
Furisto
approved these changes
Aug 28, 2021
Co-authored-by: utam0k <[email protected]>
This reverts commit 50bb5de.
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.
Fix #237 Tracking #221
Gracefully shutdown by closing down unused fds in the channel. In this case, when the child process exits, the parent waiting (read_exact) is exit blocking and error out. When fork, the fds in the channel are duplicated, so there are two receivers and two senders. Since we force the channel to become uni-directional, we can safely close the additional fds.
Also in the PR, we should only set host name when entering into a new UTS namespace. One of the integration test doesn't create any new uts namespace, so calling set_hostname is not a good idea.
Now pass one more integration test. The test essentially asks Youki to enter into the wrong type of namespace and see if Youki will error out.