mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 23:15:14 +00:00
dra kubelet: bump gRPC API to v1alpha4
The previous changes are an API break, therefore we need a new version.
This commit is contained in:
parent
ee3205804b
commit
7701a48bd6
@ -30,7 +30,7 @@ import (
|
||||
clientset "k8s.io/client-go/kubernetes"
|
||||
"k8s.io/dynamic-resource-allocation/resourceclaim"
|
||||
"k8s.io/klog/v2"
|
||||
drapb "k8s.io/kubelet/pkg/apis/dra/v1alpha3"
|
||||
drapb "k8s.io/kubelet/pkg/apis/dra/v1alpha4"
|
||||
dra "k8s.io/kubernetes/pkg/kubelet/cm/dra/plugin"
|
||||
"k8s.io/kubernetes/pkg/kubelet/config"
|
||||
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
|
||||
|
@ -36,7 +36,7 @@ import (
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
"k8s.io/client-go/kubernetes/fake"
|
||||
"k8s.io/dynamic-resource-allocation/resourceclaim"
|
||||
drapbv1 "k8s.io/kubelet/pkg/apis/dra/v1alpha3"
|
||||
drapb "k8s.io/kubelet/pkg/apis/dra/v1alpha4"
|
||||
"k8s.io/kubernetes/pkg/kubelet/cm/dra/plugin"
|
||||
"k8s.io/kubernetes/pkg/kubelet/cm/dra/state"
|
||||
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
|
||||
@ -48,16 +48,16 @@ const (
|
||||
)
|
||||
|
||||
type fakeDRADriverGRPCServer struct {
|
||||
drapbv1.UnimplementedNodeServer
|
||||
drapb.UnimplementedNodeServer
|
||||
driverName string
|
||||
timeout *time.Duration
|
||||
prepareResourceCalls atomic.Uint32
|
||||
unprepareResourceCalls atomic.Uint32
|
||||
prepareResourcesResponse *drapbv1.NodePrepareResourcesResponse
|
||||
unprepareResourcesResponse *drapbv1.NodeUnprepareResourcesResponse
|
||||
prepareResourcesResponse *drapb.NodePrepareResourcesResponse
|
||||
unprepareResourcesResponse *drapb.NodeUnprepareResourcesResponse
|
||||
}
|
||||
|
||||
func (s *fakeDRADriverGRPCServer) NodePrepareResources(ctx context.Context, req *drapbv1.NodePrepareResourcesRequest) (*drapbv1.NodePrepareResourcesResponse, error) {
|
||||
func (s *fakeDRADriverGRPCServer) NodePrepareResources(ctx context.Context, req *drapb.NodePrepareResourcesRequest) (*drapb.NodePrepareResourcesResponse, error) {
|
||||
s.prepareResourceCalls.Add(1)
|
||||
|
||||
if s.timeout != nil {
|
||||
@ -67,8 +67,8 @@ func (s *fakeDRADriverGRPCServer) NodePrepareResources(ctx context.Context, req
|
||||
if s.prepareResourcesResponse == nil {
|
||||
deviceName := "claim-" + req.Claims[0].Uid
|
||||
result := s.driverName + "/" + driverClassName + "=" + deviceName
|
||||
return &drapbv1.NodePrepareResourcesResponse{
|
||||
Claims: map[string]*drapbv1.NodePrepareResourceResponse{
|
||||
return &drapb.NodePrepareResourcesResponse{
|
||||
Claims: map[string]*drapb.NodePrepareResourceResponse{
|
||||
req.Claims[0].Uid: {
|
||||
CDIDevices: []string{result},
|
||||
},
|
||||
@ -79,7 +79,7 @@ func (s *fakeDRADriverGRPCServer) NodePrepareResources(ctx context.Context, req
|
||||
return s.prepareResourcesResponse, nil
|
||||
}
|
||||
|
||||
func (s *fakeDRADriverGRPCServer) NodeUnprepareResources(ctx context.Context, req *drapbv1.NodeUnprepareResourcesRequest) (*drapbv1.NodeUnprepareResourcesResponse, error) {
|
||||
func (s *fakeDRADriverGRPCServer) NodeUnprepareResources(ctx context.Context, req *drapb.NodeUnprepareResourcesRequest) (*drapb.NodeUnprepareResourcesResponse, error) {
|
||||
s.unprepareResourceCalls.Add(1)
|
||||
|
||||
if s.timeout != nil {
|
||||
@ -87,8 +87,8 @@ func (s *fakeDRADriverGRPCServer) NodeUnprepareResources(ctx context.Context, re
|
||||
}
|
||||
|
||||
if s.unprepareResourcesResponse == nil {
|
||||
return &drapbv1.NodeUnprepareResourcesResponse{
|
||||
Claims: map[string]*drapbv1.NodeUnprepareResourceResponse{
|
||||
return &drapb.NodeUnprepareResourcesResponse{
|
||||
Claims: map[string]*drapb.NodeUnprepareResourceResponse{
|
||||
req.Claims[0].Uid: {},
|
||||
},
|
||||
}, nil
|
||||
@ -108,7 +108,7 @@ type fakeDRAServerInfo struct {
|
||||
teardownFn tearDown
|
||||
}
|
||||
|
||||
func setupFakeDRADriverGRPCServer(shouldTimeout bool, pluginClientTimeout *time.Duration, prepareResourcesResponse *drapbv1.NodePrepareResourcesResponse, unprepareResourcesResponse *drapbv1.NodeUnprepareResourcesResponse) (fakeDRAServerInfo, error) {
|
||||
func setupFakeDRADriverGRPCServer(shouldTimeout bool, pluginClientTimeout *time.Duration, prepareResourcesResponse *drapb.NodePrepareResourcesResponse, unprepareResourcesResponse *drapb.NodeUnprepareResourcesResponse) (fakeDRAServerInfo, error) {
|
||||
socketDir, err := os.MkdirTemp("", "dra")
|
||||
if err != nil {
|
||||
return fakeDRAServerInfo{
|
||||
@ -147,7 +147,7 @@ func setupFakeDRADriverGRPCServer(shouldTimeout bool, pluginClientTimeout *time.
|
||||
fakeDRADriverGRPCServer.timeout = &timeout
|
||||
}
|
||||
|
||||
drapbv1.RegisterNodeServer(s, fakeDRADriverGRPCServer)
|
||||
drapb.RegisterNodeServer(s, fakeDRADriverGRPCServer)
|
||||
|
||||
go func() {
|
||||
go s.Serve(l)
|
||||
@ -345,7 +345,7 @@ func TestPrepareResources(t *testing.T) {
|
||||
pod *v1.Pod
|
||||
claimInfo *ClaimInfo
|
||||
resourceClaim *resourcev1alpha2.ResourceClaim
|
||||
resp *drapbv1.NodePrepareResourcesResponse
|
||||
resp *drapb.NodePrepareResourcesResponse
|
||||
wantErr bool
|
||||
wantTimeout bool
|
||||
wantResourceSkipped bool
|
||||
@ -484,7 +484,7 @@ func TestPrepareResources(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
resp: &drapbv1.NodePrepareResourcesResponse{Claims: map[string]*drapbv1.NodePrepareResourceResponse{"test-reserved": nil}},
|
||||
resp: &drapb.NodePrepareResourcesResponse{Claims: map[string]*drapb.NodePrepareResourceResponse{"test-reserved": nil}},
|
||||
expectedCDIDevices: []string{},
|
||||
ExpectedPrepareCalls: 1,
|
||||
},
|
||||
@ -541,7 +541,7 @@ func TestPrepareResources(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
resp: &drapbv1.NodePrepareResourcesResponse{Claims: map[string]*drapbv1.NodePrepareResourceResponse{"test-reserved": nil}},
|
||||
resp: &drapb.NodePrepareResourcesResponse{Claims: map[string]*drapb.NodePrepareResourceResponse{"test-reserved": nil}},
|
||||
expectedCDIDevices: []string{},
|
||||
ExpectedPrepareCalls: 1,
|
||||
},
|
||||
@ -748,8 +748,8 @@ func TestPrepareResources(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
resp: &drapbv1.NodePrepareResourcesResponse{
|
||||
Claims: map[string]*drapbv1.NodePrepareResourceResponse{
|
||||
resp: &drapb.NodePrepareResourcesResponse{
|
||||
Claims: map[string]*drapb.NodePrepareResourceResponse{
|
||||
"test-reserved": {CDIDevices: []string{fmt.Sprintf("%s/%s=claim-test-reserved", driverName, driverClassName)}},
|
||||
},
|
||||
},
|
||||
@ -810,8 +810,8 @@ func TestPrepareResources(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
resp: &drapbv1.NodePrepareResourcesResponse{
|
||||
Claims: map[string]*drapbv1.NodePrepareResourceResponse{
|
||||
resp: &drapb.NodePrepareResourcesResponse{
|
||||
Claims: map[string]*drapb.NodePrepareResourceResponse{
|
||||
"test-reserved": {CDIDevices: []string{fmt.Sprintf("%s/%s=claim-test-reserved", driverName, driverClassName)}},
|
||||
},
|
||||
},
|
||||
@ -884,8 +884,8 @@ func TestPrepareResources(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
resp: &drapbv1.NodePrepareResourcesResponse{
|
||||
Claims: map[string]*drapbv1.NodePrepareResourceResponse{
|
||||
resp: &drapb.NodePrepareResourcesResponse{
|
||||
Claims: map[string]*drapb.NodePrepareResourceResponse{
|
||||
"test-reserved": {CDIDevices: []string{fmt.Sprintf("%s/%s=claim-test-reserved", driverName, driverClassName)}},
|
||||
},
|
||||
},
|
||||
@ -977,7 +977,7 @@ func TestUnprepareResources(t *testing.T) {
|
||||
driverName string
|
||||
pod *v1.Pod
|
||||
claimInfo *ClaimInfo
|
||||
resp *drapbv1.NodeUnprepareResourcesResponse
|
||||
resp *drapb.NodeUnprepareResourcesResponse
|
||||
wantErr bool
|
||||
wantTimeout bool
|
||||
wantResourceSkipped bool
|
||||
@ -1117,7 +1117,7 @@ func TestUnprepareResources(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
resp: &drapbv1.NodeUnprepareResourcesResponse{Claims: map[string]*drapbv1.NodeUnprepareResourceResponse{"test-reserved": {}}},
|
||||
resp: &drapb.NodeUnprepareResourcesResponse{Claims: map[string]*drapb.NodeUnprepareResourceResponse{"test-reserved": {}}},
|
||||
wantErr: true,
|
||||
wantTimeout: true,
|
||||
expectedUnprepareCalls: 1,
|
||||
@ -1168,7 +1168,7 @@ func TestUnprepareResources(t *testing.T) {
|
||||
},
|
||||
prepared: true,
|
||||
},
|
||||
resp: &drapbv1.NodeUnprepareResourcesResponse{Claims: map[string]*drapbv1.NodeUnprepareResourceResponse{"": {}}},
|
||||
resp: &drapb.NodeUnprepareResourcesResponse{Claims: map[string]*drapb.NodeUnprepareResourceResponse{"": {}}},
|
||||
expectedUnprepareCalls: 1,
|
||||
},
|
||||
{
|
||||
@ -1217,7 +1217,7 @@ func TestUnprepareResources(t *testing.T) {
|
||||
},
|
||||
prepared: false,
|
||||
},
|
||||
resp: &drapbv1.NodeUnprepareResourcesResponse{Claims: map[string]*drapbv1.NodeUnprepareResourceResponse{"": {}}},
|
||||
resp: &drapb.NodeUnprepareResourcesResponse{Claims: map[string]*drapb.NodeUnprepareResourceResponse{"": {}}},
|
||||
expectedUnprepareCalls: 1,
|
||||
},
|
||||
{
|
||||
@ -1267,7 +1267,7 @@ func TestUnprepareResources(t *testing.T) {
|
||||
},
|
||||
prepared: true,
|
||||
},
|
||||
resp: &drapbv1.NodeUnprepareResourcesResponse{Claims: map[string]*drapbv1.NodeUnprepareResourceResponse{"test-reserved": nil}},
|
||||
resp: &drapb.NodeUnprepareResourcesResponse{Claims: map[string]*drapb.NodeUnprepareResourceResponse{"test-reserved": nil}},
|
||||
expectedUnprepareCalls: 1,
|
||||
},
|
||||
} {
|
||||
|
@ -30,7 +30,7 @@ import (
|
||||
|
||||
utilversion "k8s.io/apimachinery/pkg/util/version"
|
||||
"k8s.io/klog/v2"
|
||||
drapb "k8s.io/kubelet/pkg/apis/dra/v1alpha3"
|
||||
drapb "k8s.io/kubelet/pkg/apis/dra/v1alpha4"
|
||||
)
|
||||
|
||||
const PluginClientTimeout = 45 * time.Second
|
||||
|
@ -27,27 +27,27 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"google.golang.org/grpc"
|
||||
drapbv1alpha3 "k8s.io/kubelet/pkg/apis/dra/v1alpha3"
|
||||
drapb "k8s.io/kubelet/pkg/apis/dra/v1alpha4"
|
||||
"k8s.io/kubernetes/test/utils/ktesting"
|
||||
)
|
||||
|
||||
const (
|
||||
v1alpha3Version = "v1alpha3"
|
||||
v1alpha4Version = "v1alpha4"
|
||||
)
|
||||
|
||||
type fakeV1alpha3GRPCServer struct {
|
||||
drapbv1alpha3.UnimplementedNodeServer
|
||||
type fakeV1alpha4GRPCServer struct {
|
||||
drapb.UnimplementedNodeServer
|
||||
}
|
||||
|
||||
var _ drapbv1alpha3.NodeServer = &fakeV1alpha3GRPCServer{}
|
||||
var _ drapb.NodeServer = &fakeV1alpha4GRPCServer{}
|
||||
|
||||
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 *fakeV1alpha4GRPCServer) NodePrepareResources(ctx context.Context, in *drapb.NodePrepareResourcesRequest) (*drapb.NodePrepareResourcesResponse, error) {
|
||||
return &drapb.NodePrepareResourcesResponse{Claims: map[string]*drapb.NodePrepareResourceResponse{"dummy": {CDIDevices: []string{"dummy"}}}}, nil
|
||||
}
|
||||
|
||||
func (f *fakeV1alpha3GRPCServer) NodeUnprepareResources(ctx context.Context, in *drapbv1alpha3.NodeUnprepareResourcesRequest) (*drapbv1alpha3.NodeUnprepareResourcesResponse, error) {
|
||||
func (f *fakeV1alpha4GRPCServer) NodeUnprepareResources(ctx context.Context, in *drapb.NodeUnprepareResourcesRequest) (*drapb.NodeUnprepareResourcesResponse, error) {
|
||||
|
||||
return &drapbv1alpha3.NodeUnprepareResourcesResponse{}, nil
|
||||
return &drapb.NodeUnprepareResourcesResponse{}, nil
|
||||
}
|
||||
|
||||
type tearDown func()
|
||||
@ -73,9 +73,9 @@ func setupFakeGRPCServer(version string) (string, tearDown, error) {
|
||||
|
||||
s := grpc.NewServer()
|
||||
switch version {
|
||||
case v1alpha3Version:
|
||||
fakeGRPCServer := &fakeV1alpha3GRPCServer{}
|
||||
drapbv1alpha3.RegisterNodeServer(s, fakeGRPCServer)
|
||||
case v1alpha4Version:
|
||||
fakeGRPCServer := &fakeV1alpha4GRPCServer{}
|
||||
drapb.RegisterNodeServer(s, fakeGRPCServer)
|
||||
default:
|
||||
return "", nil, fmt.Errorf("unsupported version: %s", version)
|
||||
}
|
||||
@ -91,7 +91,7 @@ func setupFakeGRPCServer(version string) (string, tearDown, error) {
|
||||
|
||||
func TestGRPCConnIsReused(t *testing.T) {
|
||||
ctx := ktesting.Init(t)
|
||||
addr, teardown, err := setupFakeGRPCServer(v1alpha3Version)
|
||||
addr, teardown, err := setupFakeGRPCServer(v1alpha4Version)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@ -132,8 +132,8 @@ func TestGRPCConnIsReused(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
req := &drapbv1alpha3.NodePrepareResourcesRequest{
|
||||
Claims: []*drapbv1alpha3.Claim{
|
||||
req := &drapb.NodePrepareResourcesRequest{
|
||||
Claims: []*drapb.Claim{
|
||||
{
|
||||
Namespace: "dummy-namespace",
|
||||
Uid: "dummy-uid",
|
||||
@ -218,13 +218,13 @@ func TestNodeUnprepareResources(t *testing.T) {
|
||||
description string
|
||||
serverSetup func(string) (string, tearDown, error)
|
||||
serverVersion string
|
||||
request *drapbv1alpha3.NodeUnprepareResourcesRequest
|
||||
request *drapb.NodeUnprepareResourcesRequest
|
||||
}{
|
||||
{
|
||||
description: "server supports v1alpha3",
|
||||
description: "server supports v1alpha4",
|
||||
serverSetup: setupFakeGRPCServer,
|
||||
serverVersion: v1alpha3Version,
|
||||
request: &drapbv1alpha3.NodeUnprepareResourcesRequest{},
|
||||
serverVersion: v1alpha4Version,
|
||||
request: &drapb.NodeUnprepareResourcesRequest{},
|
||||
},
|
||||
} {
|
||||
t.Run(test.description, func(t *testing.T) {
|
||||
|
@ -30,7 +30,7 @@ import (
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
"k8s.io/dynamic-resource-allocation/resourceslice"
|
||||
drapbv1alpha3 "k8s.io/kubelet/pkg/apis/dra/v1alpha3"
|
||||
drapb "k8s.io/kubelet/pkg/apis/dra/v1alpha4"
|
||||
registerapi "k8s.io/kubelet/pkg/apis/pluginregistration/v1"
|
||||
)
|
||||
|
||||
@ -308,9 +308,9 @@ func Start(ctx context.Context, nodeServer interface{}, opts ...Option) (result
|
||||
// Run the node plugin gRPC server first to ensure that it is ready.
|
||||
implemented := false
|
||||
plugin, err := startGRPCServer(klog.NewContext(ctx, klog.LoggerWithName(logger, "dra")), o.grpcVerbosity, o.unaryInterceptors, o.streamInterceptors, o.draEndpoint, func(grpcServer *grpc.Server) {
|
||||
if nodeServer, ok := nodeServer.(drapbv1alpha3.NodeServer); ok && o.nodeV1alpha3 {
|
||||
if nodeServer, ok := nodeServer.(drapb.NodeServer); ok && o.nodeV1alpha3 {
|
||||
logger.V(5).Info("registering drapbv1alpha3.NodeServer")
|
||||
drapbv1alpha3.RegisterNodeServer(grpcServer, nodeServer)
|
||||
drapb.RegisterNodeServer(grpcServer, nodeServer)
|
||||
implemented = true
|
||||
}
|
||||
})
|
||||
|
@ -17,7 +17,7 @@ limitations under the License.
|
||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: api.proto
|
||||
|
||||
package v1alpha3
|
||||
package v1alpha4
|
||||
|
||||
import (
|
||||
context "context"
|
||||
@ -423,37 +423,38 @@ func init() {
|
||||
func init() { proto.RegisterFile("api.proto", fileDescriptor_00212fb1f9d3bf1c) }
|
||||
|
||||
var fileDescriptor_00212fb1f9d3bf1c = []byte{
|
||||
// 480 bytes of a gzipped FileDescriptorProto
|
||||
// 481 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x54, 0x4d, 0x6f, 0xd3, 0x40,
|
||||
0x10, 0xcd, 0x36, 0x4d, 0x85, 0x27, 0x12, 0xa0, 0x55, 0x85, 0xa2, 0x50, 0x4c, 0x64, 0x51, 0x92,
|
||||
0x0b, 0xb6, 0x48, 0x41, 0xaa, 0x40, 0x5c, 0xd2, 0x82, 0xf8, 0x12, 0x42, 0x96, 0xb8, 0x70, 0x81,
|
||||
0xb5, 0x3d, 0xb8, 0xab, 0x7c, 0xec, 0xb2, 0x6b, 0x47, 0xea, 0x8d, 0x9f, 0xc0, 0xcf, 0xea, 0x81,
|
||||
0x03, 0xe2, 0xc4, 0xa9, 0xa2, 0xe6, 0x8f, 0x20, 0xaf, 0x9d, 0xf4, 0x43, 0x4e, 0x5d, 0x89, 0xdb,
|
||||
0xcc, 0x78, 0x67, 0xde, 0x9b, 0xf7, 0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xe8, 0x7a, 0x76, 0x7c, 0x17, 0xf6, 0xf6, 0x5f, 0xed, 0x17, 0x55, 0x1f,
|
||||
0xc2, 0x88, 0x97, 0x31, 0xdd, 0x84, 0x16, 0x2a, 0x25, 0x94, 0x21, 0x64, 0xf9, 0x45, 0xe2, 0xbc,
|
||||
0x84, 0x3b, 0x39, 0xca, 0x87, 0x99, 0xfc, 0x5f, 0xf9, 0x7f, 0x11, 0xb0, 0x57, 0x8d, 0x2a, 0x39,
|
||||
0xbf, 0xbd, 0x30, 0xeb, 0xd1, 0x79, 0x51, 0x56, 0x77, 0x56, 0x5a, 0x10, 0xd4, 0x59, 0xf0, 0xec,
|
||||
0xbc, 0x05, 0xfd, 0x1a, 0xb4, 0x2a, 0x13, 0x1e, 0xaf, 0x90, 0x67, 0xb9, 0xd2, 0x52, 0x55, 0x72,
|
||||
0x56, 0xd5, 0x37, 0xd0, 0x32, 0xd4, 0xe8, 0x16, 0x58, 0x33, 0x36, 0x45, 0x2d, 0x59, 0x88, 0xe5,
|
||||
0x93, 0xd3, 0x42, 0x4e, 0x39, 0xe5, 0x51, 0x69, 0x48, 0x1e, 0x52, 0x0a, 0xeb, 0xf9, 0xe7, 0x4e,
|
||||
0xd3, 0x94, 0x4c, 0x3c, 0x3c, 0x26, 0xb0, 0x9e, 0x93, 0xa0, 0x31, 0x6c, 0x56, 0xdd, 0x29, 0xdd,
|
||||
0xae, 0xbb, 0x63, 0xe3, 0x64, 0xf7, 0xfe, 0xd5, 0xce, 0xdd, 0x69, 0xd0, 0x29, 0xdc, 0xaa, 0xf6,
|
||||
0x83, 0xf6, 0xeb, 0x1d, 0x2b, 0xc0, 0x06, 0x57, 0xb5, 0xd6, 0x69, 0x8c, 0x46, 0x47, 0x27, 0x36,
|
||||
0xf9, 0x7d, 0x62, 0x37, 0xbe, 0x65, 0x36, 0x39, 0xca, 0x6c, 0xf2, 0x33, 0xb3, 0xc9, 0x9f, 0xcc,
|
||||
0x26, 0xdf, 0xff, 0xda, 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 0x55, 0xdf, 0x42, 0xc3, 0x50, 0xa3, 0x5b, 0x60, 0x4d, 0xd8, 0x18, 0xb5, 0x64, 0x21, 0x96,
|
||||
0x4f, 0xce, 0x0a, 0x39, 0xe5, 0x94, 0x47, 0xa5, 0x21, 0x79, 0x48, 0x29, 0xac, 0xe7, 0x9f, 0x5b,
|
||||
0x75, 0x53, 0x32, 0x71, 0xff, 0x84, 0xc0, 0x7a, 0x4e, 0x82, 0xc6, 0xb0, 0x59, 0x75, 0xa7, 0x74,
|
||||
0x7b, 0xd9, 0x1d, 0x1b, 0x27, 0xdb, 0x0f, 0x57, 0x3b, 0x77, 0xa7, 0x46, 0xc7, 0x70, 0xa7, 0xda,
|
||||
0x0f, 0xda, 0x5d, 0xee, 0x58, 0x01, 0xd6, 0x5b, 0xd5, 0x5a, 0xa7, 0x36, 0x18, 0x1c, 0x9f, 0xda,
|
||||
0xe4, 0xcf, 0xa9, 0x5d, 0xfb, 0x9e, 0xd9, 0xe4, 0x38, 0xb3, 0xc9, 0xaf, 0xcc, 0x26, 0x7f, 0x33,
|
||||
0x9b, 0xfc, 0xf8, 0x67, 0xd7, 0x3e, 0x3d, 0x18, 0xee, 0x69, 0x97, 0x0b, 0x6f, 0x98, 0x06, 0x38,
|
||||
0xc2, 0xc4, 0x93, 0xc3, 0xd8, 0x63, 0x92, 0x6b, 0x2f, 0x52, 0xcc, 0x2b, 0x41, 0x76, 0x83, 0x0d,
|
||||
0xf3, 0x2f, 0xd9, 0xf9, 0x1f, 0x00, 0x00, 0xff, 0xff, 0x65, 0xc5, 0xc2, 0x0e, 0x91, 0x04, 0x00,
|
||||
0x00,
|
||||
}
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
@ -19,7 +19,7 @@ limitations under the License.
|
||||
syntax = "proto3";
|
||||
|
||||
package v1alpha3;
|
||||
option go_package = "k8s.io/kubelet/pkg/apis/dra/v1alpha3";
|
||||
option go_package = "k8s.io/kubelet/pkg/apis/dra/v1alpha4";
|
||||
|
||||
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
|
||||
|
||||
@ -43,10 +43,6 @@ service Node {
|
||||
// The same error handling rules apply,
|
||||
rpc NodeUnprepareResources (NodeUnprepareResourcesRequest)
|
||||
returns (NodeUnprepareResourcesResponse) {}
|
||||
|
||||
// TODO: removing NodeListAndWatchResources and the code for
|
||||
// publishing ResourceSlice objects by kubelet is an API break.
|
||||
// If we do this, then v1alpha3 must be renamed to v1alpha4.
|
||||
}
|
||||
|
||||
message NodePrepareResourcesRequest {
|
@ -36,7 +36,7 @@ import (
|
||||
"k8s.io/client-go/kubernetes"
|
||||
"k8s.io/dynamic-resource-allocation/kubeletplugin"
|
||||
"k8s.io/klog/v2"
|
||||
drapbv1alpha3 "k8s.io/kubelet/pkg/apis/dra/v1alpha3"
|
||||
drapb "k8s.io/kubelet/pkg/apis/dra/v1alpha4"
|
||||
)
|
||||
|
||||
type ExamplePlugin struct {
|
||||
@ -88,7 +88,7 @@ type ClaimID struct {
|
||||
UID string
|
||||
}
|
||||
|
||||
var _ drapbv1alpha3.NodeServer = &ExamplePlugin{}
|
||||
var _ drapb.NodeServer = &ExamplePlugin{}
|
||||
|
||||
// getJSONFilePath returns the absolute path where CDI file is/should be.
|
||||
func (ex *ExamplePlugin) getJSONFilePath(claimUID string) string {
|
||||
@ -249,7 +249,7 @@ func (ex *ExamplePlugin) getUnprepareResourcesFailure() error {
|
||||
// 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, claimReq *drapbv1alpha3.Claim) ([]string, error) {
|
||||
func (ex *ExamplePlugin) nodePrepareResource(ctx context.Context, claimReq *drapb.Claim) ([]string, error) {
|
||||
logger := klog.FromContext(ctx)
|
||||
|
||||
// The plugin must retrieve the claim itself to get it in the version
|
||||
@ -394,9 +394,9 @@ func extractParameters(parameters runtime.RawExtension, env *map[string]string,
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ex *ExamplePlugin) NodePrepareResources(ctx context.Context, req *drapbv1alpha3.NodePrepareResourcesRequest) (*drapbv1alpha3.NodePrepareResourcesResponse, error) {
|
||||
resp := &drapbv1alpha3.NodePrepareResourcesResponse{
|
||||
Claims: make(map[string]*drapbv1alpha3.NodePrepareResourceResponse),
|
||||
func (ex *ExamplePlugin) NodePrepareResources(ctx context.Context, req *drapb.NodePrepareResourcesRequest) (*drapb.NodePrepareResourcesResponse, error) {
|
||||
resp := &drapb.NodePrepareResourcesResponse{
|
||||
Claims: make(map[string]*drapb.NodePrepareResourceResponse),
|
||||
}
|
||||
|
||||
if failure := ex.getPrepareResourcesFailure(); failure != nil {
|
||||
@ -406,11 +406,11 @@ func (ex *ExamplePlugin) NodePrepareResources(ctx context.Context, req *drapbv1a
|
||||
for _, claimReq := range req.Claims {
|
||||
cdiDevices, err := ex.nodePrepareResource(ctx, claimReq)
|
||||
if err != nil {
|
||||
resp.Claims[claimReq.Uid] = &drapbv1alpha3.NodePrepareResourceResponse{
|
||||
resp.Claims[claimReq.Uid] = &drapb.NodePrepareResourceResponse{
|
||||
Error: err.Error(),
|
||||
}
|
||||
} else {
|
||||
resp.Claims[claimReq.Uid] = &drapbv1alpha3.NodePrepareResourceResponse{
|
||||
resp.Claims[claimReq.Uid] = &drapb.NodePrepareResourceResponse{
|
||||
CDIDevices: cdiDevices,
|
||||
}
|
||||
}
|
||||
@ -421,7 +421,7 @@ 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, claimReq *drapbv1alpha3.Claim) error {
|
||||
func (ex *ExamplePlugin) nodeUnprepareResource(ctx context.Context, claimReq *drapb.Claim) error {
|
||||
ex.blockUnprepareResourcesMutex.Lock()
|
||||
defer ex.blockUnprepareResourcesMutex.Unlock()
|
||||
|
||||
@ -451,9 +451,9 @@ func (ex *ExamplePlugin) nodeUnprepareResource(ctx context.Context, claimReq *dr
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ex *ExamplePlugin) NodeUnprepareResources(ctx context.Context, req *drapbv1alpha3.NodeUnprepareResourcesRequest) (*drapbv1alpha3.NodeUnprepareResourcesResponse, error) {
|
||||
resp := &drapbv1alpha3.NodeUnprepareResourcesResponse{
|
||||
Claims: make(map[string]*drapbv1alpha3.NodeUnprepareResourceResponse),
|
||||
func (ex *ExamplePlugin) NodeUnprepareResources(ctx context.Context, req *drapb.NodeUnprepareResourcesRequest) (*drapb.NodeUnprepareResourcesResponse, error) {
|
||||
resp := &drapb.NodeUnprepareResourcesResponse{
|
||||
Claims: make(map[string]*drapb.NodeUnprepareResourceResponse),
|
||||
}
|
||||
|
||||
if failure := ex.getUnprepareResourcesFailure(); failure != nil {
|
||||
@ -463,11 +463,11 @@ func (ex *ExamplePlugin) NodeUnprepareResources(ctx context.Context, req *drapbv
|
||||
for _, claimReq := range req.Claims {
|
||||
err := ex.nodeUnprepareResource(ctx, claimReq)
|
||||
if err != nil {
|
||||
resp.Claims[claimReq.Uid] = &drapbv1alpha3.NodeUnprepareResourceResponse{
|
||||
resp.Claims[claimReq.Uid] = &drapb.NodeUnprepareResourceResponse{
|
||||
Error: err.Error(),
|
||||
}
|
||||
} else {
|
||||
resp.Claims[claimReq.Uid] = &drapbv1alpha3.NodeUnprepareResourceResponse{}
|
||||
resp.Claims[claimReq.Uid] = &drapb.NodeUnprepareResourceResponse{}
|
||||
}
|
||||
}
|
||||
return resp, nil
|
||||
|
Loading…
Reference in New Issue
Block a user