mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-05 18:24:07 +00:00
topologymanager: promote TopologyManagerPolicyOptions feature to beta
* Promote TopologyManagerPolicyOptions feature to beta * Promote PreferClosestNUMANodes TopologyManagerPolicyOption to beta Signed-off-by: PiotrProkop <pprokop@nvidia.com>
This commit is contained in:
parent
23833b9c81
commit
f855a23b45
@ -754,7 +754,7 @@ func run(ctx context.Context, s *options.KubeletServer, kubeDeps *kubelet.Depend
|
||||
CPUCFSQuotaPeriod: s.CPUCFSQuotaPeriod.Duration,
|
||||
TopologyManagerPolicy: s.TopologyManagerPolicy,
|
||||
TopologyManagerScope: s.TopologyManagerScope,
|
||||
ExperimentalTopologyManagerPolicyOptions: topologyManagerPolicyOptions,
|
||||
TopologyManagerPolicyOptions: topologyManagerPolicyOptions,
|
||||
},
|
||||
s.FailSwapOn,
|
||||
kubeDeps.Recorder,
|
||||
|
@ -1064,7 +1064,7 @@ var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureS
|
||||
|
||||
TopologyManagerPolicyBetaOptions: {Default: true, PreRelease: featuregate.Beta},
|
||||
|
||||
TopologyManagerPolicyOptions: {Default: false, PreRelease: featuregate.Alpha},
|
||||
TopologyManagerPolicyOptions: {Default: true, PreRelease: featuregate.Beta},
|
||||
|
||||
VolumeCapacityPriority: {Default: false, PreRelease: featuregate.Alpha},
|
||||
|
||||
|
@ -157,7 +157,7 @@ type NodeConfig struct {
|
||||
EnforceCPULimits bool
|
||||
CPUCFSQuotaPeriod time.Duration
|
||||
TopologyManagerPolicy string
|
||||
ExperimentalTopologyManagerPolicyOptions map[string]string
|
||||
TopologyManagerPolicyOptions map[string]string
|
||||
}
|
||||
|
||||
type NodeAllocatableConfig struct {
|
||||
|
@ -292,7 +292,7 @@ func NewContainerManager(mountUtil mount.Interface, cadvisorInterface cadvisor.I
|
||||
machineInfo.Topology,
|
||||
nodeConfig.TopologyManagerPolicy,
|
||||
nodeConfig.TopologyManagerScope,
|
||||
nodeConfig.ExperimentalTopologyManagerPolicyOptions,
|
||||
nodeConfig.TopologyManagerPolicyOptions,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
|
@ -30,10 +30,10 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
alphaOptions = sets.NewString(
|
||||
alphaOptions = sets.NewString()
|
||||
betaOptions = sets.NewString(
|
||||
PreferClosestNUMANodes,
|
||||
)
|
||||
betaOptions = sets.NewString()
|
||||
stableOptions = sets.NewString()
|
||||
)
|
||||
|
||||
|
@ -29,6 +29,7 @@ import (
|
||||
)
|
||||
|
||||
var fancyBetaOption = "fancy-new-option"
|
||||
var fancyAlphaOption = "fancy-alpha-option"
|
||||
|
||||
type optionAvailTest struct {
|
||||
option string
|
||||
@ -42,12 +43,14 @@ func TestNewTopologyManagerOptions(t *testing.T) {
|
||||
description string
|
||||
policyOptions map[string]string
|
||||
featureGate featuregate.Feature
|
||||
featureGateEnable bool
|
||||
expectedErr error
|
||||
expectedOptions PolicyOptions
|
||||
}{
|
||||
{
|
||||
description: "return TopologyManagerOptions with PreferClosestNUMA set to true",
|
||||
featureGate: pkgfeatures.TopologyManagerPolicyAlphaOptions,
|
||||
featureGate: pkgfeatures.TopologyManagerPolicyBetaOptions,
|
||||
featureGateEnable: true,
|
||||
expectedOptions: PolicyOptions{
|
||||
PreferClosestNUMA: true,
|
||||
},
|
||||
@ -55,12 +58,21 @@ func TestNewTopologyManagerOptions(t *testing.T) {
|
||||
PreferClosestNUMANodes: "true",
|
||||
},
|
||||
},
|
||||
{
|
||||
description: "fail to set option when TopologyManagerPolicyBetaOptions feature gate is not set",
|
||||
featureGate: pkgfeatures.TopologyManagerPolicyBetaOptions,
|
||||
policyOptions: map[string]string{
|
||||
PreferClosestNUMANodes: "true",
|
||||
},
|
||||
expectedErr: fmt.Errorf("Topology Manager Policy Beta-level Options not enabled,"),
|
||||
},
|
||||
{
|
||||
description: "return empty TopologyManagerOptions",
|
||||
},
|
||||
{
|
||||
description: "fail to parse options",
|
||||
featureGate: pkgfeatures.TopologyManagerPolicyAlphaOptions,
|
||||
featureGateEnable: true,
|
||||
policyOptions: map[string]string{
|
||||
PreferClosestNUMANodes: "not a boolean",
|
||||
},
|
||||
@ -69,25 +81,43 @@ func TestNewTopologyManagerOptions(t *testing.T) {
|
||||
{
|
||||
description: "test beta options success",
|
||||
featureGate: pkgfeatures.TopologyManagerPolicyBetaOptions,
|
||||
featureGateEnable: true,
|
||||
policyOptions: map[string]string{
|
||||
fancyBetaOption: "true",
|
||||
},
|
||||
},
|
||||
{
|
||||
description: "test beta options success",
|
||||
description: "test beta options fail",
|
||||
featureGate: pkgfeatures.TopologyManagerPolicyBetaOptions,
|
||||
policyOptions: map[string]string{
|
||||
fancyBetaOption: "true",
|
||||
},
|
||||
expectedErr: fmt.Errorf("Topology Manager Policy Beta-level Options not enabled,"),
|
||||
},
|
||||
{
|
||||
description: "test alpha options success",
|
||||
featureGate: pkgfeatures.TopologyManagerPolicyAlphaOptions,
|
||||
featureGateEnable: true,
|
||||
policyOptions: map[string]string{
|
||||
fancyAlphaOption: "true",
|
||||
},
|
||||
},
|
||||
{
|
||||
description: "test alpha options fail",
|
||||
policyOptions: map[string]string{
|
||||
fancyAlphaOption: "true",
|
||||
},
|
||||
expectedErr: fmt.Errorf("Topology Manager Policy Alpha-level Options not enabled,"),
|
||||
},
|
||||
}
|
||||
|
||||
betaOptions = sets.NewString(fancyBetaOption)
|
||||
betaOptions.Insert(fancyBetaOption)
|
||||
alphaOptions = sets.NewString(fancyAlphaOption)
|
||||
|
||||
for _, tcase := range testCases {
|
||||
t.Run(tcase.description, func(t *testing.T) {
|
||||
if tcase.featureGate != "" {
|
||||
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, tcase.featureGate, true)()
|
||||
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, tcase.featureGate, tcase.featureGateEnable)()
|
||||
}
|
||||
opts, err := NewPolicyOptions(tcase.policyOptions)
|
||||
if tcase.expectedErr != nil {
|
||||
@ -112,7 +142,7 @@ func TestPolicyDefaultsAvailable(t *testing.T) {
|
||||
},
|
||||
{
|
||||
option: PreferClosestNUMANodes,
|
||||
expectedAvailable: false,
|
||||
expectedAvailable: true,
|
||||
},
|
||||
}
|
||||
for _, testCase := range testCases {
|
||||
@ -142,15 +172,15 @@ func TestPolicyOptionsAvailable(t *testing.T) {
|
||||
},
|
||||
{
|
||||
option: PreferClosestNUMANodes,
|
||||
featureGate: pkgfeatures.TopologyManagerPolicyAlphaOptions,
|
||||
featureGate: pkgfeatures.TopologyManagerPolicyBetaOptions,
|
||||
featureGateEnable: true,
|
||||
expectedAvailable: true,
|
||||
},
|
||||
{
|
||||
option: PreferClosestNUMANodes,
|
||||
featureGate: pkgfeatures.TopologyManagerPolicyBetaOptions,
|
||||
featureGateEnable: true,
|
||||
expectedAvailable: false,
|
||||
featureGate: pkgfeatures.TopologyManagerPolicyAlphaOptions,
|
||||
featureGateEnable: false,
|
||||
expectedAvailable: true,
|
||||
},
|
||||
}
|
||||
for _, testCase := range testCases {
|
||||
|
@ -21,7 +21,7 @@ import (
|
||||
"time"
|
||||
|
||||
cadvisorapi "github.com/google/cadvisor/info/v1"
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/kubernetes/pkg/kubelet/cm/topologymanager/bitmask"
|
||||
"k8s.io/kubernetes/pkg/kubelet/lifecycle"
|
||||
@ -133,10 +133,9 @@ var _ Manager = &manager{}
|
||||
|
||||
// NewManager creates a new TopologyManager based on provided policy and scope
|
||||
func NewManager(topology []cadvisorapi.Node, topologyPolicyName string, topologyScopeName string, topologyPolicyOptions map[string]string) (Manager, error) {
|
||||
klog.InfoS("Creating topology manager with policy per scope", "topologyPolicyName", topologyPolicyName, "topologyScopeName", topologyScopeName)
|
||||
|
||||
// When policy is none, the scope is not relevant, so we can short circuit here.
|
||||
if topologyPolicyName == PolicyNone {
|
||||
klog.InfoS("Creating topology manager with none policy")
|
||||
return &manager{scope: NewNoneScope()}, nil
|
||||
}
|
||||
|
||||
@ -145,6 +144,8 @@ func NewManager(topology []cadvisorapi.Node, topologyPolicyName string, topology
|
||||
return nil, err
|
||||
}
|
||||
|
||||
klog.InfoS("Creating topology manager with policy per scope", "topologyPolicyName", topologyPolicyName, "topologyScopeName", topologyScopeName, "topologyPolicyOptions", opts)
|
||||
|
||||
numaInfo, err := NewNUMAInfo(topology, opts)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot discover NUMA topology: %w", err)
|
||||
|
Loading…
Reference in New Issue
Block a user