k8s.io/kubernetes@v1.29.3/pkg/kubelet/cm/cpumanager/policy_none.go (about) 1 /* 2 Copyright 2017 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package cpumanager 18 19 import ( 20 "fmt" 21 22 "k8s.io/api/core/v1" 23 "k8s.io/klog/v2" 24 "k8s.io/kubernetes/pkg/kubelet/cm/cpumanager/state" 25 "k8s.io/kubernetes/pkg/kubelet/cm/topologymanager" 26 "k8s.io/utils/cpuset" 27 ) 28 29 type nonePolicy struct{} 30 31 var _ Policy = &nonePolicy{} 32 33 // PolicyNone name of none policy 34 const PolicyNone policyName = "none" 35 36 // NewNonePolicy returns a cpuset manager policy that does nothing 37 func NewNonePolicy(cpuPolicyOptions map[string]string) (Policy, error) { 38 if len(cpuPolicyOptions) > 0 { 39 return nil, fmt.Errorf("None policy: received unsupported options=%v", cpuPolicyOptions) 40 } 41 return &nonePolicy{}, nil 42 } 43 44 func (p *nonePolicy) Name() string { 45 return string(PolicyNone) 46 } 47 48 func (p *nonePolicy) Start(s state.State) error { 49 klog.InfoS("None policy: Start") 50 return nil 51 } 52 53 func (p *nonePolicy) Allocate(s state.State, pod *v1.Pod, container *v1.Container) error { 54 return nil 55 } 56 57 func (p *nonePolicy) RemoveContainer(s state.State, podUID string, containerName string) error { 58 return nil 59 } 60 61 func (p *nonePolicy) GetTopologyHints(s state.State, pod *v1.Pod, container *v1.Container) map[string][]topologymanager.TopologyHint { 62 return nil 63 } 64 65 func (p *nonePolicy) GetPodTopologyHints(s state.State, pod *v1.Pod) map[string][]topologymanager.TopologyHint { 66 return nil 67 } 68 69 // Assignable CPUs are the ones that can be exclusively allocated to pods that meet the exclusivity requirement 70 // (ie guaranteed QoS class and integral CPU request). 71 // Assignability of CPUs as a concept is only applicable in case of static policy i.e. scenarios where workloads 72 // CAN get exclusive access to core(s). 73 // Hence, we return empty set here: no cpus are assignable according to above definition with this policy. 74 func (p *nonePolicy) GetAllocatableCPUs(m state.State) cpuset.CPUSet { 75 return cpuset.New() 76 }