Rename NodeSwapEnabled flag to NodeSwap

This commit is contained in:
Elana Hashman 2021-07-07 13:25:43 -07:00
parent 2423813207
commit 642eff0c69
No known key found for this signature in database
GPG Key ID: D37F7B2A20B48FA0
8 changed files with 14 additions and 14 deletions

View File

@ -786,7 +786,7 @@ function start_kubelet {
# warn if users are running with swap allowed # warn if users are running with swap allowed
if [ "${FAIL_SWAP_ON}" == "false" ]; then if [ "${FAIL_SWAP_ON}" == "false" ]; then
echo "WARNING : The kubelet is configured to not fail even if swap is enabled; production deployments should disable swap unless testing NodeSwapEnabled feature." echo "WARNING : The kubelet is configured to not fail even if swap is enabled; production deployments should disable swap unless testing NodeSwap feature."
fi fi
if [[ "${REUSE_CERTS}" != true ]]; then if [[ "${REUSE_CERTS}" != true ]]; then

View File

@ -667,7 +667,7 @@ const (
// alpha: v1.22 // alpha: v1.22
// //
// Permits kubelet to run with swap enabled // Permits kubelet to run with swap enabled
NodeSwapEnabled featuregate.Feature = "NodeSwapEnabled" NodeSwap featuregate.Feature = "NodeSwap"
// owner: @ahg-g // owner: @ahg-g
// alpha: v1.21 // alpha: v1.21
@ -889,7 +889,7 @@ var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureS
VolumeCapacityPriority: {Default: false, PreRelease: featuregate.Alpha}, VolumeCapacityPriority: {Default: false, PreRelease: featuregate.Alpha},
PreferNominatedNode: {Default: true, PreRelease: featuregate.Beta}, PreferNominatedNode: {Default: true, PreRelease: featuregate.Beta},
ProbeTerminationGracePeriod: {Default: false, PreRelease: featuregate.Alpha}, ProbeTerminationGracePeriod: {Default: false, PreRelease: featuregate.Alpha},
NodeSwapEnabled: {Default: false, PreRelease: featuregate.Alpha}, NodeSwap: {Default: false, PreRelease: featuregate.Alpha},
PodDeletionCost: {Default: true, PreRelease: featuregate.Beta}, PodDeletionCost: {Default: true, PreRelease: featuregate.Beta},
StatefulSetAutoDeletePVC: {Default: false, PreRelease: featuregate.Alpha}, StatefulSetAutoDeletePVC: {Default: false, PreRelease: featuregate.Alpha},
TopologyAwareHints: {Default: false, PreRelease: featuregate.Alpha}, TopologyAwareHints: {Default: false, PreRelease: featuregate.Alpha},

View File

@ -331,7 +331,7 @@ type KubeletConfiguration struct {
// Tells the Kubelet to fail to start if swap is enabled on the node. // Tells the Kubelet to fail to start if swap is enabled on the node.
FailSwapOn bool FailSwapOn bool
// memorySwap configures swap memory available to container workloads. // memorySwap configures swap memory available to container workloads.
// +featureGate=NodeSwapEnabled // +featureGate=NodeSwap
// +optional // +optional
MemorySwap MemorySwapConfiguration MemorySwap MemorySwapConfiguration
// A quantity defines the maximum size of the container log file before it is rotated. For example: "5Mi" or "256Ki". // A quantity defines the maximum size of the container log file before it is rotated. For example: "5Mi" or "256Ki".
@ -590,7 +590,7 @@ type MemorySwapConfiguration struct {
// swapBehavior configures swap memory available to container workloads. May be one of // swapBehavior configures swap memory available to container workloads. May be one of
// "", "LimitedSwap": workload combined memory and swap usage cannot exceed pod memory limit // "", "LimitedSwap": workload combined memory and swap usage cannot exceed pod memory limit
// "UnlimitedSwap": workloads can use unlimited swap, up to the allocatable limit. // "UnlimitedSwap": workloads can use unlimited swap, up to the allocatable limit.
// +featureGate=NodeSwapEnabled // +featureGate=NodeSwap
// +optional // +optional
SwapBehavior string SwapBehavior string
} }

View File

@ -155,13 +155,13 @@ func ValidateKubeletConfiguration(kc *kubeletconfig.KubeletConfiguration) error
if (kc.ShutdownGracePeriod.Duration > 0 || kc.ShutdownGracePeriodCriticalPods.Duration > 0) && !localFeatureGate.Enabled(features.GracefulNodeShutdown) { if (kc.ShutdownGracePeriod.Duration > 0 || kc.ShutdownGracePeriodCriticalPods.Duration > 0) && !localFeatureGate.Enabled(features.GracefulNodeShutdown) {
allErrors = append(allErrors, fmt.Errorf("invalid configuration: Specifying ShutdownGracePeriod or ShutdownGracePeriodCriticalPods requires feature gate GracefulNodeShutdown")) allErrors = append(allErrors, fmt.Errorf("invalid configuration: Specifying ShutdownGracePeriod or ShutdownGracePeriodCriticalPods requires feature gate GracefulNodeShutdown"))
} }
if localFeatureGate.Enabled(features.NodeSwapEnabled) { if localFeatureGate.Enabled(features.NodeSwap) {
if kc.MemorySwap.SwapBehavior != "" && kc.MemorySwap.SwapBehavior != kubetypes.LimitedSwap && kc.MemorySwap.SwapBehavior != kubetypes.UnlimitedSwap { if kc.MemorySwap.SwapBehavior != "" && kc.MemorySwap.SwapBehavior != kubetypes.LimitedSwap && kc.MemorySwap.SwapBehavior != kubetypes.UnlimitedSwap {
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{}) { if !localFeatureGate.Enabled(features.NodeSwap) && kc.MemorySwap != (kubeletconfig.MemorySwapConfiguration{}) {
allErrors = append(allErrors, fmt.Errorf("invalid configuration: MemorySwap.SwapBehavior cannot be set when NodeSwapEnabled feature flag is disabled")) allErrors = append(allErrors, fmt.Errorf("invalid configuration: MemorySwap.SwapBehavior cannot be set when NodeSwap feature flag is disabled"))
} }
for _, val := range kc.EnforceNodeAllocatable { for _, val := range kc.EnforceNodeAllocatable {

View File

@ -156,7 +156,7 @@ func TestValidateKubeletConfiguration(t *testing.T) {
FeatureGates: map[string]bool{ FeatureGates: map[string]bool{
"CustomCPUCFSQuotaPeriod": true, "CustomCPUCFSQuotaPeriod": true,
"GracefulNodeShutdown": true, "GracefulNodeShutdown": true,
"NodeSwapEnabled": true, "NodeSwap": true,
"MemoryQoS": true, "MemoryQoS": true,
}, },
Logging: componentbaseconfig.LoggingConfiguration{ Logging: componentbaseconfig.LoggingConfiguration{
@ -241,7 +241,7 @@ func TestValidateKubeletConfiguration(t *testing.T) {
FeatureGates: map[string]bool{ FeatureGates: map[string]bool{
"CustomCPUCFSQuotaPeriod": true, "CustomCPUCFSQuotaPeriod": true,
"GracefulNodeShutdown": true, "GracefulNodeShutdown": true,
"NodeSwapEnabled": true, "NodeSwap": true,
"MemoryQoS": true, "MemoryQoS": true,
}, },
Logging: componentbaseconfig.LoggingConfiguration{ Logging: componentbaseconfig.LoggingConfiguration{

View File

@ -100,7 +100,7 @@ func (m *kubeGenericRuntimeManager) generateLinuxContainerConfig(container *v1.C
lc.Resources.HugepageLimits = GetHugepageLimitsFromResources(container.Resources) lc.Resources.HugepageLimits = GetHugepageLimitsFromResources(container.Resources)
if utilfeature.DefaultFeatureGate.Enabled(kubefeatures.NodeSwapEnabled) { if utilfeature.DefaultFeatureGate.Enabled(kubefeatures.NodeSwap) {
// NOTE(ehashman): Behaviour is defined in the opencontainers runtime spec: // NOTE(ehashman): Behaviour is defined in the opencontainers runtime spec:
// https://github.com/opencontainers/runtime-spec/blob/1c3f411f041711bbeecf35ff7e93461ea6789220/config-linux.md#memory // https://github.com/opencontainers/runtime-spec/blob/1c3f411f041711bbeecf35ff7e93461ea6789220/config-linux.md#memory
switch m.memorySwapBehavior { switch m.memorySwapBehavior {

View File

@ -466,7 +466,7 @@ func TestGenerateLinuxContainerConfigNamespaces(t *testing.T) {
} }
func TestGenerateLinuxContainerConfigSwap(t *testing.T) { func TestGenerateLinuxContainerConfigSwap(t *testing.T) {
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.NodeSwapEnabled, true)() defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.NodeSwap, true)()
_, _, m, err := createTestRuntimeManager() _, _, m, err := createTestRuntimeManager()
if err != nil { if err != nil {
t.Fatalf("error creating test RuntimeManager: %v", err) t.Fatalf("error creating test RuntimeManager: %v", err)

View File

@ -824,7 +824,7 @@ type KubeletConfiguration struct {
// +optional // +optional
FailSwapOn *bool `json:"failSwapOn,omitempty"` FailSwapOn *bool `json:"failSwapOn,omitempty"`
// memorySwap configures swap memory available to container workloads. // memorySwap configures swap memory available to container workloads.
// +featureGate=NodeSwapEnabled // +featureGate=NodeSwap
// +optional // +optional
MemorySwap MemorySwapConfiguration `json:"memorySwap,omitempty"` MemorySwap MemorySwapConfiguration `json:"memorySwap,omitempty"`
// containerLogMaxSize is a quantity defining the maximum size of the container log // containerLogMaxSize is a quantity defining the maximum size of the container log
@ -1132,7 +1132,7 @@ type MemorySwapConfiguration struct {
// swapBehavior configures swap memory available to container workloads. May be one of // swapBehavior configures swap memory available to container workloads. May be one of
// "", "LimitedSwap": workload combined memory and swap usage cannot exceed pod memory limit // "", "LimitedSwap": workload combined memory and swap usage cannot exceed pod memory limit
// "UnlimitedSwap": workloads can use unlimited swap, up to the allocatable limit. // "UnlimitedSwap": workloads can use unlimited swap, up to the allocatable limit.
// +featureGate=NodeSwapEnabled // +featureGate=NodeSwap
// +optional // +optional
SwapBehavior string `json:"swapBehavior,omitempty"` SwapBehavior string `json:"swapBehavior,omitempty"`
} }