Skip to content

Commit 348f94a

Browse files
committed
DRA: read ResourceClaim in DRA drivers
This is the second and final step towards making kubelet independent of the resource.k8s.io API versioning because it now doesn't need to copy structs defined by that API from the driver to the API server.
1 parent 616a014 commit 348f94a

File tree

5 files changed

+100
-249
lines changed

5 files changed

+100
-249
lines changed

pkg/kubelet/cm/dra/manager.go

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -224,13 +224,9 @@ func (m *ManagerImpl) PrepareResources(pod *v1.Pod) error {
224224
// Loop through all plugins and prepare for calling NodePrepareResources.
225225
for _, resourceHandle := range claimInfo.ResourceHandles {
226226
claim := &drapb.Claim{
227-
Namespace: claimInfo.Namespace,
228-
Uid: string(claimInfo.ClaimUID),
229-
Name: claimInfo.ClaimName,
230-
ResourceHandle: resourceHandle.Data,
231-
}
232-
if resourceHandle.StructuredData != nil {
233-
claim.StructuredResourceHandle = []*resourceapi.StructuredResourceHandle{resourceHandle.StructuredData}
227+
Namespace: claimInfo.Namespace,
228+
Uid: string(claimInfo.ClaimUID),
229+
Name: claimInfo.ClaimName,
234230
}
235231
pluginName := resourceHandle.DriverName
236232
batches[pluginName] = append(batches[pluginName], claim)
@@ -455,13 +451,9 @@ func (m *ManagerImpl) unprepareResources(podUID types.UID, namespace string, cla
455451
// Loop through all plugins and prepare for calling NodeUnprepareResources.
456452
for _, resourceHandle := range claimInfo.ResourceHandles {
457453
claim := &drapb.Claim{
458-
Namespace: claimInfo.Namespace,
459-
Uid: string(claimInfo.ClaimUID),
460-
Name: claimInfo.ClaimName,
461-
ResourceHandle: resourceHandle.Data,
462-
}
463-
if resourceHandle.StructuredData != nil {
464-
claim.StructuredResourceHandle = []*resourceapi.StructuredResourceHandle{resourceHandle.StructuredData}
454+
Namespace: claimInfo.Namespace,
455+
Uid: string(claimInfo.ClaimUID),
456+
Name: claimInfo.ClaimName,
465457
}
466458
pluginName := resourceHandle.DriverName
467459
batches[pluginName] = append(batches[pluginName], claim)

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,9 @@ func TestGRPCConnIsReused(t *testing.T) {
135135
req := &drapbv1alpha3.NodePrepareResourcesRequest{
136136
Claims: []*drapbv1alpha3.Claim{
137137
{
138-
Namespace: "dummy-namespace",
139-
Uid: "dummy-uid",
140-
Name: "dummy-claim",
141-
ResourceHandle: "dummy-resource",
138+
Namespace: "dummy-namespace",
139+
Uid: "dummy-uid",
140+
Name: "dummy-claim",
142141
},
143142
},
144143
}

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

Lines changed: 34 additions & 168 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/v1alpha3/api.proto

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ package v1alpha3;
2222
option go_package = "k8s.io/kubelet/pkg/apis/dra/v1alpha3";
2323

2424
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
25-
import "k8s.io/api/resource/v1alpha2/generated.proto";
2625

2726
option (gogoproto.goproto_stringer_all) = false;
2827
option (gogoproto.stringer_all) = true;
@@ -102,13 +101,4 @@ message Claim {
102101
// The name of the Resource claim (ResourceClaim.meta.Name)
103102
// This field is REQUIRED.
104103
string name = 3;
105-
// Resource handle (AllocationResult.ResourceHandles[*].Data)
106-
// This field is REQUIRED.
107-
string resource_handle = 4;
108-
// Structured parameter resource handle (AllocationResult.ResourceHandles[*].StructuredData).
109-
// This field is OPTIONAL. If present, it needs to be used
110-
// instead of resource_handle. It will only have a single entry.
111-
//
112-
// Using "repeated" instead of "optional" is a workaround for https://github.com/gogo/protobuf/issues/713.
113-
repeated k8s.io.api.resource.v1alpha2.StructuredResourceHandle structured_resource_handle = 5;
114104
}

0 commit comments

Comments
 (0)