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

未关闭
#5,449 0 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 3 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
72/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
go, kubernetes
领域
backend, databases

调研方向

Read pkg/reservation/instancetype.go around line 95 and the declaration keys in packages/system/vm-instance-rd/cozyrds/vm-instance.yaml and packages/system/kubernetes-nodes-rd/cozyrds/kubernetes-nodes.yaml. Trace how ClassifyInstancetype handles hugepage sizes and how its result is consumed; confirm the current behavior for an unlisted size such as 32Mi. Done means unsupported sizes are counted or evaluation returns a clear error, with a test covering that case.

由索引模型根据 Issue 内容生成。

描述

area/tenant kind/bug triage/needs-triage

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 8cab9b7d7bbc
  • 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
主要语言
Go
星标
2.2k
派生
209
平均合并
4 天 14 小时
30 天内合并 PR
140

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

cozystack/cozystack 的其他 Issue

查看 cozystack/cozystack 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。