Skip to content

Commit 56d39f3

Browse files
geetasgaws-ruhip
authored andcommitted
Add support for MatchExpression CEL constraint DRA
1 parent 387f474 commit 56d39f3

27 files changed

+1455
-530
lines changed

README_ruhip.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
### Details
2+
* This is a forked repo from kubernetes to add support for DRA CEL constraint
3+
4+
This modifies the kube-apiserver and kube-scheduler components to introduce a new CEL expression constraint for DRA. Specifically, the following files have been modified:
5+
* kube-apiserver: kubernetes/staging/src/k8s.io/api/resource/v1alpha3/types.go
6+
* kube-scheduler: kubernetes/staging/src/k8s.io/dynamic-resource-allocation/structured/allocator.go
7+
8+
### Testing Steps
9+
10+
Add a tag
11+
git tag -a v1.34.0-alpha.dracelexpr
12+
13+
KUBE_BUILD_PLATFORMS=linux/amd64 KUBE_DOCKER_IMAGE_TAG=v1.34.0-dracelexpr make quick-release-images
14+
15+
kind load docker-image registry.k8s.io/kube-controller-manager-amd64:v1.34.0-dracelexpr --name dra-example-driver-cluster
16+
kind load docker-image registry.k8s.io/kube-apiserver-amd64:v1.34.0-dracelexpr --name dra-example-driver-cluster
17+
kind load docker-image registry.k8s.io/kube-scheduler-amd64:v1.34.0-dracelexpr --name dra-example-driver-cluster
18+
kind load docker-image registry.k8s.io/kube-proxy-amd64:v1.34.0-dracelexpr --name dra-example-driver-cluster
19+
20+
21+
then docker exec -it /bin/bash into control plane container and update manifests - change the image and change log verbosity to 6 -- pods will restart automatically. Verify with get pod that control plane components are running with the above images - change apiserver, kcm and scheduler ..not sure if kcm needs to be updated.
22+
23+
Logs from dra code are in scheduler log
24+
kubectl logs kube-scheduler-dra-example-driver-cluster-control-plane -n kube-system > s.log
25+
26+

api/openapi-spec/swagger.json

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/openapi-spec/v3/apis__resource.k8s.io__v1alpha3_openapi.json

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/openapi-spec/v3/apis__resource.k8s.io__v1beta1_openapi.json

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/openapi-spec/v3/apis__resource.k8s.io__v1beta2_openapi.json

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/resource/types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,7 @@ type DeviceConstraint struct {
976976
// accidentally ignore this additional, for them unknown match
977977
// criteria.
978978
//
979-
// MatchExpression string
979+
MatchExpression string
980980
}
981981

982982
// DeviceClaimConfiguration is used for configuration parameters in DeviceClaim.

pkg/apis/resource/v1alpha3/zz_generated.conversion.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/resource/v1beta1/zz_generated.conversion.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/resource/v1beta2/zz_generated.conversion.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/resource/validation/validation.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,11 +312,20 @@ func validateDeviceConstraint(constraint resource.DeviceConstraint, fldPath *fie
312312
return validateRequestNameRef(name, fldPath, requestNames)
313313
},
314314
stringKey, fldPath.Child("requests"))...)
315-
if constraint.MatchAttribute == nil {
316-
allErrs = append(allErrs, field.Required(fldPath.Child("matchAttribute"), ""))
317-
} else {
315+
316+
if constraint.MatchAttribute == nil && constraint.MatchExpression == "" {
317+
allErrs = append(allErrs, field.Required(fldPath, "must specify either matchAttribute or MatchExpression"))
318+
}
319+
if constraint.MatchAttribute != nil && constraint.MatchExpression != "" {
320+
allErrs = append(allErrs, field.Invalid(fldPath, constraint, "cannot specify both matchAttribute and MatchExpression"))
321+
}
322+
// Validate MatchAttribute if present
323+
if constraint.MatchAttribute != nil {
318324
allErrs = append(allErrs, validateFullyQualifiedName(*constraint.MatchAttribute, fldPath.Child("matchAttribute"))...)
319325
}
326+
327+
//TODO add validation for Expression
328+
320329
return allErrs
321330
}
322331

0 commit comments

Comments
 (0)