Skip to content
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 (backport #208) #223

Merged
merged 3 commits into from
Apr 9, 2024

Conversation

shuo-wu
Copy link
Contributor

@shuo-wu shuo-wu commented Apr 4, 2024

This PR fixes conflicts for #220

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 <tserong@suse.com>
(cherry picked from commit 6841c08)
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 <tserong@suse.com>
(cherry picked from commit ceb51fd)
Signed-off-by: Tim Serong <tserong@suse.com>
(cherry picked from commit c5288d7)
Signed-off-by: Shuo Wu <shuo.wu@suse.com>
@shuo-wu shuo-wu merged commit 2a55116 into longhorn:v1.5.x Apr 9, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants