Skip to content

fix(reservation): an instance type with an unlisted hugepage size reserves no memory #5449

Backlog

Description

Describe the bug

ClassifyInstancetype puts a hugepages instance type's memory under hugepages-<pageSize> for any page size (pkg/reservation/instancetype.go:95). The consumption declarations read only hugepages-2Mi and hugepages-1Gi (packages/system/vm-instance-rd/cozyrds/vm-instance.yaml:70-71, packages/system/kubernetes-nodes-rd/cozyrds/kubernetes-nodes.yaml:80-81), and instancetypeZeroKeys (pkg/reservation/evaluator.go:268-271) pre-fills only those two. An instance type with any other spec.memory.hugepages.pageSize, for example 32Mi, produces a key nothing reads, so the VM's memory is reserved as zero. That is fail-open, while the reservation design is meant to fail closed on what it cannot count.

Environment

  • Cozystack version: main at 8cab9b7
  • Provider: any; page sizes other than 2Mi and 1Gi exist mainly on arm64

To Reproduce

  1. Define a VirtualMachineClusterInstancetype with spec.memory.hugepages.pageSize: 32Mi and spec.memory.guest: 8Gi.
  2. Evaluate the VMInstance declaration for a VM of that type.
  3. No memory class in the result is non-zero.

Expected behaviour

Either the memory is counted, or evaluation fails with an error naming the class no declaration reads.

Actual behaviour

The memory is counted as zero.

Logs

None; derived from the code.

Screenshots

Not applicable.

Additional context

The zero keys exist so a declaration can read any class of a type without guarding it, and that should stay. The smallest fix is in the classifier: refuse a page size outside the set the declarations know, with an error that says so. It gives up those types in tenants with quotas until a declaration counts them, which is the point of failing closed. The more general option is for the evaluator to fail when an instanceType() result carries a non-zero key no declaration names.

Nothing on main calls the evaluator yet; #5397 and #5401 wire it in, so this is latent until one of them lands. I have not checked which page sizes KubeVirt itself accepts.

Checklist

  • I have checked the documentation
  • I have searched for similar issues
  • I have included all required information
  • I have provided clear steps to reproduce
  • I have included relevant logs

Activity

  1. added
    kind/bug
    area/tenant
    on Nov 26, 2026
  2. added
    triage/needs-triage
    on Nov 26, 2026
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

    area/tenantkind/bugtriage/needs-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions