Ensure MemorySwapConfig can't be set without feature flag
This commit is contained in:
parent
d4041cb80f
commit
39f32d7286
@ -160,6 +160,9 @@ func ValidateKubeletConfiguration(kc *kubeletconfig.KubeletConfiguration) error
|
|||||||
allErrors = append(allErrors, fmt.Errorf("invalid configuration: MemorySwap.SwapBehavior %v must be one of: LimitedSwap, UnlimitedSwap", kc.MemorySwap.SwapBehavior))
|
allErrors = append(allErrors, fmt.Errorf("invalid configuration: MemorySwap.SwapBehavior %v must be one of: LimitedSwap, UnlimitedSwap", kc.MemorySwap.SwapBehavior))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if !localFeatureGate.Enabled(features.NodeSwapEnabled) && kc.MemorySwap != (kubeletconfig.MemorySwapConfiguration{}) {
|
||||||
|
allErrors = append(allErrors, fmt.Errorf("invalid configuration: MemorySwap.SwapBehavior cannot be set when NodeSwapEnabled feature flag is disabled"))
|
||||||
|
}
|
||||||
|
|
||||||
for _, val := range kc.EnforceNodeAllocatable {
|
for _, val := range kc.EnforceNodeAllocatable {
|
||||||
switch val {
|
switch val {
|
||||||
|
@ -190,8 +190,9 @@ func TestValidateKubeletConfiguration(t *testing.T) {
|
|||||||
Logging: componentbaseconfig.LoggingConfiguration{
|
Logging: componentbaseconfig.LoggingConfiguration{
|
||||||
Format: "",
|
Format: "",
|
||||||
},
|
},
|
||||||
|
MemorySwap: kubeletconfig.MemorySwapConfiguration{SwapBehavior: kubetypes.UnlimitedSwap},
|
||||||
}
|
}
|
||||||
const numErrsErrorCase1 = 29
|
const numErrsErrorCase1 = 30
|
||||||
if allErrors := ValidateKubeletConfiguration(errorCase1); len(allErrors.(utilerrors.Aggregate).Errors()) != numErrsErrorCase1 {
|
if allErrors := ValidateKubeletConfiguration(errorCase1); len(allErrors.(utilerrors.Aggregate).Errors()) != numErrsErrorCase1 {
|
||||||
t.Errorf("expect %d errors, got %v", numErrsErrorCase1, len(allErrors.(utilerrors.Aggregate).Errors()))
|
t.Errorf("expect %d errors, got %v", numErrsErrorCase1, len(allErrors.(utilerrors.Aggregate).Errors()))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user