mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-19 09:52:49 +00:00
Merge pull request #116558 from klueska/update-dra-kubeletplugin-v1alpha2
Update kubeletplugin API for DRA to v1alpha2
This commit is contained in:
commit
815b1bf0d8
@ -69,7 +69,7 @@ func (m *ManagerImpl) PrepareResources(pod *v1.Pod) error {
|
||||
// Process resources for each resource claim referenced by container
|
||||
for _, container := range append(pod.Spec.InitContainers, pod.Spec.Containers...) {
|
||||
for range container.Resources.Claims {
|
||||
for i, podResourceClaim := range pod.Spec.ResourceClaims {
|
||||
for i := range pod.Spec.ResourceClaims {
|
||||
claimName := resourceclaim.Name(pod, &pod.Spec.ResourceClaims[i])
|
||||
klog.V(3).InfoS("Processing resource", "claim", claimName, "pod", pod.Name)
|
||||
|
||||
@ -99,7 +99,7 @@ func (m *ManagerImpl) PrepareResources(pod *v1.Pod) error {
|
||||
// Check if pod is in the ReservedFor for the claim
|
||||
if !resourceclaim.IsReservedForPod(pod, resourceClaim) {
|
||||
return fmt.Errorf("pod %s(%s) is not allowed to use resource claim %s(%s)",
|
||||
pod.Name, pod.UID, podResourceClaim.Name, resourceClaim.UID)
|
||||
pod.Name, pod.UID, claimName, resourceClaim.UID)
|
||||
}
|
||||
|
||||
// Grab the allocation.resourceHandles. If there are no
|
||||
@ -241,19 +241,45 @@ func (m *ManagerImpl) UnprepareResources(pod *v1.Pod) error {
|
||||
continue
|
||||
}
|
||||
|
||||
// Query claim object from the API server
|
||||
resourceClaim, err := m.kubeClient.ResourceV1alpha2().ResourceClaims(pod.Namespace).Get(
|
||||
context.TODO(),
|
||||
claimName,
|
||||
metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to fetch ResourceClaim %s referenced by pod %s: %+v", claimName, pod.Name, err)
|
||||
}
|
||||
|
||||
// Grab the allocation.resourceHandles. If there are no
|
||||
// allocation.resourceHandles, create a single resourceHandle with no
|
||||
// content. This will trigger processing of this claim by a single
|
||||
// kubelet plugin whose name matches resourceClaim.Status.DriverName.
|
||||
resourceHandles := resourceClaim.Status.Allocation.ResourceHandles
|
||||
if len(resourceHandles) == 0 {
|
||||
resourceHandles = make([]resourcev1alpha2.ResourceHandle, 1)
|
||||
}
|
||||
|
||||
// Loop through all plugins and call NodeUnprepareResource only for the
|
||||
// last pod that references the claim
|
||||
for pluginName, cdiDevices := range claimInfo.CDIDevices {
|
||||
for _, resourceHandle := range resourceHandles {
|
||||
// If no DriverName is provided in the resourceHandle, we
|
||||
// use the DriverName from the status
|
||||
pluginName := resourceHandle.DriverName
|
||||
if pluginName == "" {
|
||||
pluginName = claimInfo.DriverName
|
||||
}
|
||||
|
||||
// Call NodeUnprepareResource RPC for each resourceHandle
|
||||
client, err := dra.NewDRAPluginClient(pluginName)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get DRA Plugin client for plugin name %s, err=%+v", claimInfo.DriverName, err)
|
||||
return fmt.Errorf("failed to get DRA Plugin client for plugin name %s, err=%+v", pluginName, err)
|
||||
}
|
||||
response, err := client.NodeUnprepareResource(
|
||||
context.Background(),
|
||||
claimInfo.Namespace,
|
||||
claimInfo.ClaimUID,
|
||||
claimInfo.ClaimName,
|
||||
cdiDevices)
|
||||
resourceHandle.Data)
|
||||
if err != nil {
|
||||
return fmt.Errorf(
|
||||
"NodeUnprepareResource failed, pod: %s, claim UID: %s, claim name: %s, CDI devices: %s, err: %+v",
|
||||
@ -270,7 +296,7 @@ func (m *ManagerImpl) UnprepareResources(pod *v1.Pod) error {
|
||||
m.cache.delete(claimInfo.ClaimName, pod.Namespace)
|
||||
|
||||
// Checkpoint to reduce redundant calls to NodeUnPrepareResource() after a kubelet restart.
|
||||
err := m.cache.syncToCheckpoint()
|
||||
err = m.cache.syncToCheckpoint()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to checkpoint claimInfo state, err: %+v", err)
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ import (
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/klog/v2"
|
||||
|
||||
drapbv1 "k8s.io/kubelet/pkg/apis/dra/v1alpha1"
|
||||
drapbv1 "k8s.io/kubelet/pkg/apis/dra/v1alpha2"
|
||||
)
|
||||
|
||||
const PluginClientTimeout = 10 * time.Second
|
||||
@ -48,7 +48,7 @@ type Client interface {
|
||||
namespace string,
|
||||
claimUID types.UID,
|
||||
claimName string,
|
||||
cdiDevice []string,
|
||||
resourceHandle string,
|
||||
) (*drapbv1.NodeUnprepareResourceResponse, error)
|
||||
}
|
||||
|
||||
@ -145,14 +145,14 @@ func (r *draPluginClient) NodeUnprepareResource(
|
||||
namespace string,
|
||||
claimUID types.UID,
|
||||
claimName string,
|
||||
cdiDevices []string,
|
||||
resourceHandle string,
|
||||
) (*drapbv1.NodeUnprepareResourceResponse, error) {
|
||||
klog.V(4).InfoS(
|
||||
log("calling NodeUnprepareResource rpc"),
|
||||
"namespace", namespace,
|
||||
"claimUID", claimUID,
|
||||
"claimname", claimName,
|
||||
"cdiDevices", cdiDevices)
|
||||
"resourceHandle", resourceHandle)
|
||||
|
||||
if r.nodeV1ClientCreator == nil {
|
||||
return nil, errors.New("nodeV1ClientCreate is nil")
|
||||
@ -165,10 +165,10 @@ func (r *draPluginClient) NodeUnprepareResource(
|
||||
defer closer.Close()
|
||||
|
||||
req := &drapbv1.NodeUnprepareResourceRequest{
|
||||
Namespace: namespace,
|
||||
ClaimUid: string(claimUID),
|
||||
ClaimName: claimName,
|
||||
CdiDevices: cdiDevices,
|
||||
Namespace: namespace,
|
||||
ClaimUid: string(claimUID),
|
||||
ClaimName: claimName,
|
||||
ResourceHandle: resourceHandle,
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithTimeout(ctx, PluginClientTimeout)
|
||||
|
@ -24,7 +24,7 @@ import (
|
||||
"google.golang.org/grpc"
|
||||
"k8s.io/klog/v2"
|
||||
|
||||
drapbv1 "k8s.io/kubelet/pkg/apis/dra/v1alpha1"
|
||||
drapbv1 "k8s.io/kubelet/pkg/apis/dra/v1alpha2"
|
||||
registerapi "k8s.io/kubelet/pkg/apis/pluginregistration/v1"
|
||||
)
|
||||
|
||||
|
@ -17,7 +17,7 @@ limitations under the License.
|
||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: api.proto
|
||||
|
||||
package v1alpha1
|
||||
package v1alpha2
|
||||
|
||||
import (
|
||||
context "context"
|
||||
@ -55,7 +55,7 @@ type NodePrepareResourceRequest struct {
|
||||
// The name of the Resource claim (ResourceClaim.meta.Name)
|
||||
// This field is REQUIRED.
|
||||
ClaimName string `protobuf:"bytes,3,opt,name=claim_name,json=claimName,proto3" json:"claim_name,omitempty"`
|
||||
// Resource handle (AllocationResult.ResourceHandle)
|
||||
// Resource handle (AllocationResult.ResourceHandles[*].Data)
|
||||
// This field is REQUIRED.
|
||||
ResourceHandle string `protobuf:"bytes,4,opt,name=resource_handle,json=resourceHandle,proto3" json:"resource_handle,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
@ -180,9 +180,9 @@ type NodeUnprepareResourceRequest struct {
|
||||
// The name of the Resource claim (ResourceClaim.meta.Name)
|
||||
// This field is REQUIRED.
|
||||
ClaimName string `protobuf:"bytes,3,opt,name=claim_name,json=claimName,proto3" json:"claim_name,omitempty"`
|
||||
// List of fully qualified CDI device names
|
||||
// Kubelet plugin returns them in the NodePrepareResourceResponse
|
||||
CdiDevices []string `protobuf:"bytes,4,rep,name=cdi_devices,json=cdiDevices,proto3" json:"cdi_devices,omitempty"`
|
||||
// Resource handle (AllocationResult.ResourceHandles[*].Data)
|
||||
// This field is REQUIRED.
|
||||
ResourceHandle string `protobuf:"bytes,4,opt,name=resource_handle,json=resourceHandle,proto3" json:"resource_handle,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
@ -240,11 +240,11 @@ func (m *NodeUnprepareResourceRequest) GetClaimName() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *NodeUnprepareResourceRequest) GetCdiDevices() []string {
|
||||
func (m *NodeUnprepareResourceRequest) GetResourceHandle() string {
|
||||
if m != nil {
|
||||
return m.CdiDevices
|
||||
return m.ResourceHandle
|
||||
}
|
||||
return nil
|
||||
return ""
|
||||
}
|
||||
|
||||
type NodeUnprepareResourceResponse struct {
|
||||
@ -285,40 +285,40 @@ func (m *NodeUnprepareResourceResponse) XXX_DiscardUnknown() {
|
||||
var xxx_messageInfo_NodeUnprepareResourceResponse proto.InternalMessageInfo
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*NodePrepareResourceRequest)(nil), "v1alpha1.NodePrepareResourceRequest")
|
||||
proto.RegisterType((*NodePrepareResourceResponse)(nil), "v1alpha1.NodePrepareResourceResponse")
|
||||
proto.RegisterType((*NodeUnprepareResourceRequest)(nil), "v1alpha1.NodeUnprepareResourceRequest")
|
||||
proto.RegisterType((*NodeUnprepareResourceResponse)(nil), "v1alpha1.NodeUnprepareResourceResponse")
|
||||
proto.RegisterType((*NodePrepareResourceRequest)(nil), "v1alpha2.NodePrepareResourceRequest")
|
||||
proto.RegisterType((*NodePrepareResourceResponse)(nil), "v1alpha2.NodePrepareResourceResponse")
|
||||
proto.RegisterType((*NodeUnprepareResourceRequest)(nil), "v1alpha2.NodeUnprepareResourceRequest")
|
||||
proto.RegisterType((*NodeUnprepareResourceResponse)(nil), "v1alpha2.NodeUnprepareResourceResponse")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("api.proto", fileDescriptor_00212fb1f9d3bf1c) }
|
||||
|
||||
var fileDescriptor_00212fb1f9d3bf1c = []byte{
|
||||
// 374 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x52, 0x31, 0x6f, 0xda, 0x40,
|
||||
0x14, 0xe6, 0x0a, 0xaa, 0xf0, 0x55, 0x6a, 0xa5, 0xab, 0x2a, 0x59, 0x06, 0x0c, 0xb2, 0x68, 0x61,
|
||||
0xa9, 0x2d, 0xda, 0xa5, 0x53, 0x07, 0xd4, 0xa1, 0x13, 0xaa, 0x2c, 0xb1, 0x74, 0x41, 0x67, 0xdf,
|
||||
0x8b, 0xb9, 0x60, 0xfb, 0x2e, 0x3e, 0x9b, 0x39, 0x3f, 0x21, 0x6b, 0xa6, 0xfc, 0x1d, 0xc6, 0x8c,
|
||||
0x8c, 0xc1, 0xf9, 0x23, 0x11, 0xe7, 0x58, 0x51, 0x12, 0x10, 0x5b, 0xb6, 0x7b, 0xdf, 0xfb, 0xde,
|
||||
0xfb, 0xbe, 0xf7, 0xde, 0x61, 0x83, 0x4a, 0xee, 0xca, 0x4c, 0xe4, 0x82, 0xb4, 0xd7, 0x13, 0x1a,
|
||||
0xcb, 0x25, 0x9d, 0x58, 0xdf, 0x23, 0x9e, 0x2f, 0x8b, 0xc0, 0x0d, 0x45, 0xe2, 0x45, 0x22, 0x12,
|
||||
0x9e, 0x26, 0x04, 0xc5, 0x99, 0x8e, 0x74, 0xa0, 0x5f, 0x55, 0xa1, 0x73, 0x83, 0xb0, 0x35, 0x13,
|
||||
0x0c, 0xfe, 0x65, 0x20, 0x69, 0x06, 0x3e, 0x28, 0x51, 0x64, 0x21, 0xf8, 0x70, 0x51, 0x80, 0xca,
|
||||
0x49, 0x17, 0x1b, 0x29, 0x4d, 0x40, 0x49, 0x1a, 0x82, 0x89, 0x06, 0x68, 0x6c, 0xf8, 0x4f, 0x00,
|
||||
0xe9, 0x60, 0x23, 0x8c, 0x29, 0x4f, 0x16, 0x05, 0x67, 0xe6, 0x3b, 0x9d, 0x6d, 0x6b, 0x60, 0xce,
|
||||
0x19, 0xe9, 0x61, 0x5c, 0x25, 0xf7, 0x7c, 0xb3, 0x59, 0xd5, 0x6a, 0x64, 0x46, 0x13, 0x20, 0x23,
|
||||
0xfc, 0x29, 0x7b, 0x14, 0x5b, 0x2c, 0x69, 0xca, 0x62, 0x30, 0x5b, 0x9a, 0xf3, 0xb1, 0x86, 0xff,
|
||||
0x6a, 0xd4, 0xf9, 0x8d, 0x3b, 0x07, 0x0d, 0x2a, 0x29, 0x52, 0x05, 0xa4, 0x8f, 0x3f, 0x84, 0x8c,
|
||||
0x2f, 0x18, 0xac, 0x79, 0x08, 0xca, 0x44, 0x83, 0xe6, 0xd8, 0xf0, 0x71, 0xc8, 0xf8, 0x9f, 0x0a,
|
||||
0x71, 0xae, 0x11, 0xee, 0xee, 0x1b, 0xcc, 0x53, 0xf9, 0xd6, 0x33, 0xbe, 0xf0, 0xd6, 0x7a, 0xe5,
|
||||
0xad, 0x8f, 0x7b, 0x47, 0xac, 0x55, 0xd3, 0xfd, 0xd8, 0x22, 0xdc, 0xda, 0x33, 0x08, 0xc3, 0x9f,
|
||||
0x0f, 0x6c, 0x81, 0x0c, 0xdd, 0xfa, 0xf0, 0xee, 0xf1, 0x2b, 0x5a, 0x5f, 0x4f, 0xb0, 0x2a, 0x31,
|
||||
0xa7, 0x41, 0xce, 0xf1, 0x97, 0x83, 0x7e, 0xc8, 0xb7, 0xe7, 0x1d, 0x8e, 0xed, 0xd2, 0x1a, 0x9d,
|
||||
0xe4, 0xd5, 0x5a, 0xd3, 0xe9, 0x66, 0x67, 0xa3, 0xed, 0xce, 0x6e, 0x5c, 0x96, 0x36, 0xda, 0x94,
|
||||
0x36, 0xba, 0x2d, 0x6d, 0x74, 0x57, 0xda, 0xe8, 0xea, 0xde, 0x6e, 0xfc, 0x1f, 0xae, 0x7e, 0x29,
|
||||
0x97, 0x0b, 0x6f, 0x55, 0x04, 0x10, 0x43, 0xee, 0xc9, 0x55, 0xe4, 0x51, 0xc9, 0x95, 0xc7, 0x32,
|
||||
0xea, 0xd5, 0x1a, 0xc1, 0x7b, 0xfd, 0x89, 0x7f, 0x3e, 0x04, 0x00, 0x00, 0xff, 0xff, 0xf6, 0xcb,
|
||||
0x4e, 0x59, 0x0a, 0x03, 0x00, 0x00,
|
||||
// 369 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x52, 0xb1, 0x6e, 0xe2, 0x40,
|
||||
0x10, 0x65, 0x0f, 0x74, 0xc2, 0x7b, 0xd2, 0x9d, 0xb4, 0xa7, 0x93, 0x2c, 0x03, 0x06, 0x59, 0xdc,
|
||||
0x41, 0x73, 0xb6, 0x8e, 0x6b, 0xae, 0xba, 0x02, 0xa5, 0x48, 0x85, 0x22, 0x4b, 0x34, 0x69, 0xd0,
|
||||
0xda, 0x3b, 0x31, 0x1b, 0x6c, 0xef, 0xc6, 0x6b, 0x53, 0xe7, 0x13, 0xf2, 0x07, 0x51, 0xfe, 0x86,
|
||||
0x32, 0x25, 0x65, 0x70, 0x7e, 0x24, 0x62, 0x1d, 0x2b, 0x8a, 0x04, 0xa2, 0x4d, 0xb7, 0xf3, 0xe6,
|
||||
0xcd, 0xbc, 0x37, 0xb3, 0x83, 0x0d, 0x2a, 0xb9, 0x2b, 0x33, 0x91, 0x0b, 0xd2, 0x5e, 0xff, 0xa1,
|
||||
0xb1, 0x5c, 0xd2, 0x89, 0xf5, 0x3b, 0xe2, 0xf9, 0xb2, 0x08, 0xdc, 0x50, 0x24, 0x5e, 0x24, 0x22,
|
||||
0xe1, 0x69, 0x42, 0x50, 0x5c, 0xe9, 0x48, 0x07, 0xfa, 0x55, 0x15, 0x3a, 0xf7, 0x08, 0x5b, 0x33,
|
||||
0xc1, 0xe0, 0x22, 0x03, 0x49, 0x33, 0xf0, 0x41, 0x89, 0x22, 0x0b, 0xc1, 0x87, 0x9b, 0x02, 0x54,
|
||||
0x4e, 0xba, 0xd8, 0x48, 0x69, 0x02, 0x4a, 0xd2, 0x10, 0x4c, 0x34, 0x40, 0x63, 0xc3, 0x7f, 0x03,
|
||||
0x48, 0x07, 0x1b, 0x61, 0x4c, 0x79, 0xb2, 0x28, 0x38, 0x33, 0x3f, 0xe9, 0x6c, 0x5b, 0x03, 0x73,
|
||||
0xce, 0x48, 0x0f, 0xe3, 0x2a, 0xb9, 0xe7, 0x9b, 0xcd, 0xaa, 0x56, 0x23, 0x33, 0x9a, 0x00, 0x19,
|
||||
0xe1, 0x6f, 0xd9, 0xab, 0xd8, 0x62, 0x49, 0x53, 0x16, 0x83, 0xd9, 0xd2, 0x9c, 0xaf, 0x35, 0x7c,
|
||||
0xae, 0x51, 0xe7, 0x3f, 0xee, 0x1c, 0x34, 0xa8, 0xa4, 0x48, 0x15, 0x90, 0x3e, 0xfe, 0x12, 0x32,
|
||||
0xbe, 0x60, 0xb0, 0xe6, 0x21, 0x28, 0x13, 0x0d, 0x9a, 0x63, 0xc3, 0xc7, 0x21, 0xe3, 0x67, 0x15,
|
||||
0xe2, 0x3c, 0x20, 0xdc, 0xdd, 0x37, 0x98, 0xa7, 0xf2, 0xc3, 0xce, 0xd8, 0xc7, 0xbd, 0x23, 0x16,
|
||||
0xab, 0x29, 0x27, 0x5b, 0x84, 0x5b, 0x7b, 0x06, 0x61, 0xf8, 0xfb, 0x81, 0x6d, 0x90, 0xa1, 0x5b,
|
||||
0x1f, 0x80, 0x7b, 0xfc, 0x37, 0xad, 0x9f, 0x27, 0x58, 0x95, 0x98, 0xd3, 0x20, 0xd7, 0xf8, 0xc7,
|
||||
0x41, 0x3f, 0xe4, 0xd7, 0xfb, 0x0e, 0xc7, 0x76, 0x6a, 0x8d, 0x4e, 0xf2, 0x6a, 0xad, 0xe9, 0x74,
|
||||
0xb3, 0xb3, 0xd1, 0x76, 0x67, 0x37, 0x6e, 0x4b, 0x1b, 0x6d, 0x4a, 0x1b, 0x3d, 0x96, 0x36, 0x7a,
|
||||
0x2a, 0x6d, 0x74, 0xf7, 0x6c, 0x37, 0x2e, 0x87, 0xab, 0x7f, 0xca, 0xe5, 0xc2, 0x5b, 0x15, 0x01,
|
||||
0xc4, 0x90, 0x7b, 0x72, 0x15, 0x79, 0x54, 0x72, 0xe5, 0xb1, 0x8c, 0x7a, 0xb5, 0x46, 0xf0, 0x59,
|
||||
0x1f, 0xf3, 0xdf, 0x97, 0x00, 0x00, 0x00, 0xff, 0xff, 0x89, 0x2f, 0x77, 0x8e, 0x12, 0x03, 0x00,
|
||||
0x00,
|
||||
}
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
@ -347,7 +347,7 @@ func NewNodeClient(cc *grpc.ClientConn) NodeClient {
|
||||
|
||||
func (c *nodeClient) NodePrepareResource(ctx context.Context, in *NodePrepareResourceRequest, opts ...grpc.CallOption) (*NodePrepareResourceResponse, error) {
|
||||
out := new(NodePrepareResourceResponse)
|
||||
err := c.cc.Invoke(ctx, "/v1alpha1.Node/NodePrepareResource", in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, "/v1alpha2.Node/NodePrepareResource", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -356,7 +356,7 @@ func (c *nodeClient) NodePrepareResource(ctx context.Context, in *NodePrepareRes
|
||||
|
||||
func (c *nodeClient) NodeUnprepareResource(ctx context.Context, in *NodeUnprepareResourceRequest, opts ...grpc.CallOption) (*NodeUnprepareResourceResponse, error) {
|
||||
out := new(NodeUnprepareResourceResponse)
|
||||
err := c.cc.Invoke(ctx, "/v1alpha1.Node/NodeUnprepareResource", in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, "/v1alpha2.Node/NodeUnprepareResource", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -394,7 +394,7 @@ func _Node_NodePrepareResource_Handler(srv interface{}, ctx context.Context, dec
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/v1alpha1.Node/NodePrepareResource",
|
||||
FullMethod: "/v1alpha2.Node/NodePrepareResource",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(NodeServer).NodePrepareResource(ctx, req.(*NodePrepareResourceRequest))
|
||||
@ -412,7 +412,7 @@ func _Node_NodeUnprepareResource_Handler(srv interface{}, ctx context.Context, d
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/v1alpha1.Node/NodeUnprepareResource",
|
||||
FullMethod: "/v1alpha2.Node/NodeUnprepareResource",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(NodeServer).NodeUnprepareResource(ctx, req.(*NodeUnprepareResourceRequest))
|
||||
@ -421,7 +421,7 @@ func _Node_NodeUnprepareResource_Handler(srv interface{}, ctx context.Context, d
|
||||
}
|
||||
|
||||
var _Node_serviceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "v1alpha1.Node",
|
||||
ServiceName: "v1alpha2.Node",
|
||||
HandlerType: (*NodeServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
@ -540,14 +540,12 @@ func (m *NodeUnprepareResourceRequest) MarshalToSizedBuffer(dAtA []byte) (int, e
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.CdiDevices) > 0 {
|
||||
for iNdEx := len(m.CdiDevices) - 1; iNdEx >= 0; iNdEx-- {
|
||||
i -= len(m.CdiDevices[iNdEx])
|
||||
copy(dAtA[i:], m.CdiDevices[iNdEx])
|
||||
i = encodeVarintApi(dAtA, i, uint64(len(m.CdiDevices[iNdEx])))
|
||||
i--
|
||||
dAtA[i] = 0x22
|
||||
}
|
||||
if len(m.ResourceHandle) > 0 {
|
||||
i -= len(m.ResourceHandle)
|
||||
copy(dAtA[i:], m.ResourceHandle)
|
||||
i = encodeVarintApi(dAtA, i, uint64(len(m.ResourceHandle)))
|
||||
i--
|
||||
dAtA[i] = 0x22
|
||||
}
|
||||
if len(m.ClaimName) > 0 {
|
||||
i -= len(m.ClaimName)
|
||||
@ -665,11 +663,9 @@ func (m *NodeUnprepareResourceRequest) Size() (n int) {
|
||||
if l > 0 {
|
||||
n += 1 + l + sovApi(uint64(l))
|
||||
}
|
||||
if len(m.CdiDevices) > 0 {
|
||||
for _, s := range m.CdiDevices {
|
||||
l = len(s)
|
||||
n += 1 + l + sovApi(uint64(l))
|
||||
}
|
||||
l = len(m.ResourceHandle)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovApi(uint64(l))
|
||||
}
|
||||
return n
|
||||
}
|
||||
@ -720,7 +716,7 @@ func (this *NodeUnprepareResourceRequest) String() string {
|
||||
`Namespace:` + fmt.Sprintf("%v", this.Namespace) + `,`,
|
||||
`ClaimUid:` + fmt.Sprintf("%v", this.ClaimUid) + `,`,
|
||||
`ClaimName:` + fmt.Sprintf("%v", this.ClaimName) + `,`,
|
||||
`CdiDevices:` + fmt.Sprintf("%v", this.CdiDevices) + `,`,
|
||||
`ResourceHandle:` + fmt.Sprintf("%v", this.ResourceHandle) + `,`,
|
||||
`}`,
|
||||
}, "")
|
||||
return s
|
||||
@ -1129,7 +1125,7 @@ func (m *NodeUnprepareResourceRequest) Unmarshal(dAtA []byte) error {
|
||||
iNdEx = postIndex
|
||||
case 4:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field CdiDevices", wireType)
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field ResourceHandle", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
@ -1157,7 +1153,7 @@ func (m *NodeUnprepareResourceRequest) Unmarshal(dAtA []byte) error {
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.CdiDevices = append(m.CdiDevices, string(dAtA[iNdEx:postIndex]))
|
||||
m.ResourceHandle = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2022 The Kubernetes Authors.
|
||||
Copyright 2023 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -18,8 +18,8 @@ limitations under the License.
|
||||
|
||||
syntax = "proto3";
|
||||
|
||||
package v1alpha1;
|
||||
option go_package = "k8s.io/kubelet/pkg/apis/dra/v1alpha1";
|
||||
package v1alpha2;
|
||||
option go_package = "k8s.io/kubelet/pkg/apis/dra/v1alpha2";
|
||||
|
||||
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
|
||||
|
||||
@ -49,7 +49,7 @@ message NodePrepareResourceRequest {
|
||||
// The name of the Resource claim (ResourceClaim.meta.Name)
|
||||
// This field is REQUIRED.
|
||||
string claim_name = 3;
|
||||
// Resource handle (AllocationResult.ResourceHandle)
|
||||
// Resource handle (AllocationResult.ResourceHandles[*].Data)
|
||||
// This field is REQUIRED.
|
||||
string resource_handle = 4;
|
||||
}
|
||||
@ -71,9 +71,9 @@ message NodeUnprepareResourceRequest {
|
||||
// The name of the Resource claim (ResourceClaim.meta.Name)
|
||||
// This field is REQUIRED.
|
||||
string claim_name = 3;
|
||||
// List of fully qualified CDI device names
|
||||
// Kubelet plugin returns them in the NodePrepareResourceResponse
|
||||
repeated string cdi_devices = 4;
|
||||
// Resource handle (AllocationResult.ResourceHandles[*].Data)
|
||||
// This field is REQUIRED.
|
||||
string resource_handle = 4;
|
||||
}
|
||||
|
||||
message NodeUnprepareResourceResponse {
|
@ -48,8 +48,8 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
NodePrepareResourceMethod = "/v1alpha1.Node/NodePrepareResource"
|
||||
NodeUnprepareResourceMethod = "/v1alpha1.Node/NodeUnprepareResource"
|
||||
NodePrepareResourceMethod = "/v1alpha2.Node/NodePrepareResource"
|
||||
NodeUnprepareResourceMethod = "/v1alpha2.Node/NodeUnprepareResource"
|
||||
)
|
||||
|
||||
type Nodes struct {
|
||||
|
@ -26,7 +26,7 @@ import (
|
||||
|
||||
"k8s.io/dynamic-resource-allocation/kubeletplugin"
|
||||
"k8s.io/klog/v2"
|
||||
drapbv1 "k8s.io/kubelet/pkg/apis/dra/v1alpha1"
|
||||
drapbv1 "k8s.io/kubelet/pkg/apis/dra/v1alpha2"
|
||||
)
|
||||
|
||||
type ExamplePlugin struct {
|
||||
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@ -2225,7 +2225,7 @@ k8s.io/kubelet/pkg/apis/credentialprovider/v1
|
||||
k8s.io/kubelet/pkg/apis/credentialprovider/v1alpha1
|
||||
k8s.io/kubelet/pkg/apis/credentialprovider/v1beta1
|
||||
k8s.io/kubelet/pkg/apis/deviceplugin/v1beta1
|
||||
k8s.io/kubelet/pkg/apis/dra/v1alpha1
|
||||
k8s.io/kubelet/pkg/apis/dra/v1alpha2
|
||||
k8s.io/kubelet/pkg/apis/pluginregistration/v1
|
||||
k8s.io/kubelet/pkg/apis/podresources/v1
|
||||
k8s.io/kubelet/pkg/apis/podresources/v1alpha1
|
||||
|
Loading…
Reference in New Issue
Block a user