-
Notifications
You must be signed in to change notification settings - Fork 182
cosa diff: add support for diffing metal images #4226
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
Conversation
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.
Code Review
This pull request introduces a valuable feature for diffing metal images by utilizing guestfs
and multiprocessing to efficiently compare images. However, there are critical issues with process lifecycle management and cleanup that could lead to resource leaks or crashes. Addressing these issues is important for the stability of this new feature.
3d0140e
to
1a0a833
Compare
This add two flags: `--metal` and `metal-part-table`. The former will mount the disk partitions using guestfs tools to the tmp-diff directory, then call git diff over the two mounted filesystems. It requires multithreading because the FUSE mount call is blocking so we mount the disks in two libreguest VMs that run in separate threads. A simpler approach would have been to copy all the content to the tmp-diff folder but that would copy a lot of data just for diffing. It may be faster though. The second flag `--metal-part-table` will simply show the partition table for the two images.
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.
LGTM
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.
Nice work! I like the use of the libguestfs Python bindings.
for i, d in enumerate([mount_dir_from, mount_dir_to]): | ||
p = p_from if i == 0 else p_to |
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.
Minor/optional: I think a cleaner way to do this is:
for (p, d) in [(p_from, mount_dir_from), (p_to, mount_dir_to)]:
def diff_metal_partitions(diff_from, diff_to): | ||
metal_from = get_metal_path(diff_from) | ||
metal_to = get_metal_path(diff_to) | ||
diff_cmd_outputs(['sgdisk', '-p'], metal_from, metal_to) |
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 we should use sfdisk
here instead.
# Mount the disks in the guestfs VM | ||
root = g.findfs_label("root") | ||
g.mount_ro(root, "/") | ||
boot = g.findfs_label("boot") | ||
g.mount_ro(boot, "/boot") | ||
efi = g.findfs_label("EFI-SYSTEM") | ||
g.mount_ro(efi, "/boot/efi") |
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.
Totally fine to start, though this will need adjustments to make it usable on other arches.
And we should definitely check other arches as part of coreos/fedora-coreos-tracker#1827.
This add two flags:
--metal
andmetal-part-table
.The former will mount the disk partitions using guestfs tools to the tmp-diff directory, then call git diff over the two mounted filesystems. It requires multithreading because the FUSE mount call is blocking so we mount the disks in two libreguest VMs that run in separate threads.
A simpler approach would have been to copy all the content to the tmp-diff folder but that would copy a lot of data just for diffing. It may be faster though.
The second flag
--metal-part-table
will simply show the partition table for the two images.