mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 11:21:47 +00:00
Adding validity checks for topology manager align-by-socket
This commit is contained in:
parent
35849bf7fb
commit
06f347f645
@ -23,6 +23,8 @@ import (
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||
kubefeatures "k8s.io/kubernetes/pkg/features"
|
||||
"k8s.io/kubernetes/pkg/kubelet/cm/cpumanager/topology"
|
||||
"k8s.io/kubernetes/pkg/kubelet/cm/topologymanager"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -110,3 +112,17 @@ func NewStaticPolicyOptions(policyOptions map[string]string) (StaticPolicyOption
|
||||
}
|
||||
return opts, nil
|
||||
}
|
||||
|
||||
func ValidateStaticPolicyOptions(opts StaticPolicyOptions, topology *topology.CPUTopology, topologyManager topologymanager.Store) error {
|
||||
if opts.AlignBySocket == true {
|
||||
//1. not compatible with topology manager single numa policy option
|
||||
if topologyManager.GetPolicy().Name() == topologymanager.PolicySingleNumaNode {
|
||||
return fmt.Errorf("Topolgy manager Single numa policy is incompatible with CPUManager Align by socket policy option")
|
||||
}
|
||||
//2. not comptuble with topology when num_socets > num_numa
|
||||
if topology.NumSockets > topology.NumNUMANodes {
|
||||
return fmt.Errorf("Align by socket is not compatible with hardware where number of sockets are more than number of NUMA")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -115,6 +115,10 @@ func NewStaticPolicy(topology *topology.CPUTopology, numReservedCPUs int, reserv
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = ValidateStaticPolicyOptions(opts, topology, affinity)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
klog.InfoS("Static policy created with configuration", "options", opts)
|
||||
|
||||
|
@ -50,6 +50,10 @@ func (m *fakeManager) GetAffinity(podUID string, containerName string) TopologyH
|
||||
return *m.hint
|
||||
}
|
||||
|
||||
func (m *fakeManager) GetPolicy() Policy {
|
||||
return NewNonePolicy()
|
||||
}
|
||||
|
||||
func (m *fakeManager) AddHintProvider(h HintProvider) {
|
||||
klog.InfoS("AddHintProvider", "hintProvider", h)
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ type podTopologyHints map[string]map[string]TopologyHint
|
||||
// Scope interface for Topology Manager
|
||||
type Scope interface {
|
||||
Name() string
|
||||
GetPolicy() Policy
|
||||
Admit(pod *v1.Pod) lifecycle.PodAdmitResult
|
||||
// AddHintProvider adds a hint provider to manager to indicate the hint provider
|
||||
// wants to be consoluted with when making topology hints
|
||||
@ -88,6 +89,10 @@ func (s *scope) GetAffinity(podUID string, containerName string) TopologyHint {
|
||||
return s.getTopologyHints(podUID, containerName)
|
||||
}
|
||||
|
||||
func (s *scope) GetPolicy() Policy {
|
||||
return s.policy
|
||||
}
|
||||
|
||||
func (s *scope) AddHintProvider(h HintProvider) {
|
||||
s.hintProviders = append(s.hintProviders, h)
|
||||
}
|
||||
|
@ -95,6 +95,7 @@ type HintProvider interface {
|
||||
// Store interface is to allow Hint Providers to retrieve pod affinity
|
||||
type Store interface {
|
||||
GetAffinity(podUID string, containerName string) TopologyHint
|
||||
GetPolicy() Policy
|
||||
}
|
||||
|
||||
// TopologyHint is a struct containing the NUMANodeAffinity for a Container
|
||||
@ -184,6 +185,10 @@ func (m *manager) GetAffinity(podUID string, containerName string) TopologyHint
|
||||
return m.scope.GetAffinity(podUID, containerName)
|
||||
}
|
||||
|
||||
func (m *manager) GetPolicy() Policy {
|
||||
return m.scope.GetPolicy()
|
||||
}
|
||||
|
||||
func (m *manager) AddHintProvider(h HintProvider) {
|
||||
m.scope.AddHintProvider(h)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user