Skip to content

Disk size not being honored with source image file set #776

Description

@brsmnv

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    • Status
      No status
    • Status
      In progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions