diff --git a/pkg/kubelet/cm/dra/plugin/client.go b/pkg/kubelet/cm/dra/plugin/client.go index 09d4771746d..5ec5c9d3987 100644 --- a/pkg/kubelet/cm/dra/plugin/client.go +++ b/pkg/kubelet/cm/dra/plugin/client.go @@ -22,112 +22,13 @@ import ( "time" "google.golang.org/grpc" - grpccodes "google.golang.org/grpc/codes" - grpcstatus "google.golang.org/grpc/status" "k8s.io/klog/v2" - drapbv1alpha2 "k8s.io/kubelet/pkg/apis/dra/v1alpha2" drapb "k8s.io/kubelet/pkg/apis/dra/v1alpha3" ) const PluginClientTimeout = 45 * time.Second -type ( - nodeResourceManager interface { - Prepare(context.Context, *grpc.ClientConn, *plugin, *drapb.NodePrepareResourcesRequest) (*drapb.NodePrepareResourcesResponse, error) - Unprepare(context.Context, *grpc.ClientConn, *plugin, *drapb.NodeUnprepareResourcesRequest) (*drapb.NodeUnprepareResourcesResponse, error) - } - - v1alpha2NodeResourceManager struct{} - v1alpha3NodeResourceManager struct{} -) - -var nodeResourceManagers = map[string]nodeResourceManager{ - v1alpha2Version: v1alpha2NodeResourceManager{}, - v1alpha3Version: v1alpha3NodeResourceManager{}, -} - -func (v1alpha2rm v1alpha2NodeResourceManager) Prepare(ctx context.Context, conn *grpc.ClientConn, _ *plugin, req *drapb.NodePrepareResourcesRequest) (*drapb.NodePrepareResourcesResponse, error) { - nodeClient := drapbv1alpha2.NewNodeClient(conn) - response := &drapb.NodePrepareResourcesResponse{ - Claims: make(map[string]*drapb.NodePrepareResourceResponse), - } - - for _, claim := range req.Claims { - req := &drapbv1alpha2.NodePrepareResourceRequest{ - Namespace: claim.Namespace, - ClaimUid: claim.Uid, - ClaimName: claim.Name, - ResourceHandle: claim.ResourceHandle, - StructuredResourceHandle: claim.StructuredResourceHandle, - } - res, err := nodeClient.NodePrepareResource(ctx, req) - result := &drapb.NodePrepareResourceResponse{} - if err != nil { - result.Error = err.Error() - } else { - result.CDIDevices = res.CdiDevices - } - response.Claims[claim.Uid] = result - } - - return response, nil -} - -func (v1alpha2rm v1alpha2NodeResourceManager) Unprepare(ctx context.Context, conn *grpc.ClientConn, _ *plugin, req *drapb.NodeUnprepareResourcesRequest) (*drapb.NodeUnprepareResourcesResponse, error) { - nodeClient := drapbv1alpha2.NewNodeClient(conn) - response := &drapb.NodeUnprepareResourcesResponse{ - Claims: make(map[string]*drapb.NodeUnprepareResourceResponse), - } - - for _, claim := range req.Claims { - _, err := nodeClient.NodeUnprepareResource(ctx, - &drapbv1alpha2.NodeUnprepareResourceRequest{ - Namespace: claim.Namespace, - ClaimUid: claim.Uid, - ClaimName: claim.Name, - ResourceHandle: claim.ResourceHandle, - }) - result := &drapb.NodeUnprepareResourceResponse{} - if err != nil { - result.Error = err.Error() - } - response.Claims[claim.Uid] = result - } - - return response, nil -} - -func (v1alpha3rm v1alpha3NodeResourceManager) Prepare(ctx context.Context, conn *grpc.ClientConn, p *plugin, req *drapb.NodePrepareResourcesRequest) (*drapb.NodePrepareResourcesResponse, error) { - nodeClient := drapb.NewNodeClient(conn) - response, err := nodeClient.NodePrepareResources(ctx, req) - if err != nil { - status, _ := grpcstatus.FromError(err) - if status.Code() == grpccodes.Unimplemented { - p.setVersion(v1alpha2Version) - return nodeResourceManagers[v1alpha2Version].Prepare(ctx, conn, p, req) - } - return nil, err - } - - return response, nil -} - -func (v1alpha3rm v1alpha3NodeResourceManager) Unprepare(ctx context.Context, conn *grpc.ClientConn, p *plugin, req *drapb.NodeUnprepareResourcesRequest) (*drapb.NodeUnprepareResourcesResponse, error) { - nodeClient := drapb.NewNodeClient(conn) - response, err := nodeClient.NodeUnprepareResources(ctx, req) - if err != nil { - status, _ := grpcstatus.FromError(err) - if status.Code() == grpccodes.Unimplemented { - p.setVersion(v1alpha2Version) - return nodeResourceManagers[v1alpha2Version].Unprepare(ctx, conn, p, req) - } - return nil, err - } - - return response, nil -} - func NewDRAPluginClient(pluginName string) (drapb.NodeClient, error) { if pluginName == "" { return nil, fmt.Errorf("plugin name is empty") @@ -157,15 +58,8 @@ func (p *plugin) NodePrepareResources( ctx, cancel := context.WithTimeout(ctx, p.clientTimeout) defer cancel() - version := p.getVersion() - resourceManager, exists := nodeResourceManagers[version] - if !exists { - err := fmt.Errorf("unsupported plugin version: %s", version) - logger.V(4).Info(log("done calling NodePrepareResources rpc"), "response", nil, "err", err) - return nil, err - } - - response, err := resourceManager.Prepare(ctx, conn, p, req) + nodeClient := drapb.NewNodeClient(conn) + response, err := nodeClient.NodePrepareResources(ctx, req) logger.V(4).Info(log("done calling NodePrepareResources rpc"), "response", response, "err", err) return response, err } @@ -186,15 +80,8 @@ func (p *plugin) NodeUnprepareResources( ctx, cancel := context.WithTimeout(ctx, p.clientTimeout) defer cancel() - version := p.getVersion() - resourceManager, exists := nodeResourceManagers[version] - if !exists { - err := fmt.Errorf("unsupported plugin version: %s", version) - logger.V(4).Info(log("done calling NodeUnprepareResources rpc"), "response", nil, "err", err) - return nil, err - } - - response, err := resourceManager.Unprepare(ctx, conn, p, req) + nodeClient := drapb.NewNodeClient(conn) + response, err := nodeClient.NodeUnprepareResources(ctx, req) logger.V(4).Info(log("done calling NodeUnprepareResources rpc"), "response", response, "err", err) return response, err } diff --git a/pkg/kubelet/cm/dra/plugin/client_test.go b/pkg/kubelet/cm/dra/plugin/client_test.go index 26cbb4b10f7..398f8ff60f9 100644 --- a/pkg/kubelet/cm/dra/plugin/client_test.go +++ b/pkg/kubelet/cm/dra/plugin/client_test.go @@ -27,7 +27,6 @@ import ( "github.com/stretchr/testify/assert" "google.golang.org/grpc" - drapbv1alpha2 "k8s.io/kubelet/pkg/apis/dra/v1alpha2" drapbv1alpha3 "k8s.io/kubelet/pkg/apis/dra/v1alpha3" ) @@ -35,11 +34,14 @@ type fakeV1alpha3GRPCServer struct { drapbv1alpha3.UnimplementedNodeServer } -func (f *fakeV1alpha3GRPCServer) NodePrepareResource(ctx context.Context, in *drapbv1alpha3.NodePrepareResourcesRequest) (*drapbv1alpha3.NodePrepareResourcesResponse, error) { +var _ drapbv1alpha3.NodeServer = &fakeV1alpha3GRPCServer{} + +func (f *fakeV1alpha3GRPCServer) NodePrepareResources(ctx context.Context, in *drapbv1alpha3.NodePrepareResourcesRequest) (*drapbv1alpha3.NodePrepareResourcesResponse, error) { return &drapbv1alpha3.NodePrepareResourcesResponse{Claims: map[string]*drapbv1alpha3.NodePrepareResourceResponse{"dummy": {CDIDevices: []string{"dummy"}}}}, nil } -func (f *fakeV1alpha3GRPCServer) NodeUnprepareResource(ctx context.Context, in *drapbv1alpha3.NodeUnprepareResourcesRequest) (*drapbv1alpha3.NodeUnprepareResourcesResponse, error) { +func (f *fakeV1alpha3GRPCServer) NodeUnprepareResources(ctx context.Context, in *drapbv1alpha3.NodeUnprepareResourcesRequest) (*drapbv1alpha3.NodeUnprepareResourcesResponse, error) { + return &drapbv1alpha3.NodeUnprepareResourcesResponse{}, nil } @@ -53,18 +55,6 @@ func (f *fakeV1alpha3GRPCServer) NodeListAndWatchResources(req *drapbv1alpha3.No return nil } -type fakeV1alpha2GRPCServer struct { - drapbv1alpha2.UnimplementedNodeServer -} - -func (f *fakeV1alpha2GRPCServer) NodePrepareResource(ctx context.Context, in *drapbv1alpha2.NodePrepareResourceRequest) (*drapbv1alpha2.NodePrepareResourceResponse, error) { - return &drapbv1alpha2.NodePrepareResourceResponse{CdiDevices: []string{"dummy"}}, nil -} - -func (f *fakeV1alpha2GRPCServer) NodeUnprepareResource(ctx context.Context, in *drapbv1alpha2.NodeUnprepareResourceRequest) (*drapbv1alpha2.NodeUnprepareResourceResponse, error) { - return &drapbv1alpha2.NodeUnprepareResourceResponse{}, nil -} - type tearDown func() func setupFakeGRPCServer(version string) (string, tearDown, error) { @@ -88,9 +78,6 @@ func setupFakeGRPCServer(version string) (string, tearDown, error) { s := grpc.NewServer() switch version { - case v1alpha2Version: - fakeGRPCServer := &fakeV1alpha2GRPCServer{} - drapbv1alpha2.RegisterNodeServer(s, fakeGRPCServer) case v1alpha3Version: fakeGRPCServer := &fakeV1alpha3GRPCServer{} drapbv1alpha3.RegisterNodeServer(s, fakeGRPCServer) @@ -120,7 +107,6 @@ func TestGRPCConnIsReused(t *testing.T) { p := &plugin{ endpoint: addr, - version: v1alpha3Version, } conn, err := p.getOrCreateGRPCConn() @@ -231,7 +217,7 @@ func TestNewDRAPluginClient(t *testing.T) { } } -func TestNodeUnprepareResource(t *testing.T) { +func TestNodeUnprepareResources(t *testing.T) { for _, test := range []struct { description string serverSetup func(string) (string, tearDown, error) @@ -244,21 +230,6 @@ func TestNodeUnprepareResource(t *testing.T) { serverVersion: v1alpha3Version, request: &drapbv1alpha3.NodeUnprepareResourcesRequest{}, }, - { - description: "server supports v1alpha2, plugin client should fallback", - serverSetup: setupFakeGRPCServer, - serverVersion: v1alpha2Version, - request: &drapbv1alpha3.NodeUnprepareResourcesRequest{ - Claims: []*drapbv1alpha3.Claim{ - { - Namespace: "dummy-namespace", - Uid: "dummy-uid", - Name: "dummy-claim", - ResourceHandle: "dummy-resource", - }, - }, - }, - }, } { t.Run(test.description, func(t *testing.T) { addr, teardown, err := setupFakeGRPCServer(test.serverVersion) @@ -269,7 +240,6 @@ func TestNodeUnprepareResource(t *testing.T) { p := &plugin{ endpoint: addr, - version: v1alpha3Version, clientTimeout: PluginClientTimeout, } @@ -320,13 +290,6 @@ func TestListAndWatchResources(t *testing.T) { }, expectError: "EOF", }, - { - description: "server doesn't support NodeResources API", - serverSetup: setupFakeGRPCServer, - serverVersion: v1alpha2Version, - request: new(drapbv1alpha3.NodeListAndWatchResourcesRequest), - expectError: "Unimplemented", - }, } { t.Run(test.description, func(t *testing.T) { addr, teardown, err := setupFakeGRPCServer(test.serverVersion) @@ -337,7 +300,6 @@ func TestListAndWatchResources(t *testing.T) { p := &plugin{ endpoint: addr, - version: v1alpha3Version, } conn, err := p.getOrCreateGRPCConn() diff --git a/pkg/kubelet/cm/dra/plugin/plugin.go b/pkg/kubelet/cm/dra/plugin/plugin.go index 54271ac8256..2d3d0dc5472 100644 --- a/pkg/kubelet/cm/dra/plugin/plugin.go +++ b/pkg/kubelet/cm/dra/plugin/plugin.go @@ -38,16 +38,13 @@ const ( // DRAPluginName is the name of the in-tree DRA Plugin. DRAPluginName = "kubernetes.io/dra" v1alpha3Version = "v1alpha3" - v1alpha2Version = "v1alpha2" ) -// Plugin is a description of a DRA Plugin, defined by an endpoint -// and the highest DRA version supported. +// Plugin is a description of a DRA Plugin, defined by an endpoint. type plugin struct { sync.Mutex conn *grpc.ClientConn endpoint string - version string highestSupportedVersion *utilversion.Version clientTimeout time.Duration } @@ -84,18 +81,6 @@ func (p *plugin) getOrCreateGRPCConn() (*grpc.ClientConn, error) { return p.conn, nil } -func (p *plugin) getVersion() string { - p.Lock() - defer p.Unlock() - return p.version -} - -func (p *plugin) setVersion(version string) { - p.Lock() - p.version = version - p.Unlock() -} - // RegistrationHandler is the handler which is fed to the pluginwatcher API. type RegistrationHandler struct { controller *nodeResourcesController @@ -135,7 +120,6 @@ func (h *RegistrationHandler) RegisterPlugin(pluginName string, endpoint string, pluginInstance := &plugin{ conn: nil, endpoint: endpoint, - version: v1alpha3Version, highestSupportedVersion: highestSupportedVersion, clientTimeout: timeout, } diff --git a/staging/src/k8s.io/dynamic-resource-allocation/kubeletplugin/draplugin.go b/staging/src/k8s.io/dynamic-resource-allocation/kubeletplugin/draplugin.go index 282b407bd55..4033d6056c3 100644 --- a/staging/src/k8s.io/dynamic-resource-allocation/kubeletplugin/draplugin.go +++ b/staging/src/k8s.io/dynamic-resource-allocation/kubeletplugin/draplugin.go @@ -24,7 +24,6 @@ import ( "google.golang.org/grpc" "k8s.io/klog/v2" - drapbv1alpha2 "k8s.io/kubelet/pkg/apis/dra/v1alpha2" drapbv1alpha3 "k8s.io/kubelet/pkg/apis/dra/v1alpha3" registerapi "k8s.io/kubelet/pkg/apis/pluginregistration/v1" ) @@ -154,16 +153,7 @@ func GRPCStreamInterceptor(interceptor grpc.StreamServerInterceptor) Option { } } -// NodeV1alpha2 explicitly chooses whether the DRA gRPC API v1alpha2 -// gets enabled. -func NodeV1alpha2(enabled bool) Option { - return func(o *options) error { - o.nodeV1alpha2 = enabled - return nil - } -} - -// NodeV1alpha2 explicitly chooses whether the DRA gRPC API v1alpha3 +// NodeV1alpha3 explicitly chooses whether the DRA gRPC API v1alpha3 // gets enabled. func NodeV1alpha3(enabled bool) Option { return func(o *options) error { @@ -182,7 +172,7 @@ type options struct { unaryInterceptors []grpc.UnaryServerInterceptor streamInterceptors []grpc.StreamServerInterceptor - nodeV1alpha2, nodeV1alpha3 bool + nodeV1alpha3 bool } // draPlugin combines the kubelet registration service and the DRA node plugin @@ -200,7 +190,6 @@ func Start(nodeServer interface{}, opts ...Option) (result DRAPlugin, finalErr e o := options{ logger: klog.Background(), grpcVerbosity: 4, - nodeV1alpha2: true, nodeV1alpha3: true, } for _, option := range opts { @@ -231,11 +220,6 @@ func Start(nodeServer interface{}, opts ...Option) (result DRAPlugin, finalErr e drapbv1alpha3.RegisterNodeServer(grpcServer, nodeServer) implemented = true } - if nodeServer, ok := nodeServer.(drapbv1alpha2.NodeServer); ok && o.nodeV1alpha2 { - o.logger.V(5).Info("registering drapbv1alpha2.NodeServer") - drapbv1alpha2.RegisterNodeServer(grpcServer, nodeServer) - implemented = true - } }) if err != nil { return nil, fmt.Errorf("start node client: %v", err) diff --git a/staging/src/k8s.io/kubelet/pkg/apis/dra/v1alpha2/api.pb.go b/staging/src/k8s.io/kubelet/pkg/apis/dra/v1alpha2/api.pb.go deleted file mode 100644 index 047515a147d..00000000000 --- a/staging/src/k8s.io/kubelet/pkg/apis/dra/v1alpha2/api.pb.go +++ /dev/null @@ -1,1460 +0,0 @@ -/* -Copyright 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. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: api.proto - -package v1alpha2 - -import ( - context "context" - fmt "fmt" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - io "io" - v1alpha2 "k8s.io/api/resource/v1alpha2" - math "math" - math_bits "math/bits" - reflect "reflect" - strings "strings" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -type NodePrepareResourceRequest struct { - // The ResourceClaim namespace (ResourceClaim.meta.Namespace). - // This field is REQUIRED. - Namespace string `protobuf:"bytes,1,opt,name=namespace,proto3" json:"namespace,omitempty"` - // The UID of the Resource claim (ResourceClaim.meta.UUID). - // This field is REQUIRED. - ClaimUid string `protobuf:"bytes,2,opt,name=claim_uid,json=claimUid,proto3" json:"claim_uid,omitempty"` - // 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.ResourceHandles[*].Data) - // This field is REQUIRED. - ResourceHandle string `protobuf:"bytes,4,opt,name=resource_handle,json=resourceHandle,proto3" json:"resource_handle,omitempty"` - // Structured parameter resource handle (AllocationResult.ResourceHandles[*].StructuredData). - // This field is OPTIONAL. If present, it needs to be used - // instead of resource_handle. It will only have a single entry. - // - // Using "repeated" instead of "optional" is a workaround for https://github.com/gogo/protobuf/issues/713. - StructuredResourceHandle []*v1alpha2.StructuredResourceHandle `protobuf:"bytes,5,rep,name=structured_resource_handle,json=structuredResourceHandle,proto3" json:"structured_resource_handle,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *NodePrepareResourceRequest) Reset() { *m = NodePrepareResourceRequest{} } -func (*NodePrepareResourceRequest) ProtoMessage() {} -func (*NodePrepareResourceRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_00212fb1f9d3bf1c, []int{0} -} -func (m *NodePrepareResourceRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *NodePrepareResourceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_NodePrepareResourceRequest.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *NodePrepareResourceRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_NodePrepareResourceRequest.Merge(m, src) -} -func (m *NodePrepareResourceRequest) XXX_Size() int { - return m.Size() -} -func (m *NodePrepareResourceRequest) XXX_DiscardUnknown() { - xxx_messageInfo_NodePrepareResourceRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_NodePrepareResourceRequest proto.InternalMessageInfo - -func (m *NodePrepareResourceRequest) GetNamespace() string { - if m != nil { - return m.Namespace - } - return "" -} - -func (m *NodePrepareResourceRequest) GetClaimUid() string { - if m != nil { - return m.ClaimUid - } - return "" -} - -func (m *NodePrepareResourceRequest) GetClaimName() string { - if m != nil { - return m.ClaimName - } - return "" -} - -func (m *NodePrepareResourceRequest) GetResourceHandle() string { - if m != nil { - return m.ResourceHandle - } - return "" -} - -func (m *NodePrepareResourceRequest) GetStructuredResourceHandle() []*v1alpha2.StructuredResourceHandle { - if m != nil { - return m.StructuredResourceHandle - } - return nil -} - -type NodePrepareResourceResponse struct { - // These are the additional devices that kubelet must - // make available via the container runtime. A resource - // may have zero or more devices. - CdiDevices []string `protobuf:"bytes,1,rep,name=cdi_devices,json=cdiDevices,proto3" json:"cdi_devices,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *NodePrepareResourceResponse) Reset() { *m = NodePrepareResourceResponse{} } -func (*NodePrepareResourceResponse) ProtoMessage() {} -func (*NodePrepareResourceResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_00212fb1f9d3bf1c, []int{1} -} -func (m *NodePrepareResourceResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *NodePrepareResourceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_NodePrepareResourceResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *NodePrepareResourceResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_NodePrepareResourceResponse.Merge(m, src) -} -func (m *NodePrepareResourceResponse) XXX_Size() int { - return m.Size() -} -func (m *NodePrepareResourceResponse) XXX_DiscardUnknown() { - xxx_messageInfo_NodePrepareResourceResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_NodePrepareResourceResponse proto.InternalMessageInfo - -func (m *NodePrepareResourceResponse) GetCdiDevices() []string { - if m != nil { - return m.CdiDevices - } - return nil -} - -type NodeUnprepareResourceRequest struct { - // The ResourceClaim namespace (ResourceClaim.meta.Namespace). - // This field is REQUIRED. - Namespace string `protobuf:"bytes,1,opt,name=namespace,proto3" json:"namespace,omitempty"` - // The UID of the Resource claim (ResourceClaim.meta.UUID). - // This field is REQUIRED. - ClaimUid string `protobuf:"bytes,2,opt,name=claim_uid,json=claimUid,proto3" json:"claim_uid,omitempty"` - // 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.ResourceHandles[*].Data) - // This field is REQUIRED. - ResourceHandle string `protobuf:"bytes,4,opt,name=resource_handle,json=resourceHandle,proto3" json:"resource_handle,omitempty"` - // Structured parameter resource handle (AllocationResult.ResourceHandles[*].StructuredData). - // This field is OPTIONAL. If present, it needs to be used - // instead of resource_handle. It will only have a single entry. - StructuredResourceHandle []*v1alpha2.StructuredResourceHandle `protobuf:"bytes,5,rep,name=structured_resource_handle,json=structuredResourceHandle,proto3" json:"structured_resource_handle,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *NodeUnprepareResourceRequest) Reset() { *m = NodeUnprepareResourceRequest{} } -func (*NodeUnprepareResourceRequest) ProtoMessage() {} -func (*NodeUnprepareResourceRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_00212fb1f9d3bf1c, []int{2} -} -func (m *NodeUnprepareResourceRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *NodeUnprepareResourceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_NodeUnprepareResourceRequest.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *NodeUnprepareResourceRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_NodeUnprepareResourceRequest.Merge(m, src) -} -func (m *NodeUnprepareResourceRequest) XXX_Size() int { - return m.Size() -} -func (m *NodeUnprepareResourceRequest) XXX_DiscardUnknown() { - xxx_messageInfo_NodeUnprepareResourceRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_NodeUnprepareResourceRequest proto.InternalMessageInfo - -func (m *NodeUnprepareResourceRequest) GetNamespace() string { - if m != nil { - return m.Namespace - } - return "" -} - -func (m *NodeUnprepareResourceRequest) GetClaimUid() string { - if m != nil { - return m.ClaimUid - } - return "" -} - -func (m *NodeUnprepareResourceRequest) GetClaimName() string { - if m != nil { - return m.ClaimName - } - return "" -} - -func (m *NodeUnprepareResourceRequest) GetResourceHandle() string { - if m != nil { - return m.ResourceHandle - } - return "" -} - -func (m *NodeUnprepareResourceRequest) GetStructuredResourceHandle() []*v1alpha2.StructuredResourceHandle { - if m != nil { - return m.StructuredResourceHandle - } - return nil -} - -type NodeUnprepareResourceResponse struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *NodeUnprepareResourceResponse) Reset() { *m = NodeUnprepareResourceResponse{} } -func (*NodeUnprepareResourceResponse) ProtoMessage() {} -func (*NodeUnprepareResourceResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_00212fb1f9d3bf1c, []int{3} -} -func (m *NodeUnprepareResourceResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *NodeUnprepareResourceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_NodeUnprepareResourceResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *NodeUnprepareResourceResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_NodeUnprepareResourceResponse.Merge(m, src) -} -func (m *NodeUnprepareResourceResponse) XXX_Size() int { - return m.Size() -} -func (m *NodeUnprepareResourceResponse) XXX_DiscardUnknown() { - xxx_messageInfo_NodeUnprepareResourceResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_NodeUnprepareResourceResponse proto.InternalMessageInfo - -func init() { - 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{ - // 432 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x53, 0x4d, 0x6f, 0xd3, 0x40, - 0x10, 0xcd, 0x26, 0x05, 0xd5, 0x53, 0x09, 0xa4, 0x45, 0x48, 0x96, 0xdb, 0xba, 0x51, 0x54, 0x68, - 0x0e, 0x60, 0x8b, 0x20, 0x21, 0x4e, 0x1c, 0x2a, 0x0e, 0x9c, 0x2a, 0x64, 0xd4, 0x0b, 0x97, 0x68, - 0xe3, 0x1d, 0x9c, 0x25, 0x89, 0x77, 0xd9, 0x8f, 0x9e, 0xf9, 0x09, 0x5c, 0x10, 0x7f, 0xa9, 0x47, - 0x8e, 0x3d, 0xd2, 0xf0, 0x47, 0x90, 0x77, 0xeb, 0x56, 0x41, 0x89, 0xf2, 0x07, 0x7a, 0xf3, 0xbe, - 0x79, 0x6f, 0x66, 0xf7, 0x8d, 0x1f, 0x44, 0x4c, 0x89, 0x4c, 0x69, 0x69, 0x25, 0xdd, 0xbd, 0x78, - 0xc5, 0xe6, 0x6a, 0xca, 0x46, 0xc9, 0xcb, 0x4a, 0xd8, 0xa9, 0x9b, 0x64, 0xa5, 0x5c, 0xe4, 0x95, - 0xac, 0x64, 0xee, 0x09, 0x13, 0xf7, 0xc5, 0x9f, 0xfc, 0xc1, 0x7f, 0x05, 0x61, 0xf2, 0x62, 0xf6, - 0xd6, 0x64, 0x42, 0xe6, 0x4c, 0x89, 0x5c, 0xa3, 0x91, 0x4e, 0x97, 0x98, 0xb7, 0xcd, 0xf2, 0x0a, - 0x6b, 0xd4, 0xcc, 0x22, 0x0f, 0xec, 0xc1, 0xcf, 0x2e, 0x24, 0x67, 0x92, 0xe3, 0x47, 0x8d, 0x8a, - 0x69, 0x2c, 0x6e, 0x04, 0x05, 0x7e, 0x73, 0x68, 0x2c, 0x3d, 0x80, 0xa8, 0x66, 0x0b, 0x34, 0x8a, - 0x95, 0x18, 0x93, 0x3e, 0x19, 0x46, 0xc5, 0x1d, 0x40, 0xf7, 0x21, 0x2a, 0xe7, 0x4c, 0x2c, 0xc6, - 0x4e, 0xf0, 0xb8, 0xeb, 0xab, 0xbb, 0x1e, 0x38, 0x17, 0x9c, 0x1e, 0x02, 0x84, 0x62, 0xc3, 0x8f, - 0x7b, 0x41, 0xeb, 0x91, 0x33, 0xb6, 0x40, 0x7a, 0x02, 0x8f, 0xdb, 0xdb, 0x8d, 0xa7, 0xac, 0xe6, - 0x73, 0x8c, 0x77, 0x3c, 0xe7, 0x51, 0x0b, 0x7f, 0xf0, 0x28, 0xb5, 0x90, 0x18, 0xab, 0x5d, 0x69, - 0x9d, 0x46, 0x3e, 0xfe, 0x5f, 0xf3, 0xa0, 0xdf, 0x1b, 0xee, 0x8d, 0xde, 0x64, 0xe1, 0xd1, 0x59, - 0xe3, 0x5f, 0x4b, 0xc9, 0xda, 0x47, 0x67, 0x9f, 0x6e, 0xf5, 0xc5, 0x4a, 0xef, 0x22, 0x36, 0x1b, - 0x2a, 0x83, 0x77, 0xb0, 0xbf, 0xd6, 0x16, 0xa3, 0x64, 0x6d, 0x90, 0x1e, 0xc1, 0x5e, 0xc9, 0xc5, - 0x98, 0xe3, 0x85, 0x28, 0xd1, 0xc4, 0xa4, 0xdf, 0x1b, 0x46, 0x05, 0x94, 0x5c, 0xbc, 0x0f, 0xc8, - 0xe0, 0x57, 0x17, 0x0e, 0x9a, 0x06, 0xe7, 0xb5, 0xba, 0x77, 0x76, 0xc5, 0xd9, 0x23, 0x38, 0xdc, - 0x60, 0x4c, 0xf0, 0x76, 0x74, 0x45, 0x60, 0xa7, 0x61, 0x50, 0x0e, 0x4f, 0xd6, 0xec, 0x80, 0x1e, - 0xdf, 0x8d, 0xdf, 0xfc, 0xe7, 0x26, 0xcf, 0xb6, 0xb0, 0xc2, 0xb0, 0x41, 0x87, 0x7e, 0x85, 0xa7, - 0x6b, 0xef, 0x43, 0x9f, 0xaf, 0x76, 0xd8, 0xb4, 0xc9, 0xe4, 0x64, 0x2b, 0xaf, 0x9d, 0x75, 0x7a, - 0x7a, 0x79, 0x9d, 0x92, 0xab, 0xeb, 0xb4, 0xf3, 0x7d, 0x99, 0x92, 0xcb, 0x65, 0x4a, 0x7e, 0x2f, - 0x53, 0xf2, 0x67, 0x99, 0x92, 0x1f, 0x7f, 0xd3, 0xce, 0xe7, 0xe3, 0x9b, 0xe4, 0xce, 0xdc, 0x04, - 0xe7, 0x68, 0x73, 0x35, 0xab, 0x9a, 0x14, 0x9b, 0x9c, 0x6b, 0x76, 0x9b, 0xe0, 0xc9, 0x43, 0x1f, - 0xdc, 0xd7, 0xff, 0x02, 0x00, 0x00, 0xff, 0xff, 0x10, 0x72, 0x70, 0xc7, 0x2c, 0x04, 0x00, 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// NodeClient is the client API for Node service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type NodeClient interface { - NodePrepareResource(ctx context.Context, in *NodePrepareResourceRequest, opts ...grpc.CallOption) (*NodePrepareResourceResponse, error) - NodeUnprepareResource(ctx context.Context, in *NodeUnprepareResourceRequest, opts ...grpc.CallOption) (*NodeUnprepareResourceResponse, error) -} - -type nodeClient struct { - cc *grpc.ClientConn -} - -func NewNodeClient(cc *grpc.ClientConn) NodeClient { - return &nodeClient{cc} -} - -func (c *nodeClient) NodePrepareResource(ctx context.Context, in *NodePrepareResourceRequest, opts ...grpc.CallOption) (*NodePrepareResourceResponse, error) { - out := new(NodePrepareResourceResponse) - err := c.cc.Invoke(ctx, "/v1alpha2.Node/NodePrepareResource", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *nodeClient) NodeUnprepareResource(ctx context.Context, in *NodeUnprepareResourceRequest, opts ...grpc.CallOption) (*NodeUnprepareResourceResponse, error) { - out := new(NodeUnprepareResourceResponse) - err := c.cc.Invoke(ctx, "/v1alpha2.Node/NodeUnprepareResource", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// NodeServer is the server API for Node service. -type NodeServer interface { - NodePrepareResource(context.Context, *NodePrepareResourceRequest) (*NodePrepareResourceResponse, error) - NodeUnprepareResource(context.Context, *NodeUnprepareResourceRequest) (*NodeUnprepareResourceResponse, error) -} - -// UnimplementedNodeServer can be embedded to have forward compatible implementations. -type UnimplementedNodeServer struct { -} - -func (*UnimplementedNodeServer) NodePrepareResource(ctx context.Context, req *NodePrepareResourceRequest) (*NodePrepareResourceResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method NodePrepareResource not implemented") -} -func (*UnimplementedNodeServer) NodeUnprepareResource(ctx context.Context, req *NodeUnprepareResourceRequest) (*NodeUnprepareResourceResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method NodeUnprepareResource not implemented") -} - -func RegisterNodeServer(s *grpc.Server, srv NodeServer) { - s.RegisterService(&_Node_serviceDesc, srv) -} - -func _Node_NodePrepareResource_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(NodePrepareResourceRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(NodeServer).NodePrepareResource(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/v1alpha2.Node/NodePrepareResource", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(NodeServer).NodePrepareResource(ctx, req.(*NodePrepareResourceRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Node_NodeUnprepareResource_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(NodeUnprepareResourceRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(NodeServer).NodeUnprepareResource(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/v1alpha2.Node/NodeUnprepareResource", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(NodeServer).NodeUnprepareResource(ctx, req.(*NodeUnprepareResourceRequest)) - } - return interceptor(ctx, in, info, handler) -} - -var _Node_serviceDesc = grpc.ServiceDesc{ - ServiceName: "v1alpha2.Node", - HandlerType: (*NodeServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "NodePrepareResource", - Handler: _Node_NodePrepareResource_Handler, - }, - { - MethodName: "NodeUnprepareResource", - Handler: _Node_NodeUnprepareResource_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "api.proto", -} - -func (m *NodePrepareResourceRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *NodePrepareResourceRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *NodePrepareResourceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.StructuredResourceHandle) > 0 { - for iNdEx := len(m.StructuredResourceHandle) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.StructuredResourceHandle[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintApi(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - } - } - 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) - copy(dAtA[i:], m.ClaimName) - i = encodeVarintApi(dAtA, i, uint64(len(m.ClaimName))) - i-- - dAtA[i] = 0x1a - } - if len(m.ClaimUid) > 0 { - i -= len(m.ClaimUid) - copy(dAtA[i:], m.ClaimUid) - i = encodeVarintApi(dAtA, i, uint64(len(m.ClaimUid))) - i-- - dAtA[i] = 0x12 - } - if len(m.Namespace) > 0 { - i -= len(m.Namespace) - copy(dAtA[i:], m.Namespace) - i = encodeVarintApi(dAtA, i, uint64(len(m.Namespace))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *NodePrepareResourceResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *NodePrepareResourceResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *NodePrepareResourceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = 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] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *NodeUnprepareResourceRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *NodeUnprepareResourceRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *NodeUnprepareResourceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.StructuredResourceHandle) > 0 { - for iNdEx := len(m.StructuredResourceHandle) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.StructuredResourceHandle[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintApi(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - } - } - 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) - copy(dAtA[i:], m.ClaimName) - i = encodeVarintApi(dAtA, i, uint64(len(m.ClaimName))) - i-- - dAtA[i] = 0x1a - } - if len(m.ClaimUid) > 0 { - i -= len(m.ClaimUid) - copy(dAtA[i:], m.ClaimUid) - i = encodeVarintApi(dAtA, i, uint64(len(m.ClaimUid))) - i-- - dAtA[i] = 0x12 - } - if len(m.Namespace) > 0 { - i -= len(m.Namespace) - copy(dAtA[i:], m.Namespace) - i = encodeVarintApi(dAtA, i, uint64(len(m.Namespace))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *NodeUnprepareResourceResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *NodeUnprepareResourceResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *NodeUnprepareResourceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func encodeVarintApi(dAtA []byte, offset int, v uint64) int { - offset -= sovApi(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *NodePrepareResourceRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Namespace) - if l > 0 { - n += 1 + l + sovApi(uint64(l)) - } - l = len(m.ClaimUid) - if l > 0 { - n += 1 + l + sovApi(uint64(l)) - } - l = len(m.ClaimName) - if l > 0 { - n += 1 + l + sovApi(uint64(l)) - } - l = len(m.ResourceHandle) - if l > 0 { - n += 1 + l + sovApi(uint64(l)) - } - if len(m.StructuredResourceHandle) > 0 { - for _, e := range m.StructuredResourceHandle { - l = e.Size() - n += 1 + l + sovApi(uint64(l)) - } - } - return n -} - -func (m *NodePrepareResourceResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.CdiDevices) > 0 { - for _, s := range m.CdiDevices { - l = len(s) - n += 1 + l + sovApi(uint64(l)) - } - } - return n -} - -func (m *NodeUnprepareResourceRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Namespace) - if l > 0 { - n += 1 + l + sovApi(uint64(l)) - } - l = len(m.ClaimUid) - if l > 0 { - n += 1 + l + sovApi(uint64(l)) - } - l = len(m.ClaimName) - if l > 0 { - n += 1 + l + sovApi(uint64(l)) - } - l = len(m.ResourceHandle) - if l > 0 { - n += 1 + l + sovApi(uint64(l)) - } - if len(m.StructuredResourceHandle) > 0 { - for _, e := range m.StructuredResourceHandle { - l = e.Size() - n += 1 + l + sovApi(uint64(l)) - } - } - return n -} - -func (m *NodeUnprepareResourceResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func sovApi(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozApi(x uint64) (n int) { - return sovApi(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (this *NodePrepareResourceRequest) String() string { - if this == nil { - return "nil" - } - repeatedStringForStructuredResourceHandle := "[]*StructuredResourceHandle{" - for _, f := range this.StructuredResourceHandle { - repeatedStringForStructuredResourceHandle += strings.Replace(fmt.Sprintf("%v", f), "StructuredResourceHandle", "v1alpha2.StructuredResourceHandle", 1) + "," - } - repeatedStringForStructuredResourceHandle += "}" - s := strings.Join([]string{`&NodePrepareResourceRequest{`, - `Namespace:` + fmt.Sprintf("%v", this.Namespace) + `,`, - `ClaimUid:` + fmt.Sprintf("%v", this.ClaimUid) + `,`, - `ClaimName:` + fmt.Sprintf("%v", this.ClaimName) + `,`, - `ResourceHandle:` + fmt.Sprintf("%v", this.ResourceHandle) + `,`, - `StructuredResourceHandle:` + repeatedStringForStructuredResourceHandle + `,`, - `}`, - }, "") - return s -} -func (this *NodePrepareResourceResponse) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&NodePrepareResourceResponse{`, - `CdiDevices:` + fmt.Sprintf("%v", this.CdiDevices) + `,`, - `}`, - }, "") - return s -} -func (this *NodeUnprepareResourceRequest) String() string { - if this == nil { - return "nil" - } - repeatedStringForStructuredResourceHandle := "[]*StructuredResourceHandle{" - for _, f := range this.StructuredResourceHandle { - repeatedStringForStructuredResourceHandle += strings.Replace(fmt.Sprintf("%v", f), "StructuredResourceHandle", "v1alpha2.StructuredResourceHandle", 1) + "," - } - repeatedStringForStructuredResourceHandle += "}" - s := strings.Join([]string{`&NodeUnprepareResourceRequest{`, - `Namespace:` + fmt.Sprintf("%v", this.Namespace) + `,`, - `ClaimUid:` + fmt.Sprintf("%v", this.ClaimUid) + `,`, - `ClaimName:` + fmt.Sprintf("%v", this.ClaimName) + `,`, - `ResourceHandle:` + fmt.Sprintf("%v", this.ResourceHandle) + `,`, - `StructuredResourceHandle:` + repeatedStringForStructuredResourceHandle + `,`, - `}`, - }, "") - return s -} -func (this *NodeUnprepareResourceResponse) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&NodeUnprepareResourceResponse{`, - `}`, - }, "") - return s -} -func valueToStringApi(v interface{}) string { - rv := reflect.ValueOf(v) - if rv.IsNil() { - return "nil" - } - pv := reflect.Indirect(rv).Interface() - return fmt.Sprintf("*%v", pv) -} -func (m *NodePrepareResourceRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowApi - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: NodePrepareResourceRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: NodePrepareResourceRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Namespace", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowApi - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthApi - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthApi - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Namespace = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ClaimUid", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowApi - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthApi - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthApi - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ClaimUid = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ClaimName", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowApi - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthApi - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthApi - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ClaimName = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ResourceHandle", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowApi - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthApi - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthApi - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ResourceHandle = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StructuredResourceHandle", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowApi - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthApi - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthApi - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.StructuredResourceHandle = append(m.StructuredResourceHandle, &v1alpha2.StructuredResourceHandle{}) - if err := m.StructuredResourceHandle[len(m.StructuredResourceHandle)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipApi(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthApi - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *NodePrepareResourceResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowApi - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: NodePrepareResourceResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: NodePrepareResourceResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CdiDevices", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowApi - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthApi - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthApi - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.CdiDevices = append(m.CdiDevices, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipApi(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthApi - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *NodeUnprepareResourceRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowApi - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: NodeUnprepareResourceRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: NodeUnprepareResourceRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Namespace", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowApi - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthApi - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthApi - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Namespace = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ClaimUid", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowApi - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthApi - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthApi - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ClaimUid = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ClaimName", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowApi - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthApi - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthApi - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ClaimName = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ResourceHandle", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowApi - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthApi - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthApi - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ResourceHandle = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StructuredResourceHandle", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowApi - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthApi - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthApi - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.StructuredResourceHandle = append(m.StructuredResourceHandle, &v1alpha2.StructuredResourceHandle{}) - if err := m.StructuredResourceHandle[len(m.StructuredResourceHandle)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipApi(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthApi - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *NodeUnprepareResourceResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowApi - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: NodeUnprepareResourceResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: NodeUnprepareResourceResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipApi(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthApi - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipApi(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowApi - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowApi - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowApi - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthApi - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupApi - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthApi - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthApi = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowApi = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupApi = fmt.Errorf("proto: unexpected end of group") -) diff --git a/staging/src/k8s.io/kubelet/pkg/apis/dra/v1alpha2/api.proto b/staging/src/k8s.io/kubelet/pkg/apis/dra/v1alpha2/api.proto deleted file mode 100644 index 5a722616822..00000000000 --- a/staging/src/k8s.io/kubelet/pkg/apis/dra/v1alpha2/api.proto +++ /dev/null @@ -1,92 +0,0 @@ -/* -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. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// To regenerate api.pb.go run `hack/update-codegen.sh protobindings` - -syntax = "proto3"; - -package v1alpha2; -option go_package = "k8s.io/kubelet/pkg/apis/dra/v1alpha2"; - -import "github.com/gogo/protobuf/gogoproto/gogo.proto"; -import "k8s.io/api/resource/v1alpha2/generated.proto"; - -option (gogoproto.goproto_stringer_all) = false; -option (gogoproto.stringer_all) = true; -option (gogoproto.goproto_getters_all) = true; -option (gogoproto.marshaler_all) = true; -option (gogoproto.sizer_all) = true; -option (gogoproto.unmarshaler_all) = true; -option (gogoproto.goproto_unrecognized_all) = false; - -service Node { - rpc NodePrepareResource (NodePrepareResourceRequest) - returns (NodePrepareResourceResponse) {} - - rpc NodeUnprepareResource (NodeUnprepareResourceRequest) - returns (NodeUnprepareResourceResponse) {} -} - -message NodePrepareResourceRequest { - // The ResourceClaim namespace (ResourceClaim.meta.Namespace). - // This field is REQUIRED. - string namespace = 1; - // The UID of the Resource claim (ResourceClaim.meta.UUID). - // This field is REQUIRED. - string claim_uid = 2; - // The name of the Resource claim (ResourceClaim.meta.Name) - // This field is REQUIRED. - string claim_name = 3; - // Resource handle (AllocationResult.ResourceHandles[*].Data) - // This field is REQUIRED. - string resource_handle = 4; - // Structured parameter resource handle (AllocationResult.ResourceHandles[*].StructuredData). - // This field is OPTIONAL. If present, it needs to be used - // instead of resource_handle. It will only have a single entry. - // - // Using "repeated" instead of "optional" is a workaround for https://github.com/gogo/protobuf/issues/713. - repeated k8s.io.api.resource.v1alpha2.StructuredResourceHandle structured_resource_handle = 5; -} - -message NodePrepareResourceResponse { - // These are the additional devices that kubelet must - // make available via the container runtime. A resource - // may have zero or more devices. - repeated string cdi_devices = 1; -} - -message NodeUnprepareResourceRequest { - // The ResourceClaim namespace (ResourceClaim.meta.Namespace). - // This field is REQUIRED. - string namespace = 1; - // The UID of the Resource claim (ResourceClaim.meta.UUID). - // This field is REQUIRED. - string claim_uid = 2; - // The name of the Resource claim (ResourceClaim.meta.Name) - // This field is REQUIRED. - string claim_name = 3; - // Resource handle (AllocationResult.ResourceHandles[*].Data) - // This field is REQUIRED. - string resource_handle = 4; - // Structured parameter resource handle (AllocationResult.ResourceHandles[*].StructuredData). - // This field is OPTIONAL. If present, it needs to be used - // instead of resource_handle. It will only have a single entry. - repeated k8s.io.api.resource.v1alpha2.StructuredResourceHandle structured_resource_handle = 5; -} - -message NodeUnprepareResourceResponse { - // Intentionally empty. -} diff --git a/test/e2e/dra/deploy.go b/test/e2e/dra/deploy.go index 15229198791..b07d3d00f13 100644 --- a/test/e2e/dra/deploy.go +++ b/test/e2e/dra/deploy.go @@ -55,9 +55,7 @@ import ( ) const ( - NodePrepareResourceMethod = "/v1alpha2.Node/NodePrepareResource" NodePrepareResourcesMethod = "/v1alpha3.Node/NodePrepareResources" - NodeUnprepareResourceMethod = "/v1alpha2.Node/NodeUnprepareResource" NodeUnprepareResourcesMethod = "/v1alpha3.Node/NodeUnprepareResources" NodeListAndWatchResourcesMethod = "/v1alpha3.Node/NodeListAndWatchResources" ) @@ -146,7 +144,6 @@ func NewDriver(f *framework.Framework, nodes *Nodes, configureResources func() a f: f, fail: map[MethodInstance]bool{}, callCounts: map[MethodInstance]int64{}, - NodeV1alpha2: true, NodeV1alpha3: true, } @@ -186,7 +183,7 @@ type Driver struct { claimParameterAPIKind string classParameterAPIKind string - NodeV1alpha2, NodeV1alpha3 bool + NodeV1alpha3 bool mutex sync.Mutex fail map[MethodInstance]bool @@ -339,7 +336,6 @@ func (d *Driver) SetUp(nodes *Nodes, resources app.Resources) { kubeletplugin.PluginListener(listen(ctx, d.f, pod.Name, "plugin", 9001)), kubeletplugin.RegistrarListener(listen(ctx, d.f, pod.Name, "registrar", 9000)), kubeletplugin.KubeletPluginSocketPath(draAddr), - kubeletplugin.NodeV1alpha2(d.NodeV1alpha2), kubeletplugin.NodeV1alpha3(d.NodeV1alpha3), ) framework.ExpectNoError(err, "start kubelet plugin for node %s", pod.Spec.NodeName) diff --git a/test/e2e/dra/dra.go b/test/e2e/dra/dra.go index 2c3ed5a8654..b8a4cecc7ab 100644 --- a/test/e2e/dra/dra.go +++ b/test/e2e/dra/dra.go @@ -1114,16 +1114,14 @@ var _ = framework.SIGDescribe("node")("DRA", feature.DynamicResourceAllocation, }) }) - multipleDrivers := func(nodeV1alpha2, nodeV1alpha3 bool) { + multipleDrivers := func(nodeV1alpha3 bool) { nodes := NewNodes(f, 1, 4) driver1 := NewDriver(f, nodes, perNode(2, nodes)) - driver1.NodeV1alpha2 = nodeV1alpha2 driver1.NodeV1alpha3 = nodeV1alpha3 b1 := newBuilder(f, driver1) driver2 := NewDriver(f, nodes, perNode(2, nodes)) driver2.NameSuffix = "-other" - driver2.NodeV1alpha2 = nodeV1alpha2 driver2.NodeV1alpha3 = nodeV1alpha3 b2 := newBuilder(f, driver2) @@ -1150,16 +1148,14 @@ var _ = framework.SIGDescribe("node")("DRA", feature.DynamicResourceAllocation, b1.testPod(ctx, f.ClientSet, pod) }) } - multipleDriversContext := func(prefix string, nodeV1alpha2, nodeV1alpha3 bool) { + multipleDriversContext := func(prefix string, nodeV1alpha3 bool) { ginkgo.Context(prefix, func() { - multipleDrivers(nodeV1alpha2, nodeV1alpha3) + multipleDrivers(nodeV1alpha3) }) } ginkgo.Context("multiple drivers", func() { - multipleDriversContext("using only drapbv1alpha2", true, false) - multipleDriversContext("using only drapbv1alpha3", false, true) - multipleDriversContext("using both drapbv1alpha2 and drapbv1alpha3", true, true) + multipleDriversContext("using only drapbv1alpha3", true) }) }) diff --git a/test/e2e/dra/test-driver/app/kubeletplugin.go b/test/e2e/dra/test-driver/app/kubeletplugin.go index b77742457c0..ac1f2bfa69f 100644 --- a/test/e2e/dra/test-driver/app/kubeletplugin.go +++ b/test/e2e/dra/test-driver/app/kubeletplugin.go @@ -35,7 +35,6 @@ import ( "k8s.io/apimachinery/pkg/util/sets" "k8s.io/dynamic-resource-allocation/kubeletplugin" "k8s.io/klog/v2" - drapbv1alpha2 "k8s.io/kubelet/pkg/apis/dra/v1alpha2" drapbv1alpha3 "k8s.io/kubelet/pkg/apis/dra/v1alpha3" ) @@ -80,7 +79,6 @@ type ClaimID struct { UID string } -var _ drapbv1alpha2.NodeServer = &ExamplePlugin{} var _ drapbv1alpha3.NodeServer = &ExamplePlugin{} // getJSONFilePath returns the absolute path where CDI file is/should be. @@ -174,7 +172,7 @@ func (ex *ExamplePlugin) Block() { // a deterministic name to simplify NodeUnprepareResource (no need to remember // or discover the name) and idempotency (when called again, the file simply // gets written again). -func (ex *ExamplePlugin) NodePrepareResource(ctx context.Context, req *drapbv1alpha2.NodePrepareResourceRequest) (*drapbv1alpha2.NodePrepareResourceResponse, error) { +func (ex *ExamplePlugin) nodePrepareResource(ctx context.Context, claimName string, claimUID string, resourceHandle string, structuredResourceHandle []*resourceapi.StructuredResourceHandle) ([]string, error) { logger := klog.FromContext(ctx) // Block to emulate plugin stuckness or slowness. @@ -187,32 +185,30 @@ func (ex *ExamplePlugin) NodePrepareResource(ctx context.Context, req *drapbv1al ex.mutex.Lock() defer ex.mutex.Unlock() - deviceName := "claim-" + req.ClaimUid + deviceName := "claim-" + claimUID vendor := ex.driverName class := "test" dev := vendor + "/" + class + "=" + deviceName - resp := &drapbv1alpha2.NodePrepareResourceResponse{CdiDevices: []string{dev}} - - claimID := ClaimID{Name: req.ClaimName, UID: req.ClaimUid} + claimID := ClaimID{Name: claimName, UID: claimUID} if _, ok := ex.prepared[claimID]; ok { // Idempotent call, nothing to do. - return resp, nil + return []string{dev}, nil } // Determine environment variables. var p parameters - var resourceHandle any + var actualResourceHandle any var instanceNames []string - switch len(req.StructuredResourceHandle) { + switch len(structuredResourceHandle) { case 0: // Control plane controller did the allocation. - if err := json.Unmarshal([]byte(req.ResourceHandle), &p); err != nil { + if err := json.Unmarshal([]byte(resourceHandle), &p); err != nil { return nil, fmt.Errorf("unmarshal resource handle: %w", err) } - resourceHandle = req.ResourceHandle + actualResourceHandle = resourceHandle case 1: // Scheduler did the allocation with structured parameters. - handle := req.StructuredResourceHandle[0] + handle := structuredResourceHandle[0] if handle == nil { return nil, errors.New("unexpected nil StructuredResourceHandle") } @@ -243,10 +239,10 @@ func (ex *ExamplePlugin) NodePrepareResource(ctx context.Context, req *drapbv1al } instanceNames = append(instanceNames, instanceName) } - resourceHandle = handle + actualResourceHandle = handle default: // Huh? - return nil, fmt.Errorf("invalid length of NodePrepareResourceRequest.StructuredResourceHandle: %d", len(req.StructuredResourceHandle)) + return nil, fmt.Errorf("invalid length of NodePrepareResourceRequest.StructuredResourceHandle: %d", len(structuredResourceHandle)) } // Sanity check scheduling. @@ -274,7 +270,7 @@ func (ex *ExamplePlugin) NodePrepareResource(ctx context.Context, req *drapbv1al }, }, } - filePath := ex.getJSONFilePath(req.ClaimUid) + filePath := ex.getJSONFilePath(claimUID) buffer, err := json.Marshal(spec) if err != nil { return nil, fmt.Errorf("marshal spec: %w", err) @@ -283,13 +279,13 @@ func (ex *ExamplePlugin) NodePrepareResource(ctx context.Context, req *drapbv1al return nil, fmt.Errorf("failed to write CDI file %v", err) } - ex.prepared[claimID] = resourceHandle + ex.prepared[claimID] = actualResourceHandle for _, instanceName := range instanceNames { ex.instancesInUse.Insert(instanceName) } logger.V(3).Info("CDI file created", "path", filePath, "device", dev) - return resp, nil + return []string{dev}, nil } func extractParameters(parameters runtime.RawExtension, env *map[string]string, kind string) error { @@ -314,20 +310,14 @@ func (ex *ExamplePlugin) NodePrepareResources(ctx context.Context, req *drapbv1a Claims: make(map[string]*drapbv1alpha3.NodePrepareResourceResponse), } for _, claimReq := range req.Claims { - claimResp, err := ex.NodePrepareResource(ctx, &drapbv1alpha2.NodePrepareResourceRequest{ - Namespace: claimReq.Namespace, - ClaimName: claimReq.Name, - ClaimUid: claimReq.Uid, - ResourceHandle: claimReq.ResourceHandle, - StructuredResourceHandle: claimReq.StructuredResourceHandle, - }) + cdiDevices, err := ex.nodePrepareResource(ctx, claimReq.Name, claimReq.Uid, claimReq.ResourceHandle, claimReq.StructuredResourceHandle) if err != nil { resp.Claims[claimReq.Uid] = &drapbv1alpha3.NodePrepareResourceResponse{ Error: err.Error(), } } else { resp.Claims[claimReq.Uid] = &drapbv1alpha3.NodePrepareResourceResponse{ - CDIDevices: claimResp.CdiDevices, + CDIDevices: cdiDevices, } } } @@ -337,45 +327,44 @@ func (ex *ExamplePlugin) NodePrepareResources(ctx context.Context, req *drapbv1a // NodeUnprepareResource removes the CDI file created by // NodePrepareResource. It's idempotent, therefore it is not an error when that // file is already gone. -func (ex *ExamplePlugin) NodeUnprepareResource(ctx context.Context, req *drapbv1alpha2.NodeUnprepareResourceRequest) (*drapbv1alpha2.NodeUnprepareResourceResponse, error) { +func (ex *ExamplePlugin) nodeUnprepareResource(ctx context.Context, claimName string, claimUID string, resourceHandle string, structuredResourceHandle []*resourceapi.StructuredResourceHandle) error { logger := klog.FromContext(ctx) // Block to emulate plugin stuckness or slowness. // By default the call will not be blocked as ex.block = false. if ex.block { <-ctx.Done() - return nil, ctx.Err() + return ctx.Err() } - filePath := ex.getJSONFilePath(req.ClaimUid) + filePath := ex.getJSONFilePath(claimUID) if err := ex.fileOps.Remove(filePath); err != nil { - return nil, fmt.Errorf("error removing CDI file: %w", err) + return fmt.Errorf("error removing CDI file: %w", err) } logger.V(3).Info("CDI file removed", "path", filePath) ex.mutex.Lock() defer ex.mutex.Unlock() - claimID := ClaimID{Name: req.ClaimName, UID: req.ClaimUid} - resp := &drapbv1alpha2.NodeUnprepareResourceResponse{} + claimID := ClaimID{Name: claimName, UID: claimUID} expectedResourceHandle, ok := ex.prepared[claimID] if !ok { // Idempotent call, nothing to do. - return resp, nil + return nil } - var actualResourceHandle any = req.ResourceHandle - if req.StructuredResourceHandle != nil { - if len(req.StructuredResourceHandle) != 1 { - return nil, fmt.Errorf("unexpected number of entries in StructuredResourceHandle: %d", len(req.StructuredResourceHandle)) + var actualResourceHandle any = resourceHandle + if structuredResourceHandle != nil { + if len(structuredResourceHandle) != 1 { + return fmt.Errorf("unexpected number of entries in StructuredResourceHandle: %d", len(structuredResourceHandle)) } - actualResourceHandle = req.StructuredResourceHandle[0] + actualResourceHandle = structuredResourceHandle[0] } if diff := cmp.Diff(expectedResourceHandle, actualResourceHandle); diff != "" { - return nil, fmt.Errorf("difference between expected (-) and actual resource handle (+):\n%s", diff) + return fmt.Errorf("difference between expected (-) and actual resource handle (+):\n%s", diff) } delete(ex.prepared, claimID) - if structuredResourceHandle := req.StructuredResourceHandle; structuredResourceHandle != nil { + if structuredResourceHandle := structuredResourceHandle; structuredResourceHandle != nil { for _, handle := range structuredResourceHandle { for _, result := range handle.Results { instanceName := result.NamedResources.Name @@ -383,8 +372,9 @@ func (ex *ExamplePlugin) NodeUnprepareResource(ctx context.Context, req *drapbv1 } } } + delete(ex.prepared, ClaimID{Name: claimName, UID: claimUID}) - return &drapbv1alpha2.NodeUnprepareResourceResponse{}, nil + return nil } func (ex *ExamplePlugin) NodeUnprepareResources(ctx context.Context, req *drapbv1alpha3.NodeUnprepareResourcesRequest) (*drapbv1alpha3.NodeUnprepareResourcesResponse, error) { @@ -392,13 +382,7 @@ func (ex *ExamplePlugin) NodeUnprepareResources(ctx context.Context, req *drapbv Claims: make(map[string]*drapbv1alpha3.NodeUnprepareResourceResponse), } for _, claimReq := range req.Claims { - _, err := ex.NodeUnprepareResource(ctx, &drapbv1alpha2.NodeUnprepareResourceRequest{ - Namespace: claimReq.Namespace, - ClaimName: claimReq.Name, - ClaimUid: claimReq.Uid, - ResourceHandle: claimReq.ResourceHandle, - StructuredResourceHandle: claimReq.StructuredResourceHandle, - }) + err := ex.nodeUnprepareResource(ctx, claimReq.Name, claimReq.Uid, claimReq.ResourceHandle, claimReq.StructuredResourceHandle) if err != nil { resp.Claims[claimReq.Uid] = &drapbv1alpha3.NodeUnprepareResourceResponse{ Error: err.Error(),