DRA kubelet: add v1beta1 gRPC API
The v1beta1 API is identical to the previous v1alpha4, which erroneously was still called "v1alpha3" in a few places, including the gRPC interface definition itself. The only reason for v1beta1 is to document the increased maturity of this API. To simplify the transition, kubelet supports both v1alpha4 and v1beta1, picking the more recent one automatically. All that DRA driver authors need to do to implement v1beta1 is to update to the latest k8s.io/dynamic-resource-allocation/kubeletplugin: it will automatically register both API versions unless explicitly configured otherwise, which is mostly just for testing. DRA driver authors may replace their package import of v1alpha4 with v1beta1, but they don't have to because the types in both packages are the same. Kubernetes-commit: 7b3a9afca35cf60f4a5bc1d9cca5e25ff414d39d
This commit is contained in:
parent
d45cec2ba6
commit
cc48d93402
|
|
@ -0,0 +1,193 @@
|
|||
/*
|
||||
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 v1beta1
|
||||
|
||||
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"
|
||||
v1alpha4 "k8s.io/kubelet/pkg/apis/dra/v1alpha4"
|
||||
math "math"
|
||||
)
|
||||
|
||||
// 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
|
||||
|
||||
func init() { proto.RegisterFile("api.proto", fileDescriptor_00212fb1f9d3bf1c) }
|
||||
|
||||
var fileDescriptor_00212fb1f9d3bf1c = []byte{
|
||||
// 243 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x4c, 0x2c, 0xc8, 0xd4,
|
||||
0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0x94, 0xd2,
|
||||
0x4d, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xcf, 0x4f, 0xcf, 0xd7,
|
||||
0x07, 0xcb, 0x27, 0x95, 0xa6, 0x81, 0x79, 0x60, 0x0e, 0x98, 0x05, 0xd1, 0x27, 0xa5, 0x97, 0x6d,
|
||||
0x51, 0xac, 0x97, 0x99, 0xaf, 0x9f, 0x5d, 0x9a, 0x94, 0x9a, 0x93, 0x5a, 0xa2, 0x5f, 0x90, 0x9d,
|
||||
0xae, 0x9f, 0x58, 0x90, 0x59, 0xac, 0x9f, 0x52, 0x94, 0xa8, 0x5f, 0x66, 0x98, 0x98, 0x53, 0x90,
|
||||
0x91, 0x68, 0xa2, 0x0f, 0xb7, 0xc7, 0xe8, 0x1e, 0x23, 0x17, 0x8b, 0x5f, 0x7e, 0x4a, 0xaa, 0x50,
|
||||
0x3a, 0x97, 0x08, 0x88, 0x0e, 0x28, 0x4a, 0x2d, 0x48, 0x2c, 0x4a, 0x0d, 0x4a, 0x2d, 0xce, 0x2f,
|
||||
0x2d, 0x4a, 0x4e, 0x2d, 0x16, 0x52, 0xd5, 0x83, 0xea, 0x32, 0xd6, 0xc3, 0x26, 0x1f, 0x94, 0x5a,
|
||||
0x58, 0x9a, 0x5a, 0x5c, 0x22, 0xa5, 0x46, 0x48, 0x59, 0x71, 0x41, 0x7e, 0x5e, 0x71, 0xaa, 0x12,
|
||||
0x83, 0x50, 0x2e, 0x97, 0x18, 0x48, 0x45, 0x68, 0x5e, 0x01, 0xba, 0x55, 0xea, 0xa8, 0x66, 0x60,
|
||||
0xaa, 0x80, 0x59, 0xa6, 0x41, 0x58, 0x21, 0xcc, 0x3a, 0x27, 0xc7, 0x13, 0x0f, 0xe5, 0x18, 0x6f,
|
||||
0x3c, 0x94, 0x63, 0x68, 0x78, 0x24, 0xc7, 0x78, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c,
|
||||
0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x10, 0xa5, 0x8c, 0x3f, 0xb8, 0xc0, 0x51, 0x90,
|
||||
0xc4, 0x06, 0x0e, 0x2a, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x20, 0x45, 0x28, 0xd3, 0x9f,
|
||||
0x01, 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 {
|
||||
// NodePrepareResources prepares several ResourceClaims
|
||||
// for use on the node. If an error is returned, the
|
||||
// response is ignored. Failures for individual claims
|
||||
// can be reported inside NodePrepareResourcesResponse.
|
||||
NodePrepareResources(ctx context.Context, in *v1alpha4.NodePrepareResourcesRequest, opts ...grpc.CallOption) (*v1alpha4.NodePrepareResourcesResponse, error)
|
||||
// NodeUnprepareResources is the opposite of NodePrepareResources.
|
||||
// The same error handling rules apply,
|
||||
NodeUnprepareResources(ctx context.Context, in *v1alpha4.NodeUnprepareResourcesRequest, opts ...grpc.CallOption) (*v1alpha4.NodeUnprepareResourcesResponse, error)
|
||||
}
|
||||
|
||||
type nodeClient struct {
|
||||
cc *grpc.ClientConn
|
||||
}
|
||||
|
||||
func NewNodeClient(cc *grpc.ClientConn) NodeClient {
|
||||
return &nodeClient{cc}
|
||||
}
|
||||
|
||||
func (c *nodeClient) NodePrepareResources(ctx context.Context, in *v1alpha4.NodePrepareResourcesRequest, opts ...grpc.CallOption) (*v1alpha4.NodePrepareResourcesResponse, error) {
|
||||
out := new(v1alpha4.NodePrepareResourcesResponse)
|
||||
err := c.cc.Invoke(ctx, "/v1beta1.Node/NodePrepareResources", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *nodeClient) NodeUnprepareResources(ctx context.Context, in *v1alpha4.NodeUnprepareResourcesRequest, opts ...grpc.CallOption) (*v1alpha4.NodeUnprepareResourcesResponse, error) {
|
||||
out := new(v1alpha4.NodeUnprepareResourcesResponse)
|
||||
err := c.cc.Invoke(ctx, "/v1beta1.Node/NodeUnprepareResources", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// NodeServer is the server API for Node service.
|
||||
type NodeServer interface {
|
||||
// NodePrepareResources prepares several ResourceClaims
|
||||
// for use on the node. If an error is returned, the
|
||||
// response is ignored. Failures for individual claims
|
||||
// can be reported inside NodePrepareResourcesResponse.
|
||||
NodePrepareResources(context.Context, *v1alpha4.NodePrepareResourcesRequest) (*v1alpha4.NodePrepareResourcesResponse, error)
|
||||
// NodeUnprepareResources is the opposite of NodePrepareResources.
|
||||
// The same error handling rules apply,
|
||||
NodeUnprepareResources(context.Context, *v1alpha4.NodeUnprepareResourcesRequest) (*v1alpha4.NodeUnprepareResourcesResponse, error)
|
||||
}
|
||||
|
||||
// UnimplementedNodeServer can be embedded to have forward compatible implementations.
|
||||
type UnimplementedNodeServer struct {
|
||||
}
|
||||
|
||||
func (*UnimplementedNodeServer) NodePrepareResources(ctx context.Context, req *v1alpha4.NodePrepareResourcesRequest) (*v1alpha4.NodePrepareResourcesResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method NodePrepareResources not implemented")
|
||||
}
|
||||
func (*UnimplementedNodeServer) NodeUnprepareResources(ctx context.Context, req *v1alpha4.NodeUnprepareResourcesRequest) (*v1alpha4.NodeUnprepareResourcesResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method NodeUnprepareResources not implemented")
|
||||
}
|
||||
|
||||
func RegisterNodeServer(s *grpc.Server, srv NodeServer) {
|
||||
s.RegisterService(&_Node_serviceDesc, srv)
|
||||
}
|
||||
|
||||
func _Node_NodePrepareResources_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(v1alpha4.NodePrepareResourcesRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(NodeServer).NodePrepareResources(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/v1beta1.Node/NodePrepareResources",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(NodeServer).NodePrepareResources(ctx, req.(*v1alpha4.NodePrepareResourcesRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Node_NodeUnprepareResources_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(v1alpha4.NodeUnprepareResourcesRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(NodeServer).NodeUnprepareResources(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/v1beta1.Node/NodeUnprepareResources",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(NodeServer).NodeUnprepareResources(ctx, req.(*v1alpha4.NodeUnprepareResourcesRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
var _Node_serviceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "v1beta1.Node",
|
||||
HandlerType: (*NodeServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "NodePrepareResources",
|
||||
Handler: _Node_NodePrepareResources_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "NodeUnprepareResources",
|
||||
Handler: _Node_NodeUnprepareResources_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "api.proto",
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
Copyright 2024 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 v1beta1;
|
||||
option go_package = "k8s.io/kubelet/pkg/apis/dra/v1beta1";
|
||||
|
||||
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
|
||||
import "k8s.io/kubelet/pkg/apis/dra/v1alpha4/api.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;
|
||||
|
||||
// The v1beta1 Node service has the exact same methods as the previous alpha,
|
||||
// so gRPC serves can provide both services with the same implementation.
|
||||
service Node {
|
||||
// NodePrepareResources prepares several ResourceClaims
|
||||
// for use on the node. If an error is returned, the
|
||||
// response is ignored. Failures for individual claims
|
||||
// can be reported inside NodePrepareResourcesResponse.
|
||||
rpc NodePrepareResources (v1alpha3.NodePrepareResourcesRequest)
|
||||
returns (v1alpha3.NodePrepareResourcesResponse) {}
|
||||
|
||||
// NodeUnprepareResources is the opposite of NodePrepareResources.
|
||||
// The same error handling rules apply,
|
||||
rpc NodeUnprepareResources (v1alpha3.NodeUnprepareResourcesRequest)
|
||||
returns (v1alpha3.NodeUnprepareResourcesResponse) {}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
Copyright 2024 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.
|
||||
*/
|
||||
|
||||
// Package v1beta1 has the same Go API as v1alpha4. A DRA driver implementing
|
||||
// [v1beta1.NodeServer] also implements [v1alpha4.NodeServer] and vice versa.
|
||||
//
|
||||
// The k8s.io/dynamic-resource-allocation/kubeletplugin helper will
|
||||
// automatically register both API versions unless explicitly configured
|
||||
// otherwise.
|
||||
package v1beta1
|
||||
|
||||
import (
|
||||
"k8s.io/kubelet/pkg/apis/dra/v1alpha4"
|
||||
)
|
||||
|
||||
type (
|
||||
NodePrepareResourcesRequest = v1alpha4.NodePrepareResourcesRequest
|
||||
NodePrepareResourcesResponse = v1alpha4.NodePrepareResourcesResponse
|
||||
NodePrepareResourceResponse = v1alpha4.NodePrepareResourceResponse
|
||||
NodeUnprepareResourcesRequest = v1alpha4.NodeUnprepareResourcesRequest
|
||||
NodeUnprepareResourcesResponse = v1alpha4.NodeUnprepareResourcesResponse
|
||||
NodeUnprepareResourceResponse = v1alpha4.NodeUnprepareResourceResponse
|
||||
Device = v1alpha4.Device
|
||||
Claim = v1alpha4.Claim
|
||||
)
|
||||
|
||||
var _ NodeServer = v1alpha4.NodeServer(nil)
|
||||
Loading…
Reference in New Issue