Skip to content

Commit

Permalink
validate: check for reserved resources
Browse files Browse the repository at this point in the history
Add validation check to verify _some_ resources are reserved.
We don't want yet to validate the amount of resources nor
their NUMA topology. so we just check _something_ has been reserved.

Signed-off-by: Francesco Romani <[email protected]>
  • Loading branch information
ffromani committed Feb 13, 2022
1 parent f771a17 commit 6f9dfcc
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 0 deletions.
21 changes: 21 additions & 0 deletions pkg/validator/kubeletconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,16 @@ func ValidateClusterNodeKubeletConfig(nodeName string, nodeVersion *version.Info
Detected: fmt.Sprintf("%v", kubeletConf.CPUManagerReconcilePeriod.Duration),
})
}
if kubeletConf.ReservedSystemCPUs == "" {
vrs = append(vrs, ValidationResult{
Node: nodeName,
Area: AreaKubelet,
Component: ComponentConfiguration,
Setting: "CPU",
Expected: "reserved some CPU cores",
Detected: "no reserved CPU cores",
})
}

if kubeletConf.MemoryManagerPolicy != ExpectedMemoryManagerPolicy {
vrs = append(vrs, ValidationResult{
Expand All @@ -170,6 +180,17 @@ func ValidateClusterNodeKubeletConfig(nodeName string, nodeVersion *version.Info
})
}

if len(kubeletConf.ReservedMemory) == 0 {
vrs = append(vrs, ValidationResult{
Node: nodeName,
Area: AreaKubelet,
Component: ComponentConfiguration,
Setting: "memory",
Expected: "reserved memory blocks",
Detected: "no reserved memory blocks",
})
}

if kubeletConf.TopologyManagerPolicy != ExpectedTopologyManagerPolicy {
vrs = append(vrs, ValidationResult{
Node: nodeName,
Expand Down
65 changes: 65 additions & 0 deletions pkg/validator/kubeletconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,24 @@ func TestKubeletValidations(t *testing.T) {
Component: ComponentCPUManager,
Setting: "reconcile period",
},
{
Node: nodeName,
Area: AreaKubelet,
Component: ComponentConfiguration,
Setting: "CPU",
},
{
Node: nodeName,
Area: AreaKubelet,
Component: ComponentMemoryManager,
Setting: "policy",
},
{
Node: nodeName,
Area: AreaKubelet,
Component: ComponentConfiguration,
Setting: "memory",
},
{
Node: nodeName,
Area: AreaKubelet,
Expand All @@ -86,6 +104,13 @@ func TestKubeletValidations(t *testing.T) {
CPUManagerReconcilePeriod: metav1.Duration{
Duration: 5 * time.Second,
},
MemoryManagerPolicy: ExpectedMemoryManagerPolicy,
ReservedMemory: []kubeletconfigv1beta1.MemoryReservation{
{
NumaNode: 1,
},
},
ReservedSystemCPUs: "0,1",
TopologyManagerPolicy: ExpectedTopologyManagerPolicy,
},
expected: []ValidationResult{},
Expand All @@ -97,6 +122,13 @@ func TestKubeletValidations(t *testing.T) {
CPUManagerReconcilePeriod: metav1.Duration{
Duration: 5 * time.Second,
},
MemoryManagerPolicy: ExpectedMemoryManagerPolicy,
ReservedMemory: []kubeletconfigv1beta1.MemoryReservation{
{
NumaNode: 1,
},
},
ReservedSystemCPUs: "0,1",
TopologyManagerPolicy: ExpectedTopologyManagerPolicy,
},
expected: []ValidationResult{
Expand All @@ -117,6 +149,13 @@ func TestKubeletValidations(t *testing.T) {
CPUManagerReconcilePeriod: metav1.Duration{
Duration: 5 * time.Second,
},
MemoryManagerPolicy: ExpectedMemoryManagerPolicy,
ReservedMemory: []kubeletconfigv1beta1.MemoryReservation{
{
NumaNode: 1,
},
},
ReservedSystemCPUs: "0,1",
},
expected: []ValidationResult{
{
Expand All @@ -137,6 +176,13 @@ func TestKubeletValidations(t *testing.T) {
CPUManagerReconcilePeriod: metav1.Duration{
Duration: 5 * time.Second,
},
MemoryManagerPolicy: ExpectedMemoryManagerPolicy,
ReservedMemory: []kubeletconfigv1beta1.MemoryReservation{
{
NumaNode: 1,
},
},
ReservedSystemCPUs: "0,1",
TopologyManagerPolicy: "restricted",
},
expected: []ValidationResult{
Expand All @@ -154,6 +200,12 @@ func TestKubeletValidations(t *testing.T) {
FeatureGates: map[string]bool{
ExpectedPodResourcesFeatureGate: true,
},
MemoryManagerPolicy: ExpectedMemoryManagerPolicy,
ReservedMemory: []kubeletconfigv1beta1.MemoryReservation{
{
NumaNode: 1,
},
},
TopologyManagerPolicy: ExpectedTopologyManagerPolicy,
},
expected: []ValidationResult{
Expand All @@ -170,6 +222,12 @@ func TestKubeletValidations(t *testing.T) {
Component: ComponentCPUManager,
Setting: "reconcile period",
},
{
Node: nodeName,
Area: AreaKubelet,
Component: ComponentConfiguration,
Setting: "CPU",
},
},
},
{
Expand All @@ -182,6 +240,13 @@ func TestKubeletValidations(t *testing.T) {
CPUManagerReconcilePeriod: metav1.Duration{
Duration: 30 * time.Second,
},
MemoryManagerPolicy: ExpectedMemoryManagerPolicy,
ReservedMemory: []kubeletconfigv1beta1.MemoryReservation{
{
NumaNode: 1,
},
},
ReservedSystemCPUs: "0,1",
TopologyManagerPolicy: ExpectedTopologyManagerPolicy,
},
expected: []ValidationResult{
Expand Down

0 comments on commit 6f9dfcc

Please sign in to comment.