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 "k8s.io/api/core/v1" 21 22 "k8s.io/kubernetes/pkg/kubelet/cm/cpumanager/state" 23 "k8s.io/kubernetes/pkg/kubelet/cm/topologymanager" 24 "k8s.io/utils/cpuset" 25 ) 26 27 // Policy implements logic for pod container to CPU assignment. 28 type Policy interface { 29 Name() string 30 Start(s state.State) error 31 // Allocate call is idempotent 32 Allocate(s state.State, pod *v1.Pod, container *v1.Container) error 33 // RemoveContainer call is idempotent 34 RemoveContainer(s state.State, podUID string, containerName string) error 35 // GetTopologyHints implements the topologymanager.HintProvider Interface 36 // and is consulted to achieve NUMA aware resource alignment among this 37 // and other resource controllers. 38 GetTopologyHints(s state.State, pod *v1.Pod, container *v1.Container) map[string][]topologymanager.TopologyHint 39 // GetPodTopologyHints implements the topologymanager.HintProvider Interface 40 // and is consulted to achieve NUMA aware resource alignment per Pod 41 // among this and other resource controllers. 42 GetPodTopologyHints(s state.State, pod *v1.Pod) map[string][]topologymanager.TopologyHint 43 // GetAllocatableCPUs returns the total set of CPUs available for allocation. 44 GetAllocatableCPUs(m state.State) cpuset.CPUSet 45 } 46