k8s.io/kubernetes@v1.31.0-alpha.0.0.20240520171757-56147500dadc/pkg/kubelet/cm/dra/types.go (about)

     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  	"k8s.io/kubernetes/pkg/kubelet/config"
    23  	kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
    24  )
    25  
    26  // Manager manages all the DRA resource plugins running on a node.
    27  type Manager interface {
    28  	// Start starts the reconcile loop of the manager.
    29  	// This will ensure that all claims are unprepared even if pods get deleted unexpectedly.
    30  	Start(activePods ActivePodsFunc, sourcesReady config.SourcesReady) error
    31  
    32  	// PrepareResources prepares resources for a pod.
    33  	// It communicates with the DRA resource plugin to prepare resources.
    34  	PrepareResources(pod *v1.Pod) error
    35  
    36  	// UnprepareResources calls NodeUnprepareResource GRPC from DRA plugin to unprepare pod resources
    37  	UnprepareResources(pod *v1.Pod) error
    38  
    39  	// GetResources gets a ContainerInfo object from the claimInfo cache.
    40  	// This information is used by the caller to update a container config.
    41  	GetResources(pod *v1.Pod, container *v1.Container) (*ContainerInfo, error)
    42  
    43  	// PodMightNeedToUnprepareResources returns true if the pod with the given UID
    44  	// might need to unprepare resources.
    45  	PodMightNeedToUnprepareResources(UID types.UID) bool
    46  
    47  	// GetContainerClaimInfos gets Container ClaimInfo objects
    48  	GetContainerClaimInfos(pod *v1.Pod, container *v1.Container) ([]*ClaimInfo, error)
    49  }
    50  
    51  // ContainerInfo contains information required by the runtime to consume prepared resources.
    52  type ContainerInfo struct {
    53  	// The Annotations for the container
    54  	Annotations []kubecontainer.Annotation
    55  	// CDI Devices for the container
    56  	CDIDevices []kubecontainer.CDIDevice
    57  }