From 642eff0c69db98f54e7d2cc8be62cf4292c75705 Mon Sep 17 00:00:00 2001 From: Elana Hashman Date: Wed, 7 Jul 2021 13:25:43 -0700 Subject: [PATCH] Rename NodeSwapEnabled flag to NodeSwap --- hack/local-up-cluster.sh | 2 +- pkg/features/kube_features.go | 4 ++-- pkg/kubelet/apis/config/types.go | 4 ++-- pkg/kubelet/apis/config/validation/validation.go | 6 +++--- pkg/kubelet/apis/config/validation/validation_test.go | 4 ++-- pkg/kubelet/kuberuntime/kuberuntime_container_linux.go | 2 +- pkg/kubelet/kuberuntime/kuberuntime_container_linux_test.go | 2 +- staging/src/k8s.io/kubelet/config/v1beta1/types.go | 4 ++-- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/hack/local-up-cluster.sh b/hack/local-up-cluster.sh index 23aa47aa809..32eca86af05 100755 --- a/hack/local-up-cluster.sh +++ b/hack/local-up-cluster.sh @@ -786,7 +786,7 @@ function start_kubelet { # warn if users are running with swap allowed 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 if [[ "${REUSE_CERTS}" != true ]]; then diff --git a/pkg/features/kube_features.go b/pkg/features/kube_features.go index bf35ca4f184..e16b9a8fd5c 100644 --- a/pkg/features/kube_features.go +++ b/pkg/features/kube_features.go @@ -667,7 +667,7 @@ const ( // alpha: v1.22 // // Permits kubelet to run with swap enabled - NodeSwapEnabled featuregate.Feature = "NodeSwapEnabled" + NodeSwap featuregate.Feature = "NodeSwap" // owner: @ahg-g // alpha: v1.21 @@ -889,7 +889,7 @@ var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureS VolumeCapacityPriority: {Default: false, PreRelease: featuregate.Alpha}, PreferNominatedNode: {Default: true, PreRelease: featuregate.Beta}, ProbeTerminationGracePeriod: {Default: false, PreRelease: featuregate.Alpha}, - NodeSwapEnabled: {Default: false, PreRelease: featuregate.Alpha}, + NodeSwap: {Default: false, PreRelease: featuregate.Alpha}, PodDeletionCost: {Default: true, PreRelease: featuregate.Beta}, StatefulSetAutoDeletePVC: {Default: false, PreRelease: featuregate.Alpha}, TopologyAwareHints: {Default: false, PreRelease: featuregate.Alpha}, diff --git a/pkg/kubelet/apis/config/types.go b/pkg/kubelet/apis/config/types.go index 85b84b50638..84074eaf566 100644 --- a/pkg/kubelet/apis/config/types.go +++ b/pkg/kubelet/apis/config/types.go @@ -331,7 +331,7 @@ type KubeletConfiguration struct { // Tells the Kubelet to fail to start if swap is enabled on the node. FailSwapOn bool // memorySwap configures swap memory available to container workloads. - // +featureGate=NodeSwapEnabled + // +featureGate=NodeSwap // +optional MemorySwap MemorySwapConfiguration // 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 // "", "LimitedSwap": workload combined memory and swap usage cannot exceed pod memory limit // "UnlimitedSwap": workloads can use unlimited swap, up to the allocatable limit. - // +featureGate=NodeSwapEnabled + // +featureGate=NodeSwap // +optional SwapBehavior string } diff --git a/pkg/kubelet/apis/config/validation/validation.go b/pkg/kubelet/apis/config/validation/validation.go index 07dc0978f88..700b8cf0da1 100644 --- a/pkg/kubelet/apis/config/validation/validation.go +++ b/pkg/kubelet/apis/config/validation/validation.go @@ -155,13 +155,13 @@ func ValidateKubeletConfiguration(kc *kubeletconfig.KubeletConfiguration) error 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")) } - if localFeatureGate.Enabled(features.NodeSwapEnabled) { + if localFeatureGate.Enabled(features.NodeSwap) { 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)) } } - 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")) + if !localFeatureGate.Enabled(features.NodeSwap) && kc.MemorySwap != (kubeletconfig.MemorySwapConfiguration{}) { + allErrors = append(allErrors, fmt.Errorf("invalid configuration: MemorySwap.SwapBehavior cannot be set when NodeSwap feature flag is disabled")) } for _, val := range kc.EnforceNodeAllocatable { diff --git a/pkg/kubelet/apis/config/validation/validation_test.go b/pkg/kubelet/apis/config/validation/validation_test.go index 292bb32267d..eb346dc6a98 100644 --- a/pkg/kubelet/apis/config/validation/validation_test.go +++ b/pkg/kubelet/apis/config/validation/validation_test.go @@ -156,7 +156,7 @@ func TestValidateKubeletConfiguration(t *testing.T) { FeatureGates: map[string]bool{ "CustomCPUCFSQuotaPeriod": true, "GracefulNodeShutdown": true, - "NodeSwapEnabled": true, + "NodeSwap": true, "MemoryQoS": true, }, Logging: componentbaseconfig.LoggingConfiguration{ @@ -241,7 +241,7 @@ func TestValidateKubeletConfiguration(t *testing.T) { FeatureGates: map[string]bool{ "CustomCPUCFSQuotaPeriod": true, "GracefulNodeShutdown": true, - "NodeSwapEnabled": true, + "NodeSwap": true, "MemoryQoS": true, }, Logging: componentbaseconfig.LoggingConfiguration{ diff --git a/pkg/kubelet/kuberuntime/kuberuntime_container_linux.go b/pkg/kubelet/kuberuntime/kuberuntime_container_linux.go index 404df0c37eb..ecea5f70e1a 100644 --- a/pkg/kubelet/kuberuntime/kuberuntime_container_linux.go +++ b/pkg/kubelet/kuberuntime/kuberuntime_container_linux.go @@ -100,7 +100,7 @@ func (m *kubeGenericRuntimeManager) generateLinuxContainerConfig(container *v1.C 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: // https://github.com/opencontainers/runtime-spec/blob/1c3f411f041711bbeecf35ff7e93461ea6789220/config-linux.md#memory switch m.memorySwapBehavior { diff --git a/pkg/kubelet/kuberuntime/kuberuntime_container_linux_test.go b/pkg/kubelet/kuberuntime/kuberuntime_container_linux_test.go index 001d035e151..da8d529b753 100644 --- a/pkg/kubelet/kuberuntime/kuberuntime_container_linux_test.go +++ b/pkg/kubelet/kuberuntime/kuberuntime_container_linux_test.go @@ -466,7 +466,7 @@ func TestGenerateLinuxContainerConfigNamespaces(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() if err != nil { t.Fatalf("error creating test RuntimeManager: %v", err) diff --git a/staging/src/k8s.io/kubelet/config/v1beta1/types.go b/staging/src/k8s.io/kubelet/config/v1beta1/types.go index e42159bea01..afbea34951a 100644 --- a/staging/src/k8s.io/kubelet/config/v1beta1/types.go +++ b/staging/src/k8s.io/kubelet/config/v1beta1/types.go @@ -824,7 +824,7 @@ type KubeletConfiguration struct { // +optional FailSwapOn *bool `json:"failSwapOn,omitempty"` // memorySwap configures swap memory available to container workloads. - // +featureGate=NodeSwapEnabled + // +featureGate=NodeSwap // +optional MemorySwap MemorySwapConfiguration `json:"memorySwap,omitempty"` // 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 // "", "LimitedSwap": workload combined memory and swap usage cannot exceed pod memory limit // "UnlimitedSwap": workloads can use unlimited swap, up to the allocatable limit. - // +featureGate=NodeSwapEnabled + // +featureGate=NodeSwap // +optional SwapBehavior string `json:"swapBehavior,omitempty"` }