In-place Pod Vertical Scaling - core implementation
1. Core Kubelet changes to implement In-place Pod Vertical Scaling. 2. E2E tests for In-place Pod Vertical Scaling. 3. Refactor kubelet code and add missing tests (Derek's kubelet review) 4. Add a new hash over container fields without Resources field to allow feature gate toggling without restarting containers not using the feature. 5. Fix corner-case where resize A->B->A gets ignored 6. Add cgroup v2 support to pod resize E2E test. KEP: /enhancements/keps/sig-node/1287-in-place-update-pod-resources Co-authored-by: Chen Wang <Chen.Wang1@ibm.com>
This commit is contained in:

committed by
vinay kulkarni

parent
231849a908
commit
f2bd94a0de
@@ -28,6 +28,7 @@ import (
|
||||
featuregatetesting "k8s.io/component-base/featuregate/testing"
|
||||
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1"
|
||||
"k8s.io/kubernetes/pkg/features"
|
||||
"k8s.io/kubernetes/pkg/kubelet/cm"
|
||||
utilpointer "k8s.io/utils/pointer"
|
||||
)
|
||||
|
||||
@@ -670,3 +671,81 @@ func TestGetSeccompProfileDefaultSeccomp(t *testing.T) {
|
||||
func getLocal(v string) *string {
|
||||
return &v
|
||||
}
|
||||
|
||||
func TestSharesToMilliCPU(t *testing.T) {
|
||||
knownMilliCPUToShares := map[int64]int64{
|
||||
0: 2,
|
||||
1: 2,
|
||||
2: 2,
|
||||
3: 3,
|
||||
4: 4,
|
||||
32: 32,
|
||||
64: 65,
|
||||
100: 102,
|
||||
250: 256,
|
||||
500: 512,
|
||||
1000: 1024,
|
||||
1500: 1536,
|
||||
2000: 2048,
|
||||
}
|
||||
|
||||
t.Run("sharesToMilliCPUTest", func(t *testing.T) {
|
||||
var testMilliCPU int64
|
||||
for testMilliCPU = 0; testMilliCPU <= 2000; testMilliCPU++ {
|
||||
shares := int64(cm.MilliCPUToShares(testMilliCPU))
|
||||
if expectedShares, found := knownMilliCPUToShares[testMilliCPU]; found {
|
||||
if shares != expectedShares {
|
||||
t.Errorf("Test milliCPIToShares: Input milliCPU %v, expected shares %v, but got %v", testMilliCPU, expectedShares, shares)
|
||||
}
|
||||
}
|
||||
expectedMilliCPU := testMilliCPU
|
||||
if testMilliCPU < 2 {
|
||||
expectedMilliCPU = 2
|
||||
}
|
||||
milliCPU := sharesToMilliCPU(shares)
|
||||
if milliCPU != expectedMilliCPU {
|
||||
t.Errorf("Test sharesToMilliCPU: Input shares %v, expected milliCPU %v, but got %v", shares, expectedMilliCPU, milliCPU)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestQuotaToMilliCPU(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
quota int64
|
||||
period int64
|
||||
expected int64
|
||||
}{
|
||||
{
|
||||
name: "50m",
|
||||
quota: int64(5000),
|
||||
period: int64(100000),
|
||||
expected: int64(50),
|
||||
},
|
||||
{
|
||||
name: "750m",
|
||||
quota: int64(75000),
|
||||
period: int64(100000),
|
||||
expected: int64(750),
|
||||
},
|
||||
{
|
||||
name: "1000m",
|
||||
quota: int64(100000),
|
||||
period: int64(100000),
|
||||
expected: int64(1000),
|
||||
},
|
||||
{
|
||||
name: "1500m",
|
||||
quota: int64(150000),
|
||||
period: int64(100000),
|
||||
expected: int64(1500),
|
||||
}} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
milliCPU := quotaToMilliCPU(tc.quota, tc.period)
|
||||
if milliCPU != tc.expected {
|
||||
t.Errorf("Test %s: Input quota %v and period %v, expected milliCPU %v, but got %v", tc.name, tc.quota, tc.period, tc.expected, milliCPU)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user