ironcore-dev / ironcore-dev/libvirt-provider

Disk size not being honored with source image file set

Open
#776 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area/compute bug
Dominant language
Go
Stars
11
Forks
10
Avg merge
23h 2m
Merged PRs (30d)
13

Description

Describe the bug
When a local disk vol is created with both image and size set, the size is not being taken into account.

At the moment image and size are treated as mutually exclusive. While CreateOptions carries both fields, the implementation picks only the one or the other. Requests for larger volumes e.g. 10GB are ignored for boot disks.

internal/raw/raw_exec.go makes the same assumption:

if o.SourceFile == "" {
    ... // size set
} else {
    ... // copy path, Size ignored
}

To Reproduce
Create a machine with a local disk volume specifying both an image and a size:

Volumes: []*api.VolumeSpec{
    {
        Name:   "disk-0",
        Device: "oda",
        LocalDisk: &api.LocalDiskSpec{
            Image: &image,   // ghcr.io/ironcore-dev/gardenlinux/gardener:2150.4.0-kvm
            Size:  10 * 1024 * 1024 * 1024, // 10 GiB
        },
    },
},

Expected behavior

  • Disks are created with the requested size in all scenarios. Image is written at the front and the file is expanded.
  • A size smaller than the source image should be rejected.

Additional context

In my particular case, creating a disk with the gardenlinux image produces a 1.79GiB disk. The guest sees the same size as well.

This issue makes it impossible to set the size of a boot disk. There is even code specifically excluding boot disks from online resize.

internal/controllers/machine_controller_volumes.go:

isBootDisk := desiredVolume.LocalDisk != nil && desiredVolume.LocalDisk.Image != nil
if lastVolumeSize != 0 && volumeSize != lastVolumeSize && !isBootDisk {
    // ...attacher.ResizeVolume()
}

Guests have only whatever free space the image happens to ship with. The disk fills quickly under any use, and there is no workaround.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with internal/raw/raw_exec.go and trace how a LocalDiskSpec with both Image and Size is handled. Then inspect internal/controllers/machine_controller_volumes.go for boot-disk resizing behavior and reproduce the provided 10 GiB VolumeSpec. Done means image-backed disks honor the requested size in all scenarios and reject sizes smaller than the source image.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
infrastructure
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.