-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Enable checkpoint/restore support with gVisor #27528
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
Open
rst0git
wants to merge
1
commit into
containers:main
Choose a base branch
from
rst0git:gvisor-checkpoint-restore
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+26
−3
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -216,9 +216,22 @@ func CRRuntimeSupportsCheckpointRestore(runtimePath string) bool { | |
| if err := cmd.Start(); err != nil { | ||
| return false | ||
| } | ||
| if err := cmd.Wait(); err == nil { | ||
|
|
||
| err := cmd.Wait() | ||
| if err == nil { | ||
| // Exited with status 0 means definitely supported. | ||
| return true | ||
| } | ||
|
|
||
| if exitErr, ok := err.(*exec.ExitError); ok { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. new code should use errors.Is/As() as erros can be wrapped in which case type casting won't work. |
||
| status := exitErr.ExitCode() | ||
| // "runsc checkpoint --help" exits with 128 (subcommands.ExitUsageError) | ||
| // and 127 is used for "command not found". | ||
| if status == 128 { | ||
| return true | ||
| } | ||
| } | ||
|
|
||
| return false | ||
| } | ||
|
|
||
|
|
||
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.
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.
Feels like we should only do this if we know the runtime is
runsc; 128 could be a legitimate error in other OCI runtimes. I imagine we could get that from the output of--helpbut it might also be sufficient to just check that the filename we're executing is runsc?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 think the --help check was because some runtimes (at least crun) have build option to enable/disable it thus the runtime check via --help IIRC.
That said did you ask them why they exit 128 on --help? That just seems really weird and from the applications I tested I never seen this behavior at least if they have --help actually implemented.
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.
Yes, crun has an optional dependency on libcriu and uses dlopen to load the library at runtime. When build without this dependency,
crun checkpoint --helpwill have non-zero exit code.gVisor returns
subcommands.ExitUsageError(128) when--helpis used:It seems to be specific to google's subcommands pacakge.
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 that isn't even calling
--helpthen, it actually errors our on incorrect usage because it doesn't seem to respect--helpat all which means this check isn't really doing anything useful.Then we might as well hard code checkpoint support for the runsc name I would say.
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.
FYI, this should be fixed by google/gvisor#12331.
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.
@nixprime Thank you!