-
Notifications
You must be signed in to change notification settings - Fork 3.2k
fix: Clarify error message for podman restore without --tcp-established #29026
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
simek-m
wants to merge
1
commit into
podman-container-tools:main
Choose a base branch
from
simek-m:fix/RHEL-186005-restore-tcp-established
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.
+98
−6
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
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 |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| //go:build !remote && (linux || freebsd) | ||
|
|
||
| package libpod | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| // TestParseOCIErrors verifies parsing of multiple ociErrors | ||
| // from a log file. | ||
| func TestParseOCIErrors(t *testing.T) { | ||
| log := []byte(`{"msg":"(00.022100) Error (criu/sk-inet.c:654): Connected TCP socket in image","level":"error","time":"2025-01-01T00:00:00Z"} | ||
| {"msg":"(00.022200) Error (criu/cr-restore.c:2522): Restoring FAILED.","level":"error","time":"2025-01-01T00:00:01Z"} | ||
| {"msg":"(00.022418) Error (criu/cgroup.c:1970): cg: cgroupd: recv req error: No such file or directory","level":"error","time":"2025-01-01T00:00:02Z"} | ||
| `) | ||
|
|
||
| errs, err := parseOCIErrors(log) | ||
| require.NoError(t, err) | ||
|
|
||
| // Verify that all 3 messages are parsed. | ||
| assert.Equal(t, []ociError{ | ||
| {Msg: "(00.022100) Error (criu/sk-inet.c:654): Connected TCP socket in image", Level: "error", Time: "2025-01-01T00:00:00Z"}, | ||
| {Msg: "(00.022200) Error (criu/cr-restore.c:2522): Restoring FAILED.", Level: "error", Time: "2025-01-01T00:00:01Z"}, | ||
| {Msg: "(00.022418) Error (criu/cgroup.c:1970): cg: cgroupd: recv req error: No such file or directory", Level: "error", Time: "2025-01-01T00:00:02Z"}, | ||
| }, errs) | ||
| } | ||
|
|
||
| // TestCheckOCIErrorsForTCPEstablished tests matching | ||
| // of "Connected TCP socket in image" errors in a log file. | ||
| func TestCheckOCIErrorsForTCPEstablished(t *testing.T) { | ||
| withTCP := []ociError{ | ||
| {Msg: "(00.022100) Error (criu/sk-inet.c:654): Connected TCP socket in image", Level: "error"}, | ||
| {Msg: "(00.022200) Error (criu/cr-restore.c:2522): Restoring FAILED.", Level: "error"}, | ||
| {Msg: "(00.022418) Error (criu/cgroup.c:1970): cg: cgroupd: recv req error: No such file or directory", Level: "error"}, | ||
| } | ||
|
|
||
| err := checkOCIErrorsForTCPEstablished(withTCP) | ||
|
|
||
| // Verify that the log message is matched and expected error converted. | ||
| require.Error(t, err) | ||
| assert.Contains(t, err.Error(), "--tcp-established") | ||
|
|
||
| withoutTCP := []ociError{ | ||
| {Msg: "some other OCI runtime error", Level: "error"}, | ||
| } | ||
|
|
||
| // Verify that different message is not matched. | ||
| err = checkOCIErrorsForTCPEstablished(withoutTCP) | ||
| assert.NoError(t, err) | ||
| } |
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
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.
that does not seem maintainable, we should not make assumptions about the error text from crun or criu, it changes often enough. Sure the tests depend on it to some extend but we should not make the code depend, i.e. this may not work for another runtime.
It would be better to work with crun and criu to produce better errors to begin with.