add missing diff socket logic#210
Conversation
|
Please add the tests to this PR as a second commit. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #210 +/- ##
==========================================
+ Coverage 79.98% 84.27% +4.28%
==========================================
Files 16 16
Lines 1759 1920 +161
==========================================
+ Hits 1407 1618 +211
+ Misses 263 224 -39
+ Partials 89 78 -11 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
of course, will add tests shortly. for now here is my manual testing output: |
|
i have added bats tests and i think its ready for review |
|
Thanks. Also add a couple of unit tests, especially for the error cases which are not covered via bats tests. |
|
i added the unit tests and try to covered the error cases too (not too much) you can take another look when you get time |
|
Looks good to me. @rst0git What do you think? The commit messages could contain some more details about the changes. |
Detect added, removed, and unchanged sockets by matching on (PID + protocol + type + addresses + ports). The results are shown as an ss(8)-style table. We use labels to avoid the ambiguity of an arrow between two endpoints, and PEER shows "-" for listeners and unconnected UDP. Example: sudo checkpointctl diff --sockets --files --ps-tree-cmd --ps-tree-env cp1.tar cp2.tar ╔════════════════════════════════════════════════════════════════╗ ║ Checkpoint Diff ║ ╠════════════════════════════════════════════════════════════════╣ ║ Container: optimistic_mclean ║ ║ Image: docker.io/library/python:alpine ║ ║ ID: 6ebe04dda2005962a8fb4e971caedfda5e03e22c882e2334... ║ ╚════════════════════════════════════════════════════════════════╝ Checkpoint A: Created: 2026-04-18T10:15:41+01:00 Size: 15186908 bytes Checkpoint B: Created: 2026-04-18T10:15:41+01:00 Size: 15212641 bytes ┌─ Memory Changes ─────────────────────────────────────────────┐ │ ↑ Increased by 0.02 MB └──────────────────────────────────────────────────────────────┘ ┌─ Process Changes ────────────────────────────────────────────┐ └──────────────────────────────────────────────────────────────┘ ┌─ File Descriptor Changes ────────────────────────────────────┐ │ Added: │ + PID 2 INETSK INETSK.29 │ Unchanged: 11 └──────────────────────────────────────────────────────────────┘ ┌─ Socket Changes ──────────────────────────────────────────────────────┐ │ PID PROTO STATE LOCAL PEER │ + 2 TCP ESTABLISHED 10.88.0.3:8080 10.88.0.1:39838 │ Unchanged: 1 └───────────────────────────────────────────────────────────────────────┘ Assisted-by: Claude Code Signed-off-by: Hamza Dogar <hxadogar@gmail.com> Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
The default output now hides "Unchanged: N" entirely as this is just a numer without userful information. The --show-unchanged option lists each unchanged process, file descriptor, and socket (marked with "=") alongside the delta. This context is needed to interpret the added/removed entries. The Unchanged field on ProcessDiff/FileDiff/SocketDiff is now a slice of entries instead of a counter. The "unchanged" key is now an array (omitted when empty) rather than an integer. Example: sudo checkpointctl diff --show-unchanged --sockets --files --ps-tree-cmd --ps-tree-env cp1.tar cp2.tar ╔════════════════════════════════════════════════════════════════╗ ║ Checkpoint Diff ║ ╠════════════════════════════════════════════════════════════════╣ ║ Container: optimistic_mclean ║ ║ Image: docker.io/library/python:alpine ║ ║ ID: 6ebe04dda2005962a8fb4e971caedfda5e03e22c882e2334... ║ ╚════════════════════════════════════════════════════════════════╝ Checkpoint A: Created: 2026-04-18T10:15:41+01:00 Size: 15186908 bytes Checkpoint B: Created: 2026-04-18T10:15:41+01:00 Size: 15212641 bytes ┌─ Memory Changes ─────────────────────────────────────────────┐ │ ↑ Increased by 0.02 MB └──────────────────────────────────────────────────────────────┘ ┌─ Process Changes ────────────────────────────────────────────┐ └──────────────────────────────────────────────────────────────┘ ┌─ File Descriptor Changes ────────────────────────────────────┐ │ Added: │ + PID 2 INETSK INETSK.29 │ Unchanged: │ = PID 2 / │ = PID 2 / │ = PID 1 PIPE pipe[70435895] │ = PID 1 / │ = PID 2 INETSK INETSK.28 │ = PID 1 REG /dev/null │ = PID 1 PIPE pipe[70435894] │ = PID 1 / │ = PID 2 REG /dev/null │ = PID 2 PIPE pipe[70435894] │ = PID 2 PIPE pipe[70435895] └──────────────────────────────────────────────────────────────┘ ┌─ Socket Changes ──────────────────────────────────────────────────────┐ │ PID PROTO STATE LOCAL PEER │ + 2 TCP ESTABLISHED 10.88.0.3:8080 10.88.0.1:39838 │ = 2 TCP LISTEN 0.0.0.0:8080 - └───────────────────────────────────────────────────────────────────────┘ Assisted-by: Claude Code Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
|
@hxadogar Sorry, I pressed the wrong button. Can you remove my merge commit? I can also do it if you want. |
Check that `checkpointctl diff --sockets` reports the expected added, removed and unchanged TCP connections across checkpoints. These tests cover both the text and the JSON output. We extend the piggie process to use a pair of command and acknowledgement FIFOs ($PIGGIE_CMD_FIFO and $PIGGIE_ACK_FIFO) that allow it to spawn and terminate extra TPC clients inside its private netns. Each command is acknowledged once the action has completed (e.g., the new client's connect() call has returned). The test-imgs-diff.sh script uses this functionality to create two checkpoints with deterministic differences. This approach allows us to extend testing with additional use cases in subsequent commits. While here, we drop the hard-coded line-index assertions from the inspect --files test. They broke whenever the process tree PIDs shifted in the output. Signed-off-by: Hamza Dogar <hxadogar@gmail.com> Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
Extend piggie and the command FIFOs with actions for creating and removing UDP clients between checkpoints. Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
Signed-off-by: Hamza Dogar <hxadogar@gmail.com>
|
@adrianreber No worries! I will update the PR soon |
|
Thanks @rst0git! I was about to handle it |
Replace the ProcessTree mirror struct with internal.PsNode so diff reuses the same types as inspect. This allows to render the process-tree as an annotated treeprint when --show-unchanged is set. Each PID is prefixed with +, ~, or = for added/modified/unchanged, and PIDs only present in checkpoint A are listed separately as Removed. Enable internal.PsTree per-task in getTaskJSON when pstree.img is available so the section is actually populated (it was always empty before). The section header is renamed from "Process Changes" to "Process Tree", and print "= No change" when the trees match. Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
Add unit tests covering compareProcessTrees, flattenProcessTree, buildProcessStatusMap, and renderAnnotatedProcessTree including the blank-marker fallback for PIDs not in the status map. Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
Check that Process Tree section shows "No change" for identical checkpoints, and the annotated tree when unchanged and added PIDs. Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
|
@hxadogar I've revised the patches in this branch https://github.com/rst0git/checkpointctl/tree/socket-diff |
|
I will go ahead and merge these changes; we can make any other changes in follow-up PRs |
diff
--socketswas registered but not actually any compared logic.now shows sockets added or removed.
it handles all socket types.
i have tested and verified manually.
and i will try to follow up with a dedicated pr for tests.