dra: add "named resources" structured parameter model

Like the current device plugin interface, a DRA driver using this model
announces a list of resource instances. In contrast to device plugins, this
list is made available to the scheduler together with attributes that can be
used to select suitable instances when they are not all alike.

Because this is the first structured parameter model, some checks that
previously were not possible, in particular "is one structured parameter field
set", now gets enabled. Adding another structured parameter model will be
similar.

The applyconfigs code generator assumes that all types in an API are defined in
a single package. If it wasn't for that, it would be possible to place the
"named resources" types in separate packages, which makes their names in the Go
code more natural and provides an indication of their stability level because
the package name could include a version.
This commit is contained in:
Patrick Ohly
2024-02-23 15:22:02 +01:00
parent 096e948905
commit d4d5ade7f5
66 changed files with 6143 additions and 274 deletions

View File

@@ -32,10 +32,10 @@ func testNodeResourceSlice(name, nodeName, driverName string) *resource.NodeReso
ObjectMeta: metav1.ObjectMeta{
Name: name,
},
NodeName: nodeName,
DriverName: driverName,
NodeName: nodeName,
DriverName: driverName,
NodeResourceModel: resource.NodeResourceModel{
// TODO: implement one structured parameter model
NamedResources: &resource.NamedResourcesResources{},
},
}
}
@@ -188,15 +188,14 @@ func TestValidateNodeResourceSlice(t *testing.T) {
slice: testNodeResourceSlice(goodName, goodName, badName),
},
// TODO: implement one structured parameter model
// "empty-model": {
// wantFailures: field.ErrorList{field.Required(nil, "exactly one structured model field must be set")},
// slice: func() *resource.NodeResourceSlice {
// slice := testNodeResourceSlice(goodName, goodName, driverName)
// slice.NodeResourceModel = resource.NodeResourceModel{}
// return slice
// }(),
// },
"empty-model": {
wantFailures: field.ErrorList{field.Required(nil, "exactly one structured model field must be set")},
slice: func() *resource.NodeResourceSlice {
slice := testNodeResourceSlice(goodName, goodName, driverName)
slice.NodeResourceModel = resource.NodeResourceModel{}
return slice
}(),
},
}
for name, scenario := range scenarios {