@@ -26,7 +26,6 @@ import (
26
26
"google.golang.org/grpc"
27
27
"k8s.io/klog/v2"
28
28
29
- resourceapi "k8s.io/api/resource/v1beta1"
30
29
"k8s.io/apimachinery/pkg/types"
31
30
"k8s.io/client-go/kubernetes"
32
31
"k8s.io/dynamic-resource-allocation/resourceslice"
@@ -55,24 +54,25 @@ type DRAPlugin interface {
55
54
// after it returns before all information is actually written
56
55
// to the API server.
57
56
//
58
- // The caller must not modify the content after the call.
57
+ // It is the responsibility of the caller to ensure that the pools and
58
+ // slices described in the driver resources parameters are valid
59
+ // according to the restrictions defined in the resource.k8s.io API.
59
60
//
60
- // Returns an error if KubeClient or NodeName options were not
61
- // set in Start() to create the DRAPlugin instance.
62
- PublishResources (ctx context.Context , resources Resources ) error
61
+ // Invalid ResourceSlices will be rejected by the apiserver during
62
+ // publishing, which happens asynchronously and thus does not
63
+ // get returned as error here. The only error returned here is
64
+ // when publishing was not set up properly, for example missing
65
+ // [KubeClient] or [NodeName] options.
66
+ //
67
+ // The caller may modify the resources after this call returns.
68
+ PublishResources (ctx context.Context , resources resourceslice.DriverResources ) error
63
69
64
70
// This unexported method ensures that we can modify the interface
65
71
// without causing an API break of the package
66
72
// (https://pkg.go.dev/golang.org/x/exp/apidiff#section-readme).
67
73
internal ()
68
74
}
69
75
70
- // Resources currently only supports devices. Might get extended in the
71
- // future.
72
- type Resources struct {
73
- Devices []resourceapi.Device
74
- }
75
-
76
76
// Option implements the functional options pattern for Start.
77
77
type Option func (o * options ) error
78
78
@@ -407,7 +407,7 @@ func (d *draPlugin) Stop() {
407
407
408
408
// PublishResources implements [DRAPlugin.PublishResources]. Returns en error if
409
409
// kubeClient or nodeName are unset.
410
- func (d * draPlugin ) PublishResources (ctx context.Context , resources Resources ) error {
410
+ func (d * draPlugin ) PublishResources (_ context.Context , resources resourceslice. DriverResources ) error {
411
411
if d .kubeClient == nil {
412
412
return errors .New ("no KubeClient found to publish resources" )
413
413
}
@@ -425,14 +425,9 @@ func (d *draPlugin) PublishResources(ctx context.Context, resources Resources) e
425
425
UID : d .nodeUID , // Optional, will be determined by controller if empty.
426
426
}
427
427
driverResources := & resourceslice.DriverResources {
428
- Pools : map [string ]resourceslice.Pool {
429
- d .nodeName : {
430
- Slices : []resourceslice.Slice {{
431
- Devices : resources .Devices ,
432
- }},
433
- },
434
- },
428
+ Pools : resources .Pools ,
435
429
}
430
+
436
431
if d .resourceSliceController == nil {
437
432
// Start publishing the information. The controller is using
438
433
// our background context, not the one passed into this
0 commit comments