mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-09 03:57:41 +00:00
kubelet: support structured parameters for preparing resources
If the resource handle has data from a structured parameter model, then we need to pass that to the DRA driver kubelet plugin. Because Kubernetes uses gogo/protobuf, we cannot use "optional" for that new optional field and have to resort to "repeated" with a single repetition if present. This is a new, backwards-compatible field. That extending the resource.k8s.io changes the checksum of a kubelet checkpoint is unfortunate. Updating the test cases is a stop-gap measure, the actual solution will have to be something else before beta.
This commit is contained in:
parent
4ed2b3eaeb
commit
6f1ddfcd2e
@ -21,6 +21,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
v1 "k8s.io/api/core/v1"
|
||||
resourceapi "k8s.io/api/resource/v1alpha2"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
clientset "k8s.io/client-go/kubernetes"
|
||||
@ -143,6 +144,9 @@ func (m *ManagerImpl) PrepareResources(pod *v1.Pod) error {
|
||||
Name: resourceClaim.Name,
|
||||
ResourceHandle: resourceHandle.Data,
|
||||
}
|
||||
if resourceHandle.StructuredData != nil {
|
||||
claim.StructuredResourceHandle = []*resourceapi.StructuredResourceHandle{resourceHandle.StructuredData}
|
||||
}
|
||||
batches[pluginName] = append(batches[pluginName], claim)
|
||||
}
|
||||
claimInfos[resourceClaim.UID] = claimInfo
|
||||
|
@ -54,13 +54,14 @@ func (v1alpha2rm v1alpha2NodeResourceManager) Prepare(ctx context.Context, conn
|
||||
}
|
||||
|
||||
for _, claim := range req.Claims {
|
||||
res, err := nodeClient.NodePrepareResource(ctx,
|
||||
&drapbv1alpha2.NodePrepareResourceRequest{
|
||||
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()
|
||||
|
@ -37,6 +37,13 @@ func assertStateEqual(t *testing.T, restoredState, expectedState ClaimInfoStateL
|
||||
assert.Equal(t, expectedState, restoredState, "expected ClaimInfoState does not equal to restored one")
|
||||
}
|
||||
|
||||
// TODO (https://github.com/kubernetes/kubernetes/issues/123552): reconsider what data gets stored in checkpoints and whether that is really necessary.
|
||||
//
|
||||
// As it stands now, a "v1" checkpoint contains data for types like the resourcev1alpha2.ResourceHandle
|
||||
// which may change over time as new fields get added in a backward-compatible way (not unusual
|
||||
// for API types). That breaks checksuming with pkg/util/hash because it is based on spew output.
|
||||
// That output includes those new fields.
|
||||
|
||||
func TestCheckpointGetOrCreate(t *testing.T) {
|
||||
testCases := []struct {
|
||||
description string
|
||||
@ -52,7 +59,7 @@ func TestCheckpointGetOrCreate(t *testing.T) {
|
||||
},
|
||||
{
|
||||
"Restore checkpoint - single claim",
|
||||
`{"version":"v1","entries":[{"DriverName":"test-driver.cdi.k8s.io","ClassName":"class-name","ClaimUID":"067798be-454e-4be4-9047-1aa06aea63f7","ClaimName":"example","Namespace":"default","PodUIDs":{"139cdb46-f989-4f17-9561-ca10cfb509a6":{}},"ResourceHandles":[{"driverName":"test-driver.cdi.k8s.io","data":"{\"a\": \"b\"}"}],"CDIDevices":{"test-driver.cdi.k8s.io":["example.com/example=cdi-example"]}}],"checksum":4194867564}`,
|
||||
`{"version":"v1","entries":[{"DriverName":"test-driver.cdi.k8s.io","ClassName":"class-name","ClaimUID":"067798be-454e-4be4-9047-1aa06aea63f7","ClaimName":"example","Namespace":"default","PodUIDs":{"139cdb46-f989-4f17-9561-ca10cfb509a6":{}},"ResourceHandles":[{"driverName":"test-driver.cdi.k8s.io","data":"{\"a\": \"b\"}"}],"CDIDevices":{"test-driver.cdi.k8s.io":["example.com/example=cdi-example"]}}],"checksum":113577689}`,
|
||||
"",
|
||||
[]ClaimInfoState{
|
||||
{
|
||||
@ -76,7 +83,7 @@ func TestCheckpointGetOrCreate(t *testing.T) {
|
||||
},
|
||||
{
|
||||
"Restore checkpoint - single claim - multiple devices",
|
||||
`{"version":"v1","entries":[{"DriverName":"meta-test-driver.cdi.k8s.io","ClassName":"class-name","ClaimUID":"067798be-454e-4be4-9047-1aa06aea63f7","ClaimName":"example","Namespace":"default","PodUIDs":{"139cdb46-f989-4f17-9561-ca10cfb509a6":{}},"ResourceHandles":[{"driverName":"test-driver-1.cdi.k8s.io","data":"{\"a\": \"b\"}"},{"driverName":"test-driver-2.cdi.k8s.io","data":"{\"c\": \"d\"}"}],"CDIDevices":{"test-driver-1.cdi.k8s.io":["example-1.com/example-1=cdi-example-1"],"test-driver-2.cdi.k8s.io":["example-2.com/example-2=cdi-example-2"]}}],"checksum":360176657}`,
|
||||
`{"version":"v1","entries":[{"DriverName":"meta-test-driver.cdi.k8s.io","ClassName":"class-name","ClaimUID":"067798be-454e-4be4-9047-1aa06aea63f7","ClaimName":"example","Namespace":"default","PodUIDs":{"139cdb46-f989-4f17-9561-ca10cfb509a6":{}},"ResourceHandles":[{"driverName":"test-driver-1.cdi.k8s.io","data":"{\"a\": \"b\"}"},{"driverName":"test-driver-2.cdi.k8s.io","data":"{\"c\": \"d\"}"}],"CDIDevices":{"test-driver-1.cdi.k8s.io":["example-1.com/example-1=cdi-example-1"],"test-driver-2.cdi.k8s.io":["example-2.com/example-2=cdi-example-2"]}}],"checksum":1466990255}`,
|
||||
"",
|
||||
[]ClaimInfoState{
|
||||
{
|
||||
@ -105,7 +112,7 @@ func TestCheckpointGetOrCreate(t *testing.T) {
|
||||
},
|
||||
{
|
||||
"Restore checkpoint - multiple claims",
|
||||
`{"version":"v1","entries":[{"DriverName":"test-driver.cdi.k8s.io","ClassName":"class-name-1","ClaimUID":"067798be-454e-4be4-9047-1aa06aea63f7","ClaimName":"example-1","Namespace":"default","PodUIDs":{"139cdb46-f989-4f17-9561-ca10cfb509a6":{}},"ResourceHandles":[{"driverName":"test-driver.cdi.k8s.io","data":"{\"a\": \"b\"}"}],"CDIDevices":{"test-driver.cdi.k8s.io":["example.com/example=cdi-example-1"]}},{"DriverName":"test-driver.cdi.k8s.io","ClassName":"class-name-2","ClaimUID":"4cf8db2d-06c0-7d70-1a51-e59b25b2c16c","ClaimName":"example-2","Namespace":"default","PodUIDs":{"139cdb46-f989-4f17-9561-ca10cfb509a6":{}},"ResourceHandles":[{"driverName":"test-driver.cdi.k8s.io","data":"{\"c\": \"d\"}"}],"CDIDevices":{"test-driver.cdi.k8s.io":["example.com/example=cdi-example-2"]}}],"checksum":103176902}`,
|
||||
`{"version":"v1","entries":[{"DriverName":"test-driver.cdi.k8s.io","ClassName":"class-name-1","ClaimUID":"067798be-454e-4be4-9047-1aa06aea63f7","ClaimName":"example-1","Namespace":"default","PodUIDs":{"139cdb46-f989-4f17-9561-ca10cfb509a6":{}},"ResourceHandles":[{"driverName":"test-driver.cdi.k8s.io","data":"{\"a\": \"b\"}"}],"CDIDevices":{"test-driver.cdi.k8s.io":["example.com/example=cdi-example-1"]}},{"DriverName":"test-driver.cdi.k8s.io","ClassName":"class-name-2","ClaimUID":"4cf8db2d-06c0-7d70-1a51-e59b25b2c16c","ClaimName":"example-2","Namespace":"default","PodUIDs":{"139cdb46-f989-4f17-9561-ca10cfb509a6":{}},"ResourceHandles":[{"driverName":"test-driver.cdi.k8s.io","data":"{\"c\": \"d\"}"}],"CDIDevices":{"test-driver.cdi.k8s.io":["example.com/example=cdi-example-2"]}}],"checksum":471181742}`,
|
||||
"",
|
||||
[]ClaimInfoState{
|
||||
{
|
||||
@ -218,7 +225,7 @@ func TestCheckpointStateStore(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
expectedCheckpoint := `{"version":"v1","entries":[{"DriverName":"test-driver.cdi.k8s.io","ClassName":"class-name","ClaimUID":"067798be-454e-4be4-9047-1aa06aea63f7","ClaimName":"example","Namespace":"default","PodUIDs":{"139cdb46-f989-4f17-9561-ca10cfb509a6":{}},"ResourceHandles":[{"driverName":"test-driver.cdi.k8s.io","data":"{\"a\": \"b\"}"}],"CDIDevices":{"test-driver.cdi.k8s.io":["example.com/example=cdi-example"]}}],"checksum":4194867564}`
|
||||
expectedCheckpoint := `{"version":"v1","entries":[{"DriverName":"test-driver.cdi.k8s.io","ClassName":"class-name","ClaimUID":"067798be-454e-4be4-9047-1aa06aea63f7","ClaimName":"example","Namespace":"default","PodUIDs":{"139cdb46-f989-4f17-9561-ca10cfb509a6":{}},"ResourceHandles":[{"driverName":"test-driver.cdi.k8s.io","data":"{\"a\": \"b\"}"}],"CDIDevices":{"test-driver.cdi.k8s.io":["example.com/example=cdi-example"]}}],"checksum":113577689}`
|
||||
|
||||
// Should return an error, stateDir cannot be an empty string
|
||||
if _, err := NewCheckpointState("", testingCheckpoint); err == nil {
|
||||
|
@ -28,6 +28,7 @@ import (
|
||||
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"
|
||||
@ -58,6 +59,12 @@ type NodePrepareResourceRequest struct {
|
||||
// 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:"-"`
|
||||
}
|
||||
@ -122,6 +129,13 @@ func (m *NodePrepareResourceRequest) GetResourceHandle() string {
|
||||
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
|
||||
@ -183,6 +197,10 @@ type NodeUnprepareResourceRequest struct {
|
||||
// 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:"-"`
|
||||
}
|
||||
@ -247,6 +265,13 @@ func (m *NodeUnprepareResourceRequest) GetResourceHandle() string {
|
||||
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:"-"`
|
||||
@ -294,31 +319,34 @@ func init() {
|
||||
func init() { proto.RegisterFile("api.proto", fileDescriptor_00212fb1f9d3bf1c) }
|
||||
|
||||
var fileDescriptor_00212fb1f9d3bf1c = []byte{
|
||||
// 369 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x52, 0xb1, 0x6e, 0xe2, 0x40,
|
||||
0x10, 0x65, 0x0f, 0x74, 0xc2, 0x7b, 0xd2, 0x9d, 0xb4, 0xa7, 0x93, 0x2c, 0x03, 0x06, 0x59, 0xdc,
|
||||
0x41, 0x73, 0xb6, 0x8e, 0x6b, 0xae, 0xba, 0x02, 0xa5, 0x48, 0x85, 0x22, 0x4b, 0x34, 0x69, 0xd0,
|
||||
0xda, 0x3b, 0x31, 0x1b, 0x6c, 0xef, 0xc6, 0x6b, 0x53, 0xe7, 0x13, 0xf2, 0x07, 0x51, 0xfe, 0x86,
|
||||
0x32, 0x25, 0x65, 0x70, 0x7e, 0x24, 0x62, 0x1d, 0x2b, 0x8a, 0x04, 0xa2, 0x4d, 0xb7, 0xf3, 0xe6,
|
||||
0xcd, 0xbc, 0x37, 0xb3, 0x83, 0x0d, 0x2a, 0xb9, 0x2b, 0x33, 0x91, 0x0b, 0xd2, 0x5e, 0xff, 0xa1,
|
||||
0xb1, 0x5c, 0xd2, 0x89, 0xf5, 0x3b, 0xe2, 0xf9, 0xb2, 0x08, 0xdc, 0x50, 0x24, 0x5e, 0x24, 0x22,
|
||||
0xe1, 0x69, 0x42, 0x50, 0x5c, 0xe9, 0x48, 0x07, 0xfa, 0x55, 0x15, 0x3a, 0xf7, 0x08, 0x5b, 0x33,
|
||||
0xc1, 0xe0, 0x22, 0x03, 0x49, 0x33, 0xf0, 0x41, 0x89, 0x22, 0x0b, 0xc1, 0x87, 0x9b, 0x02, 0x54,
|
||||
0x4e, 0xba, 0xd8, 0x48, 0x69, 0x02, 0x4a, 0xd2, 0x10, 0x4c, 0x34, 0x40, 0x63, 0xc3, 0x7f, 0x03,
|
||||
0x48, 0x07, 0x1b, 0x61, 0x4c,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0x72, 0x15, 0x79, 0x54, 0x72, 0xe5, 0xb1, 0x8c, 0x7a, 0xb5, 0x46, 0xf0, 0x59,
|
||||
0x1f, 0xf3, 0xdf, 0x97, 0x00, 0x00, 0x00, 0xff, 0xff, 0x89, 0x2f, 0x77, 0x8e, 0x12, 0x03, 0x00,
|
||||
0x00,
|
||||
// 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, 0x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x76, 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.
|
||||
@ -457,6 +485,20 @@ func (m *NodePrepareResourceRequest) MarshalToSizedBuffer(dAtA []byte) (int, err
|
||||
_ = 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)
|
||||
@ -540,6 +582,20 @@ func (m *NodeUnprepareResourceRequest) MarshalToSizedBuffer(dAtA []byte) (int, e
|
||||
_ = 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)
|
||||
@ -627,6 +683,12 @@ func (m *NodePrepareResourceRequest) Size() (n int) {
|
||||
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
|
||||
}
|
||||
|
||||
@ -667,6 +729,12 @@ func (m *NodeUnprepareResourceRequest) Size() (n int) {
|
||||
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
|
||||
}
|
||||
|
||||
@ -689,11 +757,17 @@ 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
|
||||
@ -712,11 +786,17 @@ 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
|
||||
@ -895,6 +975,40 @@ func (m *NodePrepareResourceRequest) Unmarshal(dAtA []byte) error {
|
||||
}
|
||||
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:])
|
||||
@ -1155,6 +1269,40 @@ func (m *NodeUnprepareResourceRequest) Unmarshal(dAtA []byte) error {
|
||||
}
|
||||
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:])
|
||||
|
@ -22,6 +22,7 @@ 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;
|
||||
@ -52,6 +53,12 @@ message NodePrepareResourceRequest {
|
||||
// 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 {
|
||||
@ -74,6 +81,10 @@ message NodeUnprepareResourceRequest {
|
||||
// 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 {
|
||||
|
@ -29,6 +29,7 @@ import (
|
||||
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"
|
||||
@ -354,6 +355,12 @@ type Claim struct {
|
||||
// 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:"-"`
|
||||
}
|
||||
@ -418,6 +425,13 @@ func (m *Claim) GetResourceHandle() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *Claim) GetStructuredResourceHandle() []*v1alpha2.StructuredResourceHandle {
|
||||
if m != nil {
|
||||
return m.StructuredResourceHandle
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*NodePrepareResourcesRequest)(nil), "v1alpha3.NodePrepareResourcesRequest")
|
||||
proto.RegisterType((*NodePrepareResourcesResponse)(nil), "v1alpha3.NodePrepareResourcesResponse")
|
||||
@ -433,39 +447,43 @@ func init() {
|
||||
func init() { proto.RegisterFile("api.proto", fileDescriptor_00212fb1f9d3bf1c) }
|
||||
|
||||
var fileDescriptor_00212fb1f9d3bf1c = []byte{
|
||||
// 500 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x54, 0x4d, 0x6f, 0xd3, 0x40,
|
||||
0x10, 0xcd, 0x36, 0x49, 0x45, 0x26, 0x52, 0x8b, 0x56, 0x15, 0xb2, 0x42, 0x31, 0x91, 0x45, 0x49,
|
||||
0x2e, 0xd8, 0x22, 0x05, 0xa9, 0x02, 0x71, 0x49, 0x0b, 0x2a, 0x08, 0x21, 0x64, 0x89, 0x0b, 0x97,
|
||||
0xb2, 0xb6, 0x07, 0xc7, 0x8a, 0xe3, 0x35, 0xbb, 0x76, 0xa4, 0xde, 0xf8, 0x09, 0xfc, 0xac, 0x1e,
|
||||
0x38, 0x20, 0x4e, 0x9c, 0x2a, 0x6a, 0xfe, 0x08, 0xf2, 0xda, 0x4e, 0x3f, 0xe4, 0x34, 0x95, 0x7a,
|
||||
0x9b, 0x7d, 0xbb, 0x33, 0x6f, 0xe6, 0xbd, 0xb1, 0xa1, 0xc3, 0xe2, 0xc0, 0x8c, 0x05, 0x4f, 0x38,
|
||||
0xbd, 0x33, 0x7f, 0xca, 0xc2, 0x78, 0xc2, 0x76, 0x7b, 0x4f, 0xfc, 0x20, 0x99, 0xa4, 0x8e, 0xe9,
|
||||
0xf2, 0x99, 0xe5, 0x73, 0x9f, 0x5b, 0xea, 0x81, 0x93, 0x7e, 0x55, 0x27, 0x75, 0x50, 0x51, 0x91,
|
||||
0x68, 0xbc, 0x81, 0xfb, 0x1f, 0x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0xce, 0xba, 0xfa, 0xe9, 0xec, 0xfe, 0x0f, 0x00, 0x00, 0xff, 0xff, 0x42, 0xff, 0x15, 0x6b,
|
||||
0xba, 0x04, 0x00, 0x00,
|
||||
// 562 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x54, 0xcd, 0x6e, 0xd3, 0x40,
|
||||
0x10, 0xce, 0x36, 0x49, 0x45, 0x26, 0x52, 0x8b, 0x56, 0x15, 0xb2, 0x42, 0x31, 0x91, 0x45, 0x49,
|
||||
0x0e, 0x60, 0x0b, 0x07, 0x50, 0x05, 0xe2, 0x92, 0x16, 0x54, 0x10, 0x42, 0xc8, 0x88, 0x0b, 0x97,
|
||||
0xb0, 0xb1, 0x07, 0xc7, 0x4a, 0x62, 0x9b, 0x5d, 0x3b, 0x52, 0x6f, 0x3c, 0x02, 0x8f, 0xd5, 0x03,
|
||||
0x07, 0xc4, 0x89, 0x53, 0x45, 0xcd, 0x8d, 0xa7, 0x40, 0x5e, 0xdb, 0x69, 0x13, 0x39, 0x4d, 0xa5,
|
||||
0xde, 0x66, 0xe7, 0xef, 0x9b, 0xfd, 0xe6, 0x07, 0x1a, 0x2c, 0xf4, 0xf4, 0x90, 0x07, 0x51, 0x40,
|
||||
0x6f, 0xcc, 0x1e, 0xb1, 0x49, 0x38, 0x62, 0xbd, 0xd6, 0x43, 0xd7, 0x8b, 0x46, 0xf1, 0x50, 0xb7,
|
||||
0x83, 0xa9, 0xe1, 0x06, 0x6e, 0x60, 0x48, 0x87, 0x61, 0xfc, 0x45, 0xbe, 0xe4, 0x43, 0x4a, 0x59,
|
||||
0x60, 0xeb, 0xc1, 0x78, 0x5f, 0xe8, 0x5e, 0x60, 0xb0, 0xd0, 0x33, 0x38, 0x8a, 0x20, 0xe6, 0x36,
|
||||
0x1a, 0x79, 0x32, 0xd3, 0x70, 0xd1, 0x47, 0xce, 0x22, 0x74, 0x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0x7e, 0x9f, 0xa9, 0x95, 0x6f, 0x89, 0x4a, 0x4e, 0x12, 0x95, 0xfc,
|
||||
0x4c, 0x54, 0xf2, 0x27, 0x51, 0xc9, 0xf7, 0xbf, 0x6a, 0xe5, 0xd3, 0xbd, 0xfc, 0xd8, 0x8d, 0xe3,
|
||||
0x21, 0x4e, 0x30, 0x32, 0xc2, 0xb1, 0x9b, 0x1e, 0x3e, 0x61, 0x38, 0x9c, 0x15, 0x47, 0xaf, 0x37,
|
||||
0xdc, 0x94, 0xb7, 0xae, 0xf7, 0x3f, 0x00, 0x00, 0xff, 0xff, 0xfd, 0x14, 0x30, 0xd4, 0x5f, 0x05,
|
||||
0x00, 0x00,
|
||||
}
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
@ -857,6 +875,20 @@ func (m *Claim) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
_ = 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)
|
||||
@ -1027,6 +1059,12 @@ func (m *Claim) Size() (n int) {
|
||||
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
|
||||
}
|
||||
|
||||
@ -1131,11 +1169,17 @@ func (this *Claim) 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{`&Claim{`,
|
||||
`Namespace:` + fmt.Sprintf("%v", this.Namespace) + `,`,
|
||||
`Uid:` + fmt.Sprintf("%v", this.Uid) + `,`,
|
||||
`Name:` + fmt.Sprintf("%v", this.Name) + `,`,
|
||||
`ResourceHandle:` + fmt.Sprintf("%v", this.ResourceHandle) + `,`,
|
||||
`StructuredResourceHandle:` + repeatedStringForStructuredResourceHandle + `,`,
|
||||
`}`,
|
||||
}, "")
|
||||
return s
|
||||
@ -2027,6 +2071,40 @@ func (m *Claim) Unmarshal(dAtA []byte) error {
|
||||
}
|
||||
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:])
|
||||
|
@ -22,6 +22,7 @@ package v1alpha3;
|
||||
option go_package = "k8s.io/kubelet/pkg/apis/dra/v1alpha3";
|
||||
|
||||
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;
|
||||
@ -100,4 +101,10 @@ message Claim {
|
||||
// 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;
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ package app
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@ -26,6 +27,7 @@ import (
|
||||
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/dynamic-resource-allocation/kubeletplugin"
|
||||
"k8s.io/klog/v2"
|
||||
drapbv1alpha2 "k8s.io/kubelet/pkg/apis/dra/v1alpha2"
|
||||
@ -71,6 +73,7 @@ type ClaimID struct {
|
||||
}
|
||||
|
||||
var _ drapbv1alpha2.NodeServer = &ExamplePlugin{}
|
||||
var _ drapbv1alpha3.NodeServer = &ExamplePlugin{}
|
||||
|
||||
// getJSONFilePath returns the absolute path where CDI file is/should be.
|
||||
func (ex *ExamplePlugin) getJSONFilePath(claimUID string) string {
|
||||
@ -160,9 +163,29 @@ func (ex *ExamplePlugin) NodePrepareResource(ctx context.Context, req *drapbv1al
|
||||
|
||||
// Determine environment variables.
|
||||
var p parameters
|
||||
switch len(req.StructuredResourceHandle) {
|
||||
case 0:
|
||||
// Control plane controller did the allocation.
|
||||
if err := json.Unmarshal([]byte(req.ResourceHandle), &p); err != nil {
|
||||
return nil, fmt.Errorf("unmarshal resource handle: %w", err)
|
||||
}
|
||||
case 1:
|
||||
// Scheduler did the allocation with structured parameters.
|
||||
handle := req.StructuredResourceHandle[0]
|
||||
if handle == nil {
|
||||
return nil, errors.New("unexpected nil StructuredResourceHandle")
|
||||
}
|
||||
p.NodeName = handle.NodeName
|
||||
if err := extractParameters(handle.VendorClassParameters, &p.EnvVars, "admin"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := extractParameters(handle.VendorClaimParameters, &p.EnvVars, "user"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
default:
|
||||
// Huh?
|
||||
return nil, fmt.Errorf("invalid length of NodePrepareResourceRequest.StructuredResourceHandle: %d", len(req.StructuredResourceHandle))
|
||||
}
|
||||
|
||||
// Sanity check scheduling.
|
||||
if p.NodeName != "" && ex.nodeName != "" && p.NodeName != ex.nodeName {
|
||||
@ -212,6 +235,23 @@ func (ex *ExamplePlugin) NodePrepareResource(ctx context.Context, req *drapbv1al
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func extractParameters(parameters runtime.RawExtension, env *map[string]string, kind string) error {
|
||||
if len(parameters.Raw) == 0 {
|
||||
return nil
|
||||
}
|
||||
var data map[string]string
|
||||
if err := json.Unmarshal(parameters.Raw, &data); err != nil {
|
||||
return fmt.Errorf("decoding %s parameters: %v", kind, err)
|
||||
}
|
||||
if len(data) > 0 && *env == nil {
|
||||
*env = make(map[string]string)
|
||||
}
|
||||
for key, value := range data {
|
||||
(*env)[kind+"_"+key] = value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ex *ExamplePlugin) NodePrepareResources(ctx context.Context, req *drapbv1alpha3.NodePrepareResourcesRequest) (*drapbv1alpha3.NodePrepareResourcesResponse, error) {
|
||||
resp := &drapbv1alpha3.NodePrepareResourcesResponse{
|
||||
Claims: make(map[string]*drapbv1alpha3.NodePrepareResourceResponse),
|
||||
@ -222,6 +262,7 @@ func (ex *ExamplePlugin) NodePrepareResources(ctx context.Context, req *drapbv1a
|
||||
ClaimName: claimReq.Name,
|
||||
ClaimUid: claimReq.Uid,
|
||||
ResourceHandle: claimReq.ResourceHandle,
|
||||
StructuredResourceHandle: claimReq.StructuredResourceHandle,
|
||||
})
|
||||
if err != nil {
|
||||
resp.Claims[claimReq.Uid] = &drapbv1alpha3.NodePrepareResourceResponse{
|
||||
|
Loading…
Reference in New Issue
Block a user