1 /* 2 Copyright 2022 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 dra 18 19 import ( 20 v1 "k8s.io/api/core/v1" 21 "k8s.io/apimachinery/pkg/types" 22 kubecontainer "k8s.io/kubernetes/pkg/kubelet/container" 23 ) 24 25 // Manager manages all the DRA resource plugins running on a node. 26 type Manager interface { 27 // PrepareResources prepares resources for a pod. 28 // It communicates with the DRA resource plugin to prepare resources. 29 PrepareResources(pod *v1.Pod) error 30 31 // UnprepareResources calls NodeUnprepareResource GRPC from DRA plugin to unprepare pod resources 32 UnprepareResources(pod *v1.Pod) error 33 34 // GetResources gets a ContainerInfo object from the claimInfo cache. 35 // This information is used by the caller to update a container config. 36 GetResources(pod *v1.Pod, container *v1.Container) (*ContainerInfo, error) 37 38 // PodMightNeedToUnprepareResources returns true if the pod with the given UID 39 // might need to unprepare resources. 40 PodMightNeedToUnprepareResources(UID types.UID) bool 41 42 // GetContainerClaimInfos gets Container ClaimInfo objects 43 GetContainerClaimInfos(pod *v1.Pod, container *v1.Container) ([]*ClaimInfo, error) 44 } 45 46 // ContainerInfo contains information required by the runtime to consume prepared resources. 47 type ContainerInfo struct { 48 // The Annotations for the container 49 Annotations []kubecontainer.Annotation 50 // CDI Devices for the container 51 CDIDevices []kubecontainer.CDIDevice 52 } 53