node: kep-2625: cpu manager policy options GA

Move the support for CPUManager Policy Options to GA

Signed-off-by: Francesco Romani <fromani@redhat.com>
This commit is contained in:
Francesco Romani 2025-03-03 11:00:30 +01:00
parent 16abcd78bd
commit 3c7ed00e22
10 changed files with 28 additions and 30 deletions

View File

@ -826,14 +826,6 @@ func run(ctx context.Context, s *options.KubeletServer, kubeDeps *kubelet.Depend
return fmt.Errorf("--qos-reserved value failed to parse: %w", err) return fmt.Errorf("--qos-reserved value failed to parse: %w", err)
} }
var cpuManagerPolicyOptions map[string]string
if utilfeature.DefaultFeatureGate.Enabled(features.CPUManagerPolicyOptions) {
cpuManagerPolicyOptions = s.CPUManagerPolicyOptions
} else if s.CPUManagerPolicyOptions != nil {
return fmt.Errorf("CPU Manager policy options %v require feature gates %q, %q enabled",
s.CPUManagerPolicyOptions, features.CPUManager, features.CPUManagerPolicyOptions)
}
var topologyManagerPolicyOptions map[string]string var topologyManagerPolicyOptions map[string]string
if utilfeature.DefaultFeatureGate.Enabled(features.TopologyManagerPolicyOptions) { if utilfeature.DefaultFeatureGate.Enabled(features.TopologyManagerPolicyOptions) {
topologyManagerPolicyOptions = s.TopologyManagerPolicyOptions topologyManagerPolicyOptions = s.TopologyManagerPolicyOptions
@ -877,7 +869,7 @@ func run(ctx context.Context, s *options.KubeletServer, kubeDeps *kubelet.Depend
}, },
QOSReserved: *experimentalQOSReserved, QOSReserved: *experimentalQOSReserved,
CPUManagerPolicy: s.CPUManagerPolicy, CPUManagerPolicy: s.CPUManagerPolicy,
CPUManagerPolicyOptions: cpuManagerPolicyOptions, CPUManagerPolicyOptions: s.CPUManagerPolicyOptions,
CPUManagerReconcilePeriod: s.CPUManagerReconcilePeriod.Duration, CPUManagerReconcilePeriod: s.CPUManagerReconcilePeriod.Duration,
MemoryManagerPolicy: s.MemoryManagerPolicy, MemoryManagerPolicy: s.MemoryManagerPolicy,
MemoryManagerReservedMemory: s.ReservedMemory, MemoryManagerReservedMemory: s.ReservedMemory,

View File

@ -167,8 +167,7 @@ function usage {
echo "Example 1: hack/local-up-cluster.sh -o _output/dockerized/bin/linux/amd64/ (run from docker output)" echo "Example 1: hack/local-up-cluster.sh -o _output/dockerized/bin/linux/amd64/ (run from docker output)"
echo "Example 2: hack/local-up-cluster.sh -O (auto-guess the bin path for your platform)" echo "Example 2: hack/local-up-cluster.sh -O (auto-guess the bin path for your platform)"
echo "Example 3: hack/local-up-cluster.sh (build a local copy of the source)" echo "Example 3: hack/local-up-cluster.sh (build a local copy of the source)"
echo "Example 4: FEATURE_GATES=CPUManagerPolicyOptions=true \\" echo "Example 4: TOPOLOGY_MANAGER_POLICY=\"single-numa-node\" \\"
echo " TOPOLOGY_MANAGER_POLICY=\"single-numa-node\" \\"
echo " CPUMANAGER_POLICY=\"static\" \\" echo " CPUMANAGER_POLICY=\"static\" \\"
echo " CPUMANAGER_POLICY_OPTIONS=full-pcpus-only=\"true\" \\" echo " CPUMANAGER_POLICY_OPTIONS=full-pcpus-only=\"true\" \\"
echo " CPUMANAGER_RECONCILE_PERIOD=\"5s\" \\" echo " CPUMANAGER_RECONCILE_PERIOD=\"5s\" \\"

View File

@ -114,7 +114,7 @@ const (
// for details about the removal of this feature gate. // for details about the removal of this feature gate.
CPUManagerPolicyBetaOptions featuregate.Feature = "CPUManagerPolicyBetaOptions" CPUManagerPolicyBetaOptions featuregate.Feature = "CPUManagerPolicyBetaOptions"
// owner: @fromanirh // owner: @ffromani
// //
// Allow the usage of options to fine-tune the cpumanager policies. // Allow the usage of options to fine-tune the cpumanager policies.
CPUManagerPolicyOptions featuregate.Feature = "CPUManagerPolicyOptions" CPUManagerPolicyOptions featuregate.Feature = "CPUManagerPolicyOptions"
@ -1049,6 +1049,7 @@ var defaultVersionedKubernetesFeatureGates = map[featuregate.Feature]featuregate
CPUManagerPolicyOptions: { CPUManagerPolicyOptions: {
{Version: version.MustParse("1.22"), Default: false, PreRelease: featuregate.Alpha}, {Version: version.MustParse("1.22"), Default: false, PreRelease: featuregate.Alpha},
{Version: version.MustParse("1.23"), Default: true, PreRelease: featuregate.Beta}, {Version: version.MustParse("1.23"), Default: true, PreRelease: featuregate.Beta},
{Version: version.MustParse("1.33"), Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.36
}, },
CronJobsScheduledAnnotation: { CronJobsScheduledAnnotation: {

View File

@ -66530,7 +66530,7 @@ func schema_k8sio_kubelet_config_v1beta1_KubeletConfiguration(ref common.Referen
}, },
"cpuManagerPolicyOptions": { "cpuManagerPolicyOptions": {
SchemaProps: spec.SchemaProps{ SchemaProps: spec.SchemaProps{
Description: "cpuManagerPolicyOptions is a set of key=value which \tallows to set extra options to fine tune the behaviour of the cpu manager policies. Requires both the \"CPUManager\" and \"CPUManagerPolicyOptions\" feature gates to be enabled. Default: nil", Description: "cpuManagerPolicyOptions is a set of key=value which \tallows to set extra options to fine tune the behaviour of the cpu manager policies. Default: nil",
Type: []string{"object"}, Type: []string{"object"},
AdditionalProperties: &spec.SchemaOrBool{ AdditionalProperties: &spec.SchemaOrBool{
Allows: true, Allows: true,

View File

@ -257,7 +257,6 @@ type KubeletConfiguration struct {
CPUManagerPolicy string CPUManagerPolicy string
// CPUManagerPolicyOptions is a set of key=value which allows to set extra options // CPUManagerPolicyOptions is a set of key=value which allows to set extra options
// to fine tune the behaviour of the cpu manager policies. // to fine tune the behaviour of the cpu manager policies.
// Requires both the "CPUManager" and "CPUManagerPolicyOptions" feature gates to be enabled.
CPUManagerPolicyOptions map[string]string CPUManagerPolicyOptions map[string]string
// CPU Manager reconciliation period. // CPU Manager reconciliation period.
// Requires the CPUManager feature gate to be enabled. // Requires the CPUManager feature gate to be enabled.

View File

@ -44,11 +44,12 @@ var (
PreferAlignByUnCoreCacheOption, PreferAlignByUnCoreCacheOption,
) )
betaOptions = sets.New[string]( betaOptions = sets.New[string](
FullPCPUsOnlyOption,
StrictCPUReservationOption, StrictCPUReservationOption,
DistributeCPUsAcrossNUMAOption, DistributeCPUsAcrossNUMAOption,
) )
stableOptions = sets.New[string]() stableOptions = sets.New[string](
FullPCPUsOnlyOption,
)
) )
// CheckPolicyOptionAvailable verifies if the given option can be used depending on the Feature Gate Settings. // CheckPolicyOptionAvailable verifies if the given option can be used depending on the Feature Gate Settings.
@ -66,6 +67,7 @@ func CheckPolicyOptionAvailable(option string) error {
return fmt.Errorf("CPU Manager Policy Beta-level Options not enabled, but option %q provided", option) return fmt.Errorf("CPU Manager Policy Beta-level Options not enabled, but option %q provided", option)
} }
// if the option is stable, we need no CPUManagerPolicy*Options feature gate check
return nil return nil
} }

View File

@ -70,18 +70,6 @@ func TestPolicyOptionsAvailable(t *testing.T) {
featureGateEnable: true, featureGateEnable: true,
expectedAvailable: false, expectedAvailable: false,
}, },
{
option: FullPCPUsOnlyOption,
featureGate: pkgfeatures.CPUManagerPolicyBetaOptions,
featureGateEnable: true,
expectedAvailable: true,
},
{
option: FullPCPUsOnlyOption,
featureGate: pkgfeatures.CPUManagerPolicyBetaOptions,
featureGateEnable: false,
expectedAvailable: false,
},
{ {
option: AlignBySocketOption, option: AlignBySocketOption,
featureGate: pkgfeatures.CPUManagerPolicyAlphaOptions, featureGate: pkgfeatures.CPUManagerPolicyAlphaOptions,
@ -143,6 +131,21 @@ func TestPolicyOptionsAvailable(t *testing.T) {
} }
} }
func TestPolicyOptionsAlwaysAvailableOnceGA(t *testing.T) {
options := []string{
FullPCPUsOnlyOption,
}
for _, option := range options {
t.Run(option, func(t *testing.T) {
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, pkgfeatures.CPUManagerPolicyAlphaOptions, false)
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, pkgfeatures.CPUManagerPolicyBetaOptions, false)
if err := CheckPolicyOptionAvailable(option); err != nil {
t.Errorf("option %q should be available even with all featuregate disabled", option)
}
})
}
}
func TestValidateStaticPolicyOptions(t *testing.T) { func TestValidateStaticPolicyOptions(t *testing.T) {
testCases := []struct { testCases := []struct {
description string description string

View File

@ -406,7 +406,6 @@ type KubeletConfiguration struct {
SingleProcessOOMKill *bool `json:"singleProcessOOMKill,omitempty"` SingleProcessOOMKill *bool `json:"singleProcessOOMKill,omitempty"`
// cpuManagerPolicyOptions is a set of key=value which allows to set extra options // cpuManagerPolicyOptions is a set of key=value which allows to set extra options
// to fine tune the behaviour of the cpu manager policies. // to fine tune the behaviour of the cpu manager policies.
// Requires both the "CPUManager" and "CPUManagerPolicyOptions" feature gates to be enabled.
// Default: nil // Default: nil
// +optional // +optional
CPUManagerPolicyOptions map[string]string `json:"cpuManagerPolicyOptions,omitempty"` CPUManagerPolicyOptions map[string]string `json:"cpuManagerPolicyOptions,omitempty"`

View File

@ -303,6 +303,10 @@
lockToDefault: false lockToDefault: false
preRelease: Beta preRelease: Beta
version: "1.23" version: "1.23"
- default: true
lockToDefault: true
preRelease: GA
version: "1.33"
- name: CRDValidationRatcheting - name: CRDValidationRatcheting
versionedSpecs: versionedSpecs:
- default: false - default: false

View File

@ -303,7 +303,6 @@ func configureCPUManagerInKubelet(oldCfg *kubeletconfig.KubeletConfiguration, ku
newCfg.FeatureGates = make(map[string]bool) newCfg.FeatureGates = make(map[string]bool)
} }
newCfg.FeatureGates["CPUManagerPolicyOptions"] = kubeletArguments.enableCPUManagerOptions
newCfg.FeatureGates["CPUManagerPolicyBetaOptions"] = kubeletArguments.enableCPUManagerOptions newCfg.FeatureGates["CPUManagerPolicyBetaOptions"] = kubeletArguments.enableCPUManagerOptions
newCfg.FeatureGates["CPUManagerPolicyAlphaOptions"] = kubeletArguments.enableCPUManagerOptions newCfg.FeatureGates["CPUManagerPolicyAlphaOptions"] = kubeletArguments.enableCPUManagerOptions
newCfg.FeatureGates["DisableCPUQuotaWithExclusiveCPUs"] = kubeletArguments.disableCPUQuotaWithExclusiveCPUs newCfg.FeatureGates["DisableCPUQuotaWithExclusiveCPUs"] = kubeletArguments.disableCPUQuotaWithExclusiveCPUs