Skip to content

Commit 437be1e

Browse files
committed
DRA kubelet: rename gRPC server from Node to DRAPlugin in v1beta1
The version bump is an opportunity to pick a name that is a bit more descriptive. It matches the "DevicePlugin" service name.
1 parent 63a7865 commit 437be1e

File tree

9 files changed

+63
-61
lines changed

9 files changed

+63
-61
lines changed

pkg/kubelet/cm/dra/manager_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const (
5252
)
5353

5454
type fakeDRADriverGRPCServer struct {
55-
drapb.UnimplementedNodeServer
55+
drapb.UnimplementedDRAPluginServer
5656
driverName string
5757
timeout *time.Duration
5858
prepareResourceCalls atomic.Uint32
@@ -161,7 +161,7 @@ func setupFakeDRADriverGRPCServer(ctx context.Context, shouldTimeout bool, plugi
161161
fakeDRADriverGRPCServer.timeout = &timeout
162162
}
163163

164-
drapb.RegisterNodeServer(s, fakeDRADriverGRPCServer)
164+
drapb.RegisterDRAPluginServer(s, fakeDRADriverGRPCServer)
165165

166166
go func(ctx context.Context) {
167167
go func() {

pkg/kubelet/cm/dra/plugin/plugin.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,15 +134,15 @@ func (p *Plugin) NodePrepareResources(
134134
var response *drapbv1beta1.NodePrepareResourcesResponse
135135
switch supportedAPI {
136136
case apiV1beta1:
137-
nodeClient := drapbv1beta1.NewNodeClient(conn)
137+
nodeClient := drapbv1beta1.NewDRAPluginClient(conn)
138138
response, err = nodeClient.NodePrepareResources(ctx, req)
139139
case apiV1alpha4:
140140
nodeClient := drapbv1alpha4.NewNodeClient(conn)
141141
response, err = nodeClient.NodePrepareResources(ctx, req)
142142
default:
143143
// Try it, fall back if necessary.
144144
supportedAPI = apiV1beta1
145-
nodeClient := drapbv1beta1.NewNodeClient(conn)
145+
nodeClient := drapbv1beta1.NewDRAPluginClient(conn)
146146
response, err = nodeClient.NodePrepareResources(ctx, req)
147147
if err != nil && status.Convert(err).Code() == codes.Unimplemented {
148148
supportedAPI = apiV1alpha4
@@ -179,15 +179,15 @@ func (p *Plugin) NodeUnprepareResources(
179179
var response *drapbv1beta1.NodeUnprepareResourcesResponse
180180
switch supportedAPI {
181181
case apiV1beta1:
182-
nodeClient := drapbv1beta1.NewNodeClient(conn)
182+
nodeClient := drapbv1beta1.NewDRAPluginClient(conn)
183183
response, err = nodeClient.NodeUnprepareResources(ctx, req)
184184
case apiV1alpha4:
185185
nodeClient := drapbv1alpha4.NewNodeClient(conn)
186186
response, err = nodeClient.NodeUnprepareResources(ctx, req)
187187
default:
188188
// Try it, fall back if necessary.
189189
supportedAPI = apiV1beta1
190-
nodeClient := drapbv1beta1.NewNodeClient(conn)
190+
nodeClient := drapbv1beta1.NewDRAPluginClient(conn)
191191
response, err = nodeClient.NodeUnprepareResources(ctx, req)
192192
if err != nil && status.Convert(err).Code() == codes.Unimplemented {
193193
supportedAPI = apiV1alpha4

pkg/kubelet/cm/dra/plugin/plugin_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ const (
3636
)
3737

3838
type fakeV1alpha4GRPCServer struct {
39-
drapb.UnimplementedNodeServer
39+
drapb.UnimplementedDRAPluginServer
4040
}
4141

42-
var _ drapb.NodeServer = &fakeV1alpha4GRPCServer{}
42+
var _ drapb.DRAPluginServer = &fakeV1alpha4GRPCServer{}
4343

4444
func (f *fakeV1alpha4GRPCServer) NodePrepareResources(ctx context.Context, in *drapb.NodePrepareResourcesRequest) (*drapb.NodePrepareResourcesResponse, error) {
4545
return &drapb.NodePrepareResourcesResponse{Claims: map[string]*drapb.NodePrepareResourceResponse{"claim-uid": {
@@ -84,7 +84,7 @@ func setupFakeGRPCServer(version string) (string, tearDown, error) {
8484
switch version {
8585
case v1alpha4Version:
8686
fakeGRPCServer := &fakeV1alpha4GRPCServer{}
87-
drapb.RegisterNodeServer(s, fakeGRPCServer)
87+
drapb.RegisterDRAPluginServer(s, fakeGRPCServer)
8888
default:
8989
return "", nil, fmt.Errorf("unsupported version: %s", version)
9090
}

staging/src/k8s.io/dynamic-resource-allocation/kubeletplugin/draplugin.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -333,13 +333,13 @@ func Start(ctx context.Context, nodeServer interface{}, opts ...Option) (result
333333
implemented := false
334334
plugin, err := startGRPCServer(klog.NewContext(ctx, klog.LoggerWithName(logger, "dra")), o.grpcVerbosity, o.unaryInterceptors, o.streamInterceptors, o.draEndpoint, func(grpcServer *grpc.Server) {
335335
if nodeServer, ok := nodeServer.(drapbv1alpha4.NodeServer); ok && o.nodeV1alpha4 {
336-
logger.V(5).Info("registering drapbv1alpha4.NodeServer")
336+
logger.V(5).Info("registering v1alpha4.Node gGRPC service")
337337
drapbv1alpha4.RegisterNodeServer(grpcServer, nodeServer)
338338
implemented = true
339339
}
340-
if nodeServer, ok := nodeServer.(drapbv1beta1.NodeServer); ok && o.nodeV1beta1 {
341-
logger.V(5).Info("registering drapbv1beta1.NodeServer")
342-
drapbv1beta1.RegisterNodeServer(grpcServer, nodeServer)
340+
if nodeServer, ok := nodeServer.(drapbv1beta1.DRAPluginServer); ok && o.nodeV1beta1 {
341+
logger.V(5).Info("registering v1beta1.DRAPlugin gRPC service")
342+
drapbv1beta1.RegisterDRAPluginServer(grpcServer, nodeServer)
343343
implemented = true
344344
}
345345
})

staging/src/k8s.io/kubelet/pkg/apis/dra/v1beta1/api.pb.go

Lines changed: 41 additions & 41 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

staging/src/k8s.io/kubelet/pkg/apis/dra/v1beta1/api.proto

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@ option (gogoproto.sizer_all) = true;
3232
option (gogoproto.unmarshaler_all) = true;
3333
option (gogoproto.goproto_unrecognized_all) = false;
3434

35-
// The v1beta1 Node service has the exact same methods as the previous alpha,
36-
// so gRPC serves can provide both services with the same implementation.
37-
service Node {
35+
// The v1beta1 DRAPlugin service has the exact same methods as the Node
36+
// service in the previous alpha, so gRPC serves can provide both
37+
// services with the same implementation.
38+
service DRAPlugin {
3839
// NodePrepareResources prepares several ResourceClaims
3940
// for use on the node. If an error is returned, the
4041
// response is ignored. Failures for individual claims

staging/src/k8s.io/kubelet/pkg/apis/dra/v1beta1/types.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,5 @@ type (
3737
Claim = v1alpha4.Claim
3838
)
3939

40-
var _ NodeServer = v1alpha4.NodeServer(nil)
40+
// Ensure that the interfaces are equivalent.
41+
var _ DRAPluginServer = v1alpha4.NodeServer(nil)

test/e2e/dra/deploy.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ import (
6565
)
6666

6767
const (
68-
NodePrepareResourcesMethod = "/v1beta1.Node/NodePrepareResources"
69-
NodeUnprepareResourcesMethod = "/v1beta1.Node/NodeUnprepareResources"
68+
NodePrepareResourcesMethod = "/v1beta1.DRAPlugin/NodePrepareResources"
69+
NodeUnprepareResourcesMethod = "/v1beta1.DRAPlugin/NodeUnprepareResources"
7070
)
7171

7272
type Nodes struct {

test/e2e/dra/test-driver/app/kubeletplugin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ type Device struct {
9797
CDIDeviceID string
9898
}
9999

100-
var _ drapb.NodeServer = &ExamplePlugin{}
100+
var _ drapb.DRAPluginServer = &ExamplePlugin{}
101101

102102
// getJSONFilePath returns the absolute path where CDI file is/should be.
103103
func (ex *ExamplePlugin) getJSONFilePath(claimUID string, requestName string) string {

0 commit comments

Comments
 (0)