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 #208

Merged
merged 3 commits into from
Mar 26, 2024

Commits on Mar 19, 2024

  1. scripts/validate: Fix git rev-parse when doing local builds

    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>
    tserong committed Mar 19, 2024
    Configuration menu
    Copy the full SHA
    2226346 View commit details
    Browse the repository at this point in the history
  2. Expose virtual size of qcow2 backing images

    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>
    tserong committed Mar 19, 2024
    Configuration menu
    Copy the full SHA
    4f11ccf View commit details
    Browse the repository at this point in the history
  3. Consolidate GetImageVirtualSize and DetectFileFormat functions

    Signed-off-by: Tim Serong <tserong@suse.com>
    tserong committed Mar 19, 2024
    Configuration menu
    Copy the full SHA
    f08df28 View commit details
    Browse the repository at this point in the history