What happened:
pkg/util/resource.IsZero returns false for any non-empty corev1.ResourceList, including a list whose quantities are all zero.
The implementation at pkg/util/resource/resource.go:117-129 returns false immediately when len(rl) != 0, so the subsequent per-quantity zero check is unreachable for non-empty lists.
What you expected to happen:
A ResourceList containing only zero-valued quantities should be treated as zero.
Expected results:
- Empty list:
true
- Zero-only list, for example
{cpu: 0}: true
- Mixed list, for example
{cpu: 0, memory: 1Gi}: false
How to reproduce it (as minimally and precisely as possible):
Using the current Kueue source:
empty := corev1.ResourceList{}
zero := corev1.ResourceList{
corev1.ResourceCPU: resource.MustParse("0"),
}
mixed := corev1.ResourceList{
corev1.ResourceCPU: resource.MustParse("0"),
corev1.ResourceMemory: resource.MustParse("1Gi"),
}
fmt.Println(kueueresource.IsZero(empty)) // true
fmt.Println(kueueresource.IsZero(zero)) // false
fmt.Println(kueueresource.IsZero(mixed)) // false
The expected result for zero is true.
go test ./pkg/util/resource currently passes, but the existing tests do not cover this behavior.
Anything else we need to know?:
A repository-wide source search did not find a current Kueue production caller of this exported helper. Please confirm whether the intended contract is that a non-empty ResourceList containing only zero-valued quantities should be considered zero before a focused fix and regression test are prepared.
This issue was prepared with AI assistance. The source location and reproduction were verified locally.
Environment:
- Kubernetes version: N/A
- Kueue version:
a081b4f-dirty
- Cloud provider or hardware configuration: N/A
- OS: macOS
- Kernel: N/A
- Install tools: Go toolchain
- Others: N/A
What happened:
pkg/util/resource.IsZeroreturnsfalsefor any non-emptycorev1.ResourceList, including a list whose quantities are all zero.The implementation at
pkg/util/resource/resource.go:117-129returnsfalseimmediately whenlen(rl) != 0, so the subsequent per-quantity zero check is unreachable for non-empty lists.What you expected to happen:
A
ResourceListcontaining only zero-valued quantities should be treated as zero.Expected results:
true{cpu: 0}:true{cpu: 0, memory: 1Gi}:falseHow to reproduce it (as minimally and precisely as possible):
Using the current Kueue source:
The expected result for
zeroistrue.go test ./pkg/util/resourcecurrently passes, but the existing tests do not cover this behavior.Anything else we need to know?:
A repository-wide source search did not find a current Kueue production caller of this exported helper. Please confirm whether the intended contract is that a non-empty
ResourceListcontaining only zero-valued quantities should be considered zero before a focused fix and regression test are prepared.This issue was prepared with AI assistance. The source location and reproduction were verified locally.
Environment:
a081b4f-dirty