longhorn-manager
longhorn-manager copied to clipboard
Expose virtual size of backing images
Which issue(s) this PR fixes:
https://github.com/longhorn/longhorn/issues/7923
What this PR does / why we need it:
This commit adds virtualSize to the BackingImageStatus and BackingImageFileInfo structs, and thus to the BackingImage and BackingImageManager CRDs. We can see how this works in practice by creating a new backing image downloaded from a URL, then periodically running kubectl -n longhorn-system get lhbi. I'm using https://download.opensuse.org/distribution/leap/15.5/appliances/openSUSE-Leap-15.5-Minimal-VM.x86_64-Cloud.qcow2 in the example below.
Initially, when the download is just started, before the file size is known:
> kubectl -n longhorn-system get lhbi/default-image-7mplj
NAME UUID SOURCETYPE SIZE VIRTUALSIZE AGE
default-image-7mplj 6d5a98b0 download 0 0 9s
A little later, while the download is running:
> kubectl -n longhorn-system get lhbi/default-image-7mplj
NAME UUID SOURCETYPE SIZE VIRTUALSIZE AGE
default-image-7mplj 6d5a98b0 download 255701504 0 3m33s
Finally, once the download is complete:
> kubectl -n longhorn-system get lhbi/default-image-7mplj
NAME UUID SOURCETYPE SIZE VIRTUALSIZE AGE
default-image-7mplj 6d5a98b0 download 255701504 821035008 4m26s
Compare size and virtualSize above with the image downloaded manually:
> wget https://download.opensuse.org/distribution/leap/15.5/appliances/openSUSE-Leap-15.5-Minimal-VM.x86_64-Cloud.qcow2
[...]
> ls -l openSUSE-Leap-15.5-Minimal-VM.x86_64-Cloud.qcow2
-rw-r--r-- 1 tserong users 255701504 Dec 19 23:26 openSUSE-Leap-15.5-Minimal-VM.x86_64-Cloud.qcow2
> qemu-img info openSUSE-Leap-15.5-Minimal-VM.x86_64-Cloud.qcow2 | grep virtual
virtual size: 783 MiB (821035008 bytes)
Special notes for your reviewer:
This PR manually pulls the changes from https://github.com/longhorn/backing-image-manager/pull/208 into the vendor directory, so probably shouldn't be taken as-is (I assume we need to merge the BIM PR first, then do a proper go get ; go mod tidy ; go mod vendor thing separately to pull the BIM changes into longhorn-manager, and only then look at this PR, but please correct me if I'm wrong).
Additional documentation or context
N/A