Skip to content

Commit 34c3b09

Browse files
committed
KEP-5007 DRA Device Binding Conditions: API Update
1 parent d33916b commit 34c3b09

File tree

7 files changed

+348
-8
lines changed

7 files changed

+348
-8
lines changed

pkg/apis/resource/types.go

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ type ResourcePool struct {
233233
const ResourceSliceMaxSharedCapacity = 128
234234
const ResourceSliceMaxDevices = 128
235235
const PoolNameMaxLength = validation.DNS1123SubdomainMaxLength // Same as for a single node name.
236+
const BindingConditionsMaxSize = 4
237+
const BindingFailureConditionsMaxSize = 4
236238

237239
// Defines the max number of shared counters that can be specified
238240
// in a ResourceSlice. The number is summed up across all sets.
@@ -322,6 +324,51 @@ type Device struct {
322324
// +listType=atomic
323325
// +featureGate=DRADeviceTaints
324326
Taints []DeviceTaint
327+
328+
// BindsToNode indicates if the usage of an allocation involving this device
329+
// has to be limited to exactly the node that was chosen when allocating the claim.
330+
// If set to true, the scheduler will set the ResourceClaim.Status.Allocation.NodeSelector
331+
// to match the node where the allocation was made.
332+
//
333+
// This is an alpha field and requires enabling the DRADeviceBindingConditions and DRAResourceClaimDeviceStatus
334+
// feature gates.
335+
//
336+
// +optional
337+
// +featureGate=DRADeviceBindingConditions,DRAResourceClaimDeviceStatus
338+
BindsToNode *bool
339+
340+
// BindingConditions defines the conditions for proceeding with binding.
341+
// All of these conditions must be set in the per-device status
342+
// conditions with a value of True to proceed with binding the pod to the node
343+
// while scheduling the pod.
344+
//
345+
// The maximum number of binding conditions is 4.
346+
// All entries are condition types, which means
347+
// they must be labels.
348+
//
349+
// This is an alpha field and requires enabling the DRADeviceBindingConditions and DRAResourceClaimDeviceStatus
350+
// feature gates.
351+
//
352+
// +optional
353+
// +listType=atomic
354+
// +featureGate=DRADeviceBindingConditions,DRAResourceClaimDeviceStatus
355+
BindingConditions []string
356+
357+
// BindingFailureConditions defines the conditions for binding failure.
358+
// They may be set in the per-device status conditions.
359+
// If any is true, a binding failure occurred.
360+
//
361+
// The maximum number of binding conditions is 4.
362+
// All entries are condition types, which means
363+
// they must be labels.
364+
//
365+
// This is an alpha field and requires enabling the DRADeviceBindingConditions and DRAResourceClaimDeviceStatus
366+
// feature gates.
367+
//
368+
// +optional
369+
// +listType=atomic
370+
// +featureGate=DRADeviceBindingConditions,DRAResourceClaimDeviceStatus
371+
BindingFailureConditions []string
325372
}
326373

327374
// DeviceCounterConsumption defines a set of counters that
@@ -1183,6 +1230,16 @@ type AllocationResult struct {
11831230
// it got removed. May be reused once decoding v1alpha3 is no longer
11841231
// supported.
11851232
// Controller string
1233+
1234+
// AllocationTimestamp stores the time when the resources were allocated.
1235+
// This field is not guaranteed to be set, in which case that time is unknown.
1236+
//
1237+
// This is an alpha field and requires enabling the DRADeviceBindingConditions and DRAResourceClaimDeviceStatus
1238+
// feature gate.
1239+
//
1240+
// +optional
1241+
// +featureGate=DRADeviceBindingConditions,DRAResourceClaimDeviceStatus
1242+
AllocationTimestamp *metav1.Time
11861243
}
11871244

11881245
// DeviceAllocationResult is the result of allocating devices.
@@ -1272,6 +1329,28 @@ type DeviceRequestAllocationResult struct {
12721329
// +listType=atomic
12731330
// +featureGate=DRADeviceTaints
12741331
Tolerations []DeviceToleration
1332+
1333+
// BindingConditions contains a copy of the BindingConditions
1334+
// from the corresponding ResourceSlice at the time of allocation.
1335+
//
1336+
// This is an alpha field and requires enabling the DRADeviceBindingConditions and DRAResourceClaimDeviceStatus
1337+
// feature gates.
1338+
//
1339+
// +optional
1340+
// +listType=atomic
1341+
// +featureGate=DRADeviceBindingConditions,DRAResourceClaimDeviceStatus
1342+
BindingConditions []string
1343+
1344+
// BindingFailureConditions contains a copy of the BindingFailureConditions
1345+
// from the corresponding ResourceSlice at the time of allocation.
1346+
//
1347+
// This is an alpha field and requires enabling the DRADeviceBindingConditions and DRAResourceClaimDeviceStatus
1348+
// feature gates.
1349+
//
1350+
// +optional
1351+
// +listType=atomic
1352+
// +featureGate=DRADeviceBindingConditions,DRAResourceClaimDeviceStatus
1353+
BindingFailureConditions []string
12751354
}
12761355

12771356
// DeviceAllocationConfiguration gets embedded in an AllocationResult.

pkg/apis/resource/v1beta1/conversion.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,9 @@ func Convert_v1beta1_Device_To_resource_Device(in *resourcev1beta1.Device, out *
200200
taints = append(taints, taint)
201201
}
202202
out.Taints = taints
203+
out.BindsToNode = basic.BindsToNode
204+
out.BindingConditions = basic.BindingConditions
205+
out.BindingFailureConditions = basic.BindingFailureConditions
203206
}
204207
return nil
205208
}
@@ -245,6 +248,9 @@ func Convert_resource_Device_To_v1beta1_Device(in *resource.Device, out *resourc
245248
taints = append(taints, taint)
246249
}
247250
out.Basic.Taints = taints
251+
out.Basic.BindsToNode = in.BindsToNode
252+
out.Basic.BindingConditions = in.BindingConditions
253+
out.Basic.BindingFailureConditions = in.BindingFailureConditions
248254
return nil
249255
}
250256

pkg/features/kube_features.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,17 @@ const (
175175
// when a container uses the allocated device.
176176
DRAAdminAccess featuregate.Feature = "DRAAdminAccess"
177177

178+
// owner: @KobayashiD27
179+
// kep: http://kep.k8s.io/5007
180+
// alpha: v1.34
181+
//
182+
// Enables support for delaying the binding of pods
183+
// which depend on devices with binding conditions.
184+
//
185+
// DRAResourceClaimDeviceStatus also needs to be
186+
// enabled.
187+
DRADeviceBindingConditions featuregate.Feature = "DRADeviceBindingConditions"
188+
178189
// owner: @pohly
179190
// kep: http://kep.k8s.io/5055
180191
//
@@ -1165,6 +1176,10 @@ var defaultVersionedKubernetesFeatureGates = map[featuregate.Feature]featuregate
11651176
{Version: version.MustParse("1.34"), Default: true, PreRelease: featuregate.Beta},
11661177
},
11671178

1179+
DRADeviceBindingConditions: {
1180+
{Version: version.MustParse("1.34"), Default: false, PreRelease: featuregate.Alpha},
1181+
},
1182+
11681183
DRADeviceTaints: {
11691184
{Version: version.MustParse("1.33"), Default: false, PreRelease: featuregate.Alpha},
11701185
},

staging/src/k8s.io/api/resource/v1/types.go

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,8 @@ type ResourcePool struct {
236236
const ResourceSliceMaxSharedCapacity = 128
237237
const ResourceSliceMaxDevices = 128
238238
const PoolNameMaxLength = validation.DNS1123SubdomainMaxLength // Same as for a single node name.
239+
const BindingConditionsMaxSize = 4
240+
const BindingFailureConditionsMaxSize = 4
239241

240242
// Defines the max number of shared counters that can be specified
241243
// in a ResourceSlice. The number is summed up across all sets.
@@ -325,6 +327,51 @@ type Device struct {
325327
// +listType=atomic
326328
// +featureGate=DRADeviceTaints
327329
Taints []DeviceTaint `json:"taints,omitempty" protobuf:"bytes,8,rep,name=taints"`
330+
331+
// BindsToNode indicates if the usage of an allocation involving this device
332+
// has to be limited to exactly the node that was chosen when allocating the claim.
333+
// If set to true, the scheduler will set the ResourceClaim.Status.Allocation.NodeSelector
334+
// to match the node where the allocation was made.
335+
//
336+
// This is an alpha field and requires enabling the DRADeviceBindingConditions and DRAResourceClaimDeviceStatus
337+
// feature gates.
338+
//
339+
// +optional
340+
// +featureGate=DRADeviceBindingConditions,DRAResourceClaimDeviceStatus
341+
BindsToNode *bool `json:"bindsToNode,omitempty" protobuf:"varint,9,opt,name=bindsToNode"`
342+
343+
// BindingConditions defines the conditions for proceeding with binding.
344+
// All of these conditions must be set in the per-device status
345+
// conditions with a value of True to proceed with binding the pod to the node
346+
// while scheduling the pod.
347+
//
348+
// The maximum number of binding conditions is 4.
349+
//
350+
// The conditions must be a valid condition type string.
351+
//
352+
// This is an alpha field and requires enabling the DRADeviceBindingConditions and DRAResourceClaimDeviceStatus
353+
// feature gates.
354+
//
355+
// +optional
356+
// +listType=atomic
357+
// +featureGate=DRADeviceBindingConditions,DRAResourceClaimDeviceStatus
358+
BindingConditions []string `json:"bindingConditions,omitempty" protobuf:"bytes,10,rep,name=bindingConditions"`
359+
360+
// BindingFailureConditions defines the conditions for binding failure.
361+
// They may be set in the per-device status conditions.
362+
// If any is set to "True", a binding failure occurred.
363+
//
364+
// The maximum number of binding failure conditions is 4.
365+
//
366+
// The conditions must be a valid condition type string.
367+
//
368+
// This is an alpha field and requires enabling the DRADeviceBindingConditions and DRAResourceClaimDeviceStatus
369+
// feature gates.
370+
//
371+
// +optional
372+
// +listType=atomic
373+
// +featureGate=DRADeviceBindingConditions,DRAResourceClaimDeviceStatus
374+
BindingFailureConditions []string `json:"bindingFailureConditions,omitempty" protobuf:"bytes,11,rep,name=bindingFailureConditions"`
328375
}
329376

330377
// DeviceCounterConsumption defines a set of counters that
@@ -1191,6 +1238,16 @@ type AllocationResult struct {
11911238
// it got removed. May be reused once decoding v1alpha3 is no longer
11921239
// supported.
11931240
// Controller string `json:"controller,omitempty" protobuf:"bytes,4,opt,name=controller"`
1241+
1242+
// AllocationTimestamp stores the time when the resources were allocated.
1243+
// This field is not guaranteed to be set, in which case that time is unknown.
1244+
//
1245+
// This is an alpha field and requires enabling the DRADeviceBindingConditions and DRAResourceClaimDeviceStatus
1246+
// feature gate.
1247+
//
1248+
// +optional
1249+
// +featureGate=DRADeviceBindingConditions,DRAResourceClaimDeviceStatus
1250+
AllocationTimestamp *metav1.Time `json:"allocationTimestamp,omitempty" protobuf:"bytes,5,opt,name=allocationTimestamp"`
11941251
}
11951252

11961253
// DeviceAllocationResult is the result of allocating devices.
@@ -1280,6 +1337,28 @@ type DeviceRequestAllocationResult struct {
12801337
// +listType=atomic
12811338
// +featureGate=DRADeviceTaints
12821339
Tolerations []DeviceToleration `json:"tolerations,omitempty" protobuf:"bytes,6,opt,name=tolerations"`
1340+
1341+
// BindingConditions contains a copy of the BindingConditions
1342+
// from the corresponding ResourceSlice at the time of allocation.
1343+
//
1344+
// This is an alpha field and requires enabling the DRADeviceBindingConditions and DRAResourceClaimDeviceStatus
1345+
// feature gates.
1346+
//
1347+
// +optional
1348+
// +listType=atomic
1349+
// +featureGate=DRADeviceBindingConditions,DRAResourceClaimDeviceStatus
1350+
BindingConditions []string `json:"bindingConditions,omitempty" protobuf:"bytes,7,rep,name=bindingConditions"`
1351+
1352+
// BindingFailureConditions contains a copy of the BindingFailureConditions
1353+
// from the corresponding ResourceSlice at the time of allocation.
1354+
//
1355+
// This is an alpha field and requires enabling the DRADeviceBindingConditions and DRAResourceClaimDeviceStatus
1356+
// feature gates.
1357+
//
1358+
// +optional
1359+
// +listType=atomic
1360+
// +featureGate=DRADeviceBindingConditions,DRAResourceClaimDeviceStatus
1361+
BindingFailureConditions []string `json:"bindingFailureConditions,omitempty" protobuf:"bytes,8,rep,name=bindingFailureConditions"`
12831362
}
12841363

12851364
// DeviceAllocationConfiguration gets embedded in an AllocationResult.

staging/src/k8s.io/api/resource/v1beta1/types.go

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,8 @@ type ResourcePool struct {
244244
const ResourceSliceMaxSharedCapacity = 128
245245
const ResourceSliceMaxDevices = 128
246246
const PoolNameMaxLength = validation.DNS1123SubdomainMaxLength // Same as for a single node name.
247+
const BindingConditionsMaxSize = 4
248+
const BindingFailureConditionsMaxSize = 4
247249

248250
// Device represents one individual hardware instance that can be selected based
249251
// on its attributes. Besides the name, exactly one field must be set.
@@ -337,6 +339,51 @@ type BasicDevice struct {
337339
// +listType=atomic
338340
// +featureGate=DRADeviceTaints
339341
Taints []DeviceTaint `json:"taints,omitempty" protobuf:"bytes,7,rep,name=taints"`
342+
343+
// BindsToNode indicates if the usage of an allocation involving this device
344+
// has to be limited to exactly the node that was chosen when allocating the claim.
345+
// If set to true, the scheduler will set the ResourceClaim.Status.Allocation.NodeSelector
346+
// to match the node where the allocation was made.
347+
//
348+
// This is an alpha field and requires enabling the DRADeviceBindingConditions and DRAResourceClaimDeviceStatus
349+
// feature gates.
350+
//
351+
// +optional
352+
// +featureGate=DRADeviceBindingConditions,DRAResourceClaimDeviceStatus
353+
BindsToNode *bool `json:"bindsToNode,omitempty" protobuf:"varint,8,opt,name=bindsToNode"`
354+
355+
// BindingConditions defines the conditions for proceeding with binding.
356+
// All of these conditions must be set in the per-device status
357+
// conditions with a value of True to proceed with binding the pod to the node
358+
// while scheduling the pod.
359+
//
360+
// The maximum number of binding conditions is 4.
361+
//
362+
// The conditions must be a valid condition type string.
363+
//
364+
// This is an alpha field and requires enabling the DRADeviceBindingConditions and DRAResourceClaimDeviceStatus
365+
// feature gates.
366+
//
367+
// +optional
368+
// +listType=atomic
369+
// +featureGate=DRADeviceBindingConditions,DRAResourceClaimDeviceStatus
370+
BindingConditions []string `json:"bindingConditions,omitempty" protobuf:"bytes,9,rep,name=bindingConditions"`
371+
372+
// BindingFailureConditions defines the conditions for binding failure.
373+
// They may be set in the per-device status conditions.
374+
// If any is true, a binding failure occurred.
375+
//
376+
// The maximum number of binding failure conditions is 4.
377+
//
378+
// The conditions must be a valid condition type string.
379+
//
380+
// This is an alpha field and requires enabling the DRADeviceBindingConditions and DRAResourceClaimDeviceStatus
381+
// feature gates.
382+
//
383+
// +optional
384+
// +listType=atomic
385+
// +featureGate=DRADeviceBindingConditions,DRAResourceClaimDeviceStatus
386+
BindingFailureConditions []string `json:"bindingFailureConditions,omitempty" protobuf:"bytes,10,rep,name=bindingFailureConditions"`
340387
}
341388

342389
// DeviceCounterConsumption defines a set of counters that
@@ -1199,6 +1246,16 @@ type AllocationResult struct {
11991246
// it got removed. May be reused once decoding v1alpha3 is no longer
12001247
// supported.
12011248
// Controller string `json:"controller,omitempty" protobuf:"bytes,4,opt,name=controller"`
1249+
1250+
// AllocationTimestamp stores the time when the resources were allocated.
1251+
// This field is not guaranteed to be set, in which case that time is unknown.
1252+
//
1253+
// This is an alpha field and requires enabling the DRADeviceBindingConditions and DRAResourceClaimDeviceStatus
1254+
// feature gate.
1255+
//
1256+
// +optional
1257+
// +featureGate=DRADeviceBindingConditions,DRAResourceClaimDeviceStatus
1258+
AllocationTimestamp *metav1.Time `json:"allocationTimestamp,omitempty" protobuf:"bytes,5,opt,name=allocationTimestamp"`
12021259
}
12031260

12041261
// DeviceAllocationResult is the result of allocating devices.
@@ -1288,6 +1345,28 @@ type DeviceRequestAllocationResult struct {
12881345
// +listType=atomic
12891346
// +featureGate=DRADeviceTaints
12901347
Tolerations []DeviceToleration `json:"tolerations,omitempty" protobuf:"bytes,6,opt,name=tolerations"`
1348+
1349+
// BindingConditions contains a copy of the BindingConditions
1350+
// from the corresponding ResourceSlice at the time of allocation.
1351+
//
1352+
// This is an alpha field and requires enabling the DRADeviceBindingConditions and DRAResourceClaimDeviceStatus
1353+
// feature gates.
1354+
//
1355+
// +optional
1356+
// +listType=atomic
1357+
// +featureGate=DRADeviceBindingConditions,DRAResourceClaimDeviceStatus
1358+
BindingConditions []string `json:"bindingConditions,omitempty" protobuf:"bytes,7,rep,name=bindingConditions"`
1359+
1360+
// BindingFailureConditions contains a copy of the BindingFailureConditions
1361+
// from the corresponding ResourceSlice at the time of allocation.
1362+
//
1363+
// This is an alpha field and requires enabling the DRADeviceBindingConditions and DRAResourceClaimDeviceStatus
1364+
// feature gates.
1365+
//
1366+
// +optional
1367+
// +listType=atomic
1368+
// +featureGate=DRADeviceBindingConditions,DRAResourceClaimDeviceStatus
1369+
BindingFailureConditions []string `json:"bindingFailureConditions,omitempty" protobuf:"bytes,8,rep,name=bindingFailureConditions"`
12911370
}
12921371

12931372
// DeviceAllocationConfiguration gets embedded in an AllocationResult.

0 commit comments

Comments
 (0)