-
Notifications
You must be signed in to change notification settings - Fork 35
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
Expose virtual size of qcow2 backing images #208
Conversation
e249fc0
to
0e0854e
Compare
Force push to make the 512 byte padding in |
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
0e0854e
to
a8b08c1
Compare
(rebased on latest master) |
a8b08c1
to
eca5852
Compare
This manually applies the relevant changes from longhorn/backing-image-manager#208 to vendor/github.com/longhorn/backing-image-manager because using `go get ; go mod tidy ; go mod vendor` pulls in a giant mess of other stuff that's changed in the meantime :-/ Signed-off-by: Tim Serong <[email protected]>
a2a1c0e
to
4f3b4c7
Compare
(rebased on latest master) |
This manually applies the relevant changes from longhorn/backing-image-manager#208 and longhorn/longhorn-manager#2680 to vendor/github.com/longhorn/backing-image-manager and vendor/github.com/longhorn/longhorn-manager because using `go get ; go mod tidy ; go mod vendor` pulls in a giant mess of other stuff that's changed in the meantime :-/ Signed-off-by: Tim Serong <[email protected]>
This requires: - longhorn/backing-image-manager#208 - longhorn/longhorn-manager#2680 With this change, we can do this: ``` NAME DISPLAY-NAME SIZE VIRTUALSIZE AGE image-26r4s sles15-sp5-minimal-vm.x86_64-kvm-and-xen-qu1.qcow2 267845632 25769803776 6m36s image-bgnhb sle-micro.x86_64-5.5.0-default-qcow-gm.qcow2 1001652224 21474836480 20m image-nmmvj sle-15-sp5-full-x86_64-gm-media1.iso 14548992000 14548992000 19m ``` Related issue: harvester#4905 Signed-off-by: Tim Serong <[email protected]>
This requires: - longhorn/backing-image-manager#208 - longhorn/longhorn-manager#2680 With this change, we can do this: # kubectl get vmimages NAME DISPLAY-NAME SIZE VIRTUALSIZE AGE image-26r4s sles15-sp5-minimal-vm.x86_64-kvm-and-xen-qu1.qcow2 267845632 25769803776 6m36s image-bgnhb sle-micro.x86_64-5.5.0-default-qcow-gm.qcow2 1001652224 21474836480 20m image-nmmvj sle-15-sp5-full-x86_64-gm-media1.iso 14548992000 14548992000 19m Related issue: harvester#4905 Signed-off-by: Tim Serong <[email protected]>
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
This requires: - longhorn/backing-image-manager#208 - longhorn/longhorn-manager#2680 With this change, we can do this: # kubectl get vmimages NAME DISPLAY-NAME SIZE VIRTUALSIZE AGE image-26r4s sles15-sp5-minimal-vm.x86_64-kvm-and-xen-qu1.qcow2 267845632 25769803776 6m36s image-bgnhb sle-micro.x86_64-5.5.0-default-qcow-gm.qcow2 1001652224 21474836480 20m image-nmmvj sle-15-sp5-full-x86_64-gm-media1.iso 14548992000 14548992000 19m Related issue: harvester#4905 Signed-off-by: Tim Serong <[email protected]>
4f3b4c7
to
c4c63a1
Compare
@ChanYiLin Please review this. |
When doing local builds (i.e. without $DRONE_REPO and $DRONE_PULL_REQUEST, or $DRONE_COMMIT_REF set), the build fails with "fatal: Needed a single revision" in `scripts/validate`: ``` > make REPO=tserong [...] Running validation Running: go vet refs/heads/wip-add-virtualSize fatal: Needed a single revision FATA[0032] exit status 128 make: *** [Makefile:11: ci] Error 1 ``` If I run the commands in `scripts/validate` by hand, I see this: ``` > git symbolic-ref -q HEAD && REV="origin/HEAD" || REV="HEAD^" refs/heads/wip-add-virtualSize > echo $REV origin/HEAD > headSHA=$(git rev-parse --short=12 ${REV}) fatal: Needed a single revision ``` I don't know if this is just something weird about my environment, but if I change "origin/HEAD" to "HEAD", it works fine: ``` > headSHA=$(git rev-parse --short=12 HEAD) > echo $headSHA eb27fbf6e678 ``` Signed-off-by: Tim Serong <[email protected]>
This commit adds VirtualSize to the BackingImage, BackingImageStatus, BackingImageSpec and FileInfo structs. This will allow longhorn-manager to in turn pick up the virtual image size and expose it in the status section of the BackingImage and BackingImageManager CRDs. The virtual size of an image is determined by running `qemu-img info`. For qcow2 images, the virtual size will usually be larger than the actual physical file size. For raw images, `qemu-img info` still reports virtual size, but it's the same as the physical file size in this case. It's important to note that we can only report the virtual size of an image once the syncing file is ready. If the syncing file is not yet ready (or if for some reason the call to `qemu-img info` fails), virtual size will be set to zero. Related issue: longhorn/longhorn#7923 Signed-off-by: Tim Serong <[email protected]>
Signed-off-by: Tim Serong <[email protected]>
c4c63a1
to
f08df28
Compare
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, thanks for the contribution
@mergify backport v1.5.x v1.6.x |
✅ Backports have been created
|
Would you help update longhorn-manager and longhorn-instance-manager to fit this change? |
Sure, will do. |
The longhorn-manager PR is longhorn/longhorn-manager#2680. I'm not sure yet what needs to change in longhorn-instance-manager as I can't find any references to backing-image-manager in the longhorn-instance-manager source. Can you please advise? |
I just re-checked the code. You are right there is no reference in longhorn-instance-manager now. Please ignore this. |
This is necessary to bring in support for backing image virtual size: - longhorn/backing-image-manager#208 - longhorn/longhorn-manager#2680 Signed-off-by: Tim Serong <[email protected]>
This is necessary to bring in support for backing image virtual size: - longhorn/backing-image-manager#208 - longhorn/longhorn-manager#2680 Note the the longhorn chart version in dependency_charts/longhorn is v1.6.0-dev because that's what it's set to at the time of writing in the upstream longhorn git repo, but the tags for the various longhorn images are all "master-head". IMO we really shouldn't take this change until we at least get a proper v1.7.0 RC or dev tag release. Signed-off-by: Tim Serong <[email protected]>
This is necessary to bring in support for backing image virtual size: - longhorn/backing-image-manager#208 - longhorn/longhorn-manager#2680 Note the the longhorn chart version in dependency_charts/longhorn is v1.6.0-dev because that's what it's set to at the time of writing in the upstream longhorn git repo, but the tags for the various longhorn images are all "master-head". IMO we really shouldn't take this change until we at least get a proper v1.7.0 RC or dev tag release. Signed-off-by: Tim Serong <[email protected]>
This is necessary to bring in support for backing image virtual size: - longhorn/backing-image-manager#208 - longhorn/longhorn-manager#2680 Note the the longhorn chart version in dependency_charts/longhorn is v1.6.0-dev because that's what it's set to at the time of writing in the upstream longhorn git repo, but the tags for the various longhorn images are all "master-head". IMO we really shouldn't take this change until we at least get a proper v1.7.0 RC or dev tag release. Signed-off-by: Tim Serong <[email protected]>
With this change, we can do this: # kubectl get vmimages NAME DISPLAY-NAME SIZE VIRTUALSIZE AGE image-26r4s sles15-sp5-minimal-vm.x86_64-kvm-and-xen-qu1.qcow2 267845632 25769803776 6m36s image-bgnhb sle-micro.x86_64-5.5.0-default-qcow-gm.qcow2 1001652224 21474836480 20m image-nmmvj sle-15-sp5-full-x86_64-gm-media1.iso 14548992000 14548992000 19m This in turn means we can update the UI to take image virtual size into account when creating VMs. Note that this requires the following Longhorn PRs, which have been backported to longhorn 1.5.5 and 1.6.2: - longhorn/backing-image-manager#208 - longhorn/longhorn-manager#2680 - longhorn/longhorn#8267 Related issue: harvester#4905 Signed-off-by: Tim Serong <[email protected]>
With this change, we can do this: # kubectl get vmimages NAME DISPLAY-NAME SIZE VIRTUALSIZE AGE image-26r4s sles15-sp5-minimal-vm.x86_64-kvm-and-xen-qu1.qcow2 267845632 25769803776 6m36s image-bgnhb sle-micro.x86_64-5.5.0-default-qcow-gm.qcow2 1001652224 21474836480 20m image-nmmvj sle-15-sp5-full-x86_64-gm-media1.iso 14548992000 14548992000 19m This in turn means we can update the UI to take image virtual size into account when creating VMs. Note that this requires the following Longhorn PRs, which have been backported to longhorn 1.5.5 and 1.6.2: - longhorn/backing-image-manager#208 - longhorn/longhorn-manager#2680 - longhorn/longhorn#8267 Related issue: harvester#4905 Signed-off-by: Tim Serong <[email protected]>
With this change, we can do this: # kubectl get vmimages NAME DISPLAY-NAME SIZE VIRTUALSIZE AGE image-26r4s sles15-sp5-minimal-vm.x86_64-kvm-and-xen-qu1.qcow2 267845632 25769803776 6m36s image-bgnhb sle-micro.x86_64-5.5.0-default-qcow-gm.qcow2 1001652224 21474836480 20m image-nmmvj sle-15-sp5-full-x86_64-gm-media1.iso 14548992000 14548992000 19m This in turn means we can update the UI to take image virtual size into account when creating VMs. Note that this requires the following Longhorn PRs, which have been backported to longhorn 1.5.5 and 1.6.2: - longhorn/backing-image-manager#208 - longhorn/longhorn-manager#2680 - longhorn/longhorn#8267 Related issue: harvester#4905 Signed-off-by: Tim Serong <[email protected]>
With this change, we can do this: # kubectl get vmimages NAME DISPLAY-NAME SIZE VIRTUALSIZE AGE image-26r4s sles15-sp5-minimal-vm.x86_64-kvm-and-xen-qu1.qcow2 267845632 25769803776 6m36s image-bgnhb sle-micro.x86_64-5.5.0-default-qcow-gm.qcow2 1001652224 21474836480 20m image-nmmvj sle-15-sp5-full-x86_64-gm-media1.iso 14548992000 14548992000 19m This in turn means we can update the UI to take image virtual size into account when creating VMs. Note that this requires the following Longhorn PRs, which have been backported to longhorn 1.5.5 and 1.6.2: - longhorn/backing-image-manager#208 - longhorn/longhorn-manager#2680 - longhorn/longhorn#8267 Related issue: #4905 Signed-off-by: Tim Serong <[email protected]>
With this change, we can do this: # kubectl get vmimages NAME DISPLAY-NAME SIZE VIRTUALSIZE AGE image-26r4s sles15-sp5-minimal-vm.x86_64-kvm-and-xen-qu1.qcow2 267845632 25769803776 6m36s image-bgnhb sle-micro.x86_64-5.5.0-default-qcow-gm.qcow2 1001652224 21474836480 20m image-nmmvj sle-15-sp5-full-x86_64-gm-media1.iso 14548992000 14548992000 19m This in turn means we can update the UI to take image virtual size into account when creating VMs. Note that this requires the following Longhorn PRs, which have been backported to longhorn 1.5.5 and 1.6.2: - longhorn/backing-image-manager#208 - longhorn/longhorn-manager#2680 - longhorn/longhorn#8267 Related issue: harvester#4905 Signed-off-by: Tim Serong <[email protected]> (cherry picked from commit 79f6cdc)
Which issue(s) this PR fixes:
Issue longhorn/longhorn#7923
What this PR does / why we need it:
This commit adds VirtualSize to the BackingImage, BackingImageStatus, BackingImageSpec and FileInfo structs. This will allow longhorn-manager to in turn pick up the virtual image size and expose it in the status section of the BackingImage and BackingImageManager CRDs.
The virtual size of an image is determined by running
qemu-img info
. For qcow2 images, the virtual size will usually be larger than the actual physical file size. For raw images,qemu-img info
still reports virtual size, but it's the same as the physical file size in this case.It's important to note that we can only report the virtual size of an image once the syncing file is ready. If the syncing file is not yet ready (or if for some reason the call to
qemu-img info
fails), virtual size will be set to zero.Special notes for your reviewer:
In order to actually be useful, this requires matching changes in longhorn-manager. I'm still working on that piece :-)
My implementation of
util.GetImageVirtualSize()
usesqemu-img info --output=json
then unmarshalls the JSON to extract the virtual size. There's a similar existing function -util.DetectFileFormat()
- which instead parses the human readable output usingbufio.NewScanner
, but IMO the JSON form makes for simpler code. I wasn't sure if I should mess withutil.DetectFileFormat()
while working on this PR, so I left it alone.Note that there's an extra commit in here to fix
make
when run locally (see the commit message for details). I can split that out into a separate PR if you'd prefer.Additional documentation or context
Here's some sample output from
backing-image-manager backing-image list
with this change applied: