Skip to content

Display network information of checkpoints created with Podman #162

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
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

deveshgoyal1000
Copy link

This PR implements support for displaying network information (IP and MAC addresses) from Podman container checkpoints, addressing issue.

Currently, checkpointctl shows IP address information for checkpoints created with CRI-O but not with Podman. For Podman checkpoints, this information is stored in network.status in JSON format.

Implementation:

  • Added network.status file parsing functionality
  • Added IP and MAC address display to checkpoint show output
  • Added test coverage for network information parsing

Testing Results:
Before (Original Output) and After (With Network Information output)

Screenshot (1191)

Screenshot (1195)

The implementation successfully displays:

  • Container's IP address
  • MAC address
  • Maintains existing checkpoint information

Fixes #132

Copy link

github-actions bot commented Apr 5, 2025

Test Results

61 tests  ±0   61 ✅ ±0   2s ⏱️ ±0s
 1 suites ±0    0 💤 ±0 
 1 files   ±0    0 ❌ ±0 

Results for commit 7669ce5. ± Comparison against base commit 2eec433.

♻️ This comment has been updated with latest results.

@adrianreber
Copy link
Member

Please have a look at the CI failures and try to fix them.

Also, please rebase and remove the merge commit.

@adrianreber
Copy link
Member

You should also remove the dependabot commit from your PR.

@rst0git
Copy link
Member

rst0git commented Apr 5, 2025

@deveshgoyal1000 Thank you for working on this! In addition to Adrian's comments, it would be great if you can add more detailed commit messages. The following contributor guide provides more information: https://github.com/checkpoint-restore/criu/blob/criu-dev/CONTRIBUTING.md#describe-your-changes

@deveshgoyal1000
Copy link
Author

Thanks for the feedback! I’ll start working on the suggested updates.

Signed-off-by: deveshgoyal1000 <devesh.21bcon427@jecrcu.edu.in>
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 74.02597% with 20 lines in your changes missing coverage. Please review.

Project coverage is 71.41%. Comparing base (88acd95) to head (7669ce5).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
internal/podman_network.go 43.75% 9 Missing ⚠️
internal/container.go 88.23% 5 Missing and 1 partial ⚠️
internal/oci_image_build.go 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #162      +/-   ##
==========================================
- Coverage   71.43%   71.41%   -0.02%     
==========================================
  Files          13       14       +1     
  Lines        1565     1599      +34     
==========================================
+ Hits         1118     1142      +24     
- Misses        373      384      +11     
+ Partials       74       73       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

if specDump.Annotations["io.container.manager"] == "libpod" {
// Create temp dir for network status file
tmpDir, err := os.MkdirTemp("", "network-status")
if err == nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We would like to return the error here (possible wrapped with some context)


// Extract network.status file
err = UntarFiles(task.CheckpointFilePath, tmpDir, []string{metadata.NetworkStatusFile})
if err == nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

if err == nil {
networkStatusFile := filepath.Join(tmpDir, metadata.NetworkStatusFile)
ip, mac, err := getPodmanNetworkInfo(networkStatusFile)
if err == nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

Comment on lines +111 to +114
if strings.Contains(err.Error(), "unexpected end of JSON input") {
return nil, fmt.Errorf("config.dump: unexpected end of JSON input")
}
return nil, fmt.Errorf("config.dump: %w", err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if strings.Contains(err.Error(), "unexpected end of JSON input") {
return nil, fmt.Errorf("config.dump: unexpected end of JSON input")
}
return nil, fmt.Errorf("config.dump: %w", err)
return nil, fmt.Errorf("config.dump: %w", err)

I don't think we need the special case since we are wrapping with context.

Comment on lines +118 to +124
if os.IsNotExist(err) {
return nil, fmt.Errorf("spec.dump: no such file or directory")
}
if strings.Contains(err.Error(), "unexpected end of JSON input") {
return nil, fmt.Errorf("spec.dump: unexpected end of JSON input")
}
return nil, fmt.Errorf("spec.dump: %w", err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if os.IsNotExist(err) {
return nil, fmt.Errorf("spec.dump: no such file or directory")
}
if strings.Contains(err.Error(), "unexpected end of JSON input") {
return nil, fmt.Errorf("spec.dump: unexpected end of JSON input")
}
return nil, fmt.Errorf("spec.dump: %w", err)
return nil, fmt.Errorf("spec.dump: %w", err)

I don't think we need the special case since we are wrapping with context.

"IP",
"MAC",
"CHKPT Size",
"Root FS Diff Size",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"Root FS Diff Size",
"Root FS Diff",

Would it make sense to drop the "size" suffix, since the field ought to make it clear that we are talking about the size?

Comment on lines +158 to +160
if strings.Contains(err.Error(), "Error: ") {
return fmt.Errorf("%s", strings.TrimPrefix(err.Error(), "Error: "))
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems unnecessary

}

return "", "", nil
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a newline at the end of the file :)

if err == nil {
t.Error("getPodmanNetworkInfo should fail with invalid JSON")
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a newline at the end of the file :)

@snprajwal
Copy link
Member

Oh also, it looks like you need to format the files correctly

@deveshgoyal1000
Copy link
Author

Yes, I’m working on it. Thanks for the detailed review and suggestions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Display network information of checkpoints created with Podman
5 participants