@@ -388,16 +388,12 @@ const (
388
388
// DeviceRequest is a request for devices required for a claim.
389
389
// This is typically a request for a single resource like a device, but can
390
390
// also ask for several identical devices.
391
- //
392
- // A DeviceClassName is currently required. Clients must check that it is
393
- // indeed set. It's absence indicates that something changed in a way that
394
- // is not supported by the client yet, in which case it must refuse to
395
- // handle the request.
396
391
type DeviceRequest struct {
397
392
// Name can be used to reference this request in a pod.spec.containers[].resources.claims
398
393
// entry and in a constraint of the claim.
399
394
//
400
- // Must be a DNS label.
395
+ // Must be a DNS label and unique among all DeviceRequests in a
396
+ // ResourceClaim.
401
397
//
402
398
// +required
403
399
Name string
@@ -406,15 +402,17 @@ type DeviceRequest struct {
406
402
// additional configuration and selectors to be inherited by this
407
403
// request.
408
404
//
409
- // A class is required. Which classes are available depends on the cluster.
405
+ // A class is required if no subrequests are specified in the
406
+ // firstAvailable list. Which classes are available depends on the cluster.
410
407
//
411
408
// Administrators may use this to restrict which devices may get
412
409
// requested by only installing classes with selectors for permitted
413
410
// devices. If users are free to request anything without restrictions,
414
411
// then administrators can create an empty DeviceClass for users
415
412
// to reference.
416
413
//
417
- // +required
414
+ // +optional
415
+ // +oneOf=deviceRequestType
418
416
DeviceClassName string
419
417
420
418
// Selectors define criteria which must be satisfied by a specific
@@ -468,10 +466,93 @@ type DeviceRequest struct {
468
466
// +optional
469
467
// +featureGate=DRAAdminAccess
470
468
AdminAccess * bool
469
+
470
+ // FirstAvailable contains subrequests, exactly one of which must be satisfied
471
+ // in order to satisfy this request. This field may only be set in the
472
+ // entries of DeviceClaim.Requests.
473
+ //
474
+ // +optional
475
+ // +oneOf=deviceRequestType
476
+ // +listType=atomic
477
+ // +featureGate=DRAPrioritizedList
478
+ FirstAvailable []DeviceSubRequest
479
+ }
480
+
481
+ // DeviceSubRequest describes a request for device provided in the
482
+ // claim.spec.devices.requests[].firstAvailable array. Each
483
+ // is typically a request for a single resource like a device, but can
484
+ // also ask for several identical devices.
485
+ //
486
+ // DeviceSubRequest is similar to Request, but doesn't expose the AdminAccess
487
+ // or FirstAvailable fields, as those can only be set on the top-level request.
488
+ // AdminAccess is not supported for requests with a prioritized list, and
489
+ // recursive FirstAvailable fields are not supported.
490
+ type DeviceSubRequest struct {
491
+ // Name can be used to reference this subrequest in the list of constraints
492
+ // or the list of configurations for the claim. References must use the
493
+ // format <main request>/<subrequest>.
494
+ //
495
+ // Must be a DNS label.
496
+ //
497
+ // +required
498
+ Name string
499
+
500
+ // DeviceClassName references a specific DeviceClass, which can define
501
+ // additional configuration and selectors to be inherited by this
502
+ // subrequest.
503
+ //
504
+ // A class is required. Which classes are available depends on the cluster.
505
+ //
506
+ // Administrators may use this to restrict which devices may get
507
+ // requested by only installing classes with selectors for permitted
508
+ // devices. If users are free to request anything without restrictions,
509
+ // then administrators can create an empty DeviceClass for users
510
+ // to reference.
511
+ //
512
+ // +required
513
+ DeviceClassName string
514
+
515
+ // Selectors define criteria which must be satisfied by a specific
516
+ // device in order for that device to be considered for this
517
+ // subrequest. All selectors must be satisfied for a device to be
518
+ // considered.
519
+ //
520
+ // +optional
521
+ // +listType=atomic
522
+ Selectors []DeviceSelector
523
+
524
+ // AllocationMode and its related fields define how devices are allocated
525
+ // to satisfy this subrequest. Supported values are:
526
+ //
527
+ // - ExactCount: This request is for a specific number of devices.
528
+ // This is the default. The exact number is provided in the
529
+ // count field.
530
+ //
531
+ // - All: This subrequest is for all of the matching devices in a pool.
532
+ // Allocation will fail if some devices are already allocated,
533
+ // unless adminAccess is requested.
534
+ //
535
+ // If AlloctionMode is not specified, the default mode is ExactCount. If
536
+ // the mode is ExactCount and count is not specified, the default count is
537
+ // one. Any other subrequests must specify this field.
538
+ //
539
+ // More modes may get added in the future. Clients must refuse to handle
540
+ // requests with unknown modes.
541
+ //
542
+ // +optional
543
+ AllocationMode DeviceAllocationMode
544
+
545
+ // Count is used only when the count mode is "ExactCount". Must be greater than zero.
546
+ // If AllocationMode is ExactCount and this field is not specified, the default is one.
547
+ //
548
+ // +optional
549
+ // +oneOf=AllocationMode
550
+ Count int64
471
551
}
472
552
473
553
const (
474
- DeviceSelectorsMaxSize = 32
554
+ DeviceSelectorsMaxSize = 32
555
+ FirstAvailableDeviceRequestMaxSize = 8
475
556
)
476
557
477
558
type DeviceAllocationMode string
@@ -584,6 +665,10 @@ type DeviceConstraint struct {
584
665
// constraint. If this is not specified, this constraint applies to all
585
666
// requests in this claim.
586
667
//
668
+ // References to subrequests must include the name of the main request
669
+ // and may include the subrequest using the format <main request>[/<subrequest>]. If just
670
+ // the main request is given, the constraint applies to all subrequests.
671
+ //
587
672
// +optional
588
673
// +listType=atomic
589
674
Requests []string
@@ -621,6 +706,10 @@ type DeviceClaimConfiguration struct {
621
706
// Requests lists the names of requests where the configuration applies.
622
707
// If empty, it applies to all requests.
623
708
//
709
+ // References to subrequests must include the name of the main request
710
+ // and may include the subrequest using the format <main request>[/<subrequest>]. If just
711
+ // the main request is given, the configuration applies to all subrequests.
712
+ //
624
713
// +optional
625
714
// +listType=atomic
626
715
Requests []string
@@ -793,8 +882,12 @@ const AllocationResultsMaxSize = 32
793
882
// DeviceRequestAllocationResult contains the allocation result for one request.
794
883
type DeviceRequestAllocationResult struct {
795
884
// Request is the name of the request in the claim which caused this
796
- // device to be allocated. Multiple devices may have been allocated
797
- // per request.
885
+ // device to be allocated. If it references a subrequest in the
886
+ // firstAvailable list on a DeviceRequest, this field must
887
+ // include both the name of the main request and the subrequest
888
+ // using the format <main request>/<subrequest>.
889
+ //
890
+ // Multiple devices may have been allocated per request.
798
891
//
799
892
// +required
800
893
Request string
@@ -849,6 +942,10 @@ type DeviceAllocationConfiguration struct {
849
942
// Requests lists the names of requests where the configuration applies.
850
943
// If empty, its applies to all requests.
851
944
//
945
+ // References to subrequests must include the name of the main request
946
+ // and may include the subrequest using the format <main request>[/<subrequest>]. If just
947
+ // the main request is given, the configuration applies to all subrequests.
948
+ //
852
949
// +optional
853
950
// +listType=atomic
854
951
Requests []string
0 commit comments