Skip to content

Commit ebecc56

Browse files
authored
Introduce AdmissionCheckStrategy API, change assigning AdmissionChecks to a Workload (#1960)
Add validation webhook Add TestReconcile unit tests Add webhook unit tests Add an additional layer to the API that wraps rules for AdmissionChecks Add AdmissionCheckStrategy to ClusterQueues's cache Change ClusterQueue cache Sort AdmissionChecks in a Workload
1 parent 206b59f commit ebecc56

File tree

26 files changed

+885
-66
lines changed

26 files changed

+885
-66
lines changed

‎apis/kueue/v1beta1/clusterqueue_types.go‎

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,16 @@ type ClusterQueueSpec struct {
9898
// +kubebuilder:default={}
9999
Preemption *ClusterQueuePreemption `json:"preemption,omitempty"`
100100

101-
// admissionChecks lists the AdmissionChecks required by this ClusterQueue
101+
// admissionChecks lists the AdmissionChecks required by this ClusterQueue.
102+
// Cannot be used along with AdmissionCheckStrategy.
102103
// +optional
103104
AdmissionChecks []string `json:"admissionChecks,omitempty"`
104105

106+
// admissionCheckStrategy defines a list of strategies to determine which ResourceFlavors require AdmissionChecks.
107+
// This property cannot be used in conjunction with the 'admissionChecks' property.
108+
// +optional
109+
AdmissionChecksStrategy AdmissionChecksStrategy `json:"admissionChecksStrategy,omitempty"`
110+
105111
// stopPolicy - if set to a value different from None, the ClusterQueue is considered Inactive, no new reservation being
106112
// made.
107113
//
@@ -117,6 +123,23 @@ type ClusterQueueSpec struct {
117123
StopPolicy *StopPolicy `json:"stopPolicy,omitempty"`
118124
}
119125

126+
// AdmissionCheckStrategy defines a strategy for a AdmissionCheck.
127+
type AdmissionChecksStrategy struct {
128+
// admissionChecks is a list of strategies for AdmissionChecks
129+
AdmissionChecks []AdmissionCheckStrategyRule `json:"admissionChecks,omitempty"`
130+
}
131+
132+
// AdmissionCheckStrategyRule defines rules for a single AdmissionCheck
133+
type AdmissionCheckStrategyRule struct {
134+
// name is an AdmissionCheck's name.
135+
Name string `json:"name"`
136+
137+
// onFlavors is a list of ResourceFlavors' names that this AdmissionCheck should run for.
138+
// If empty, the AdmissionCheck will run for all workloads submitted to the ClusterQueue.
139+
// +optional
140+
OnFlavors []ResourceFlavorReference `json:"onFlavors"`
141+
}
142+
120143
type QueueingStrategy string
121144

122145
const (

‎apis/kueue/v1beta1/zz_generated.deepcopy.go‎

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

‎charts/kueue/templates/crd/kueue.x-k8s.io_clusterqueues.yaml‎

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,42 @@ spec:
7474
description: ClusterQueueSpec defines the desired state of ClusterQueue
7575
properties:
7676
admissionChecks:
77-
description: admissionChecks lists the AdmissionChecks required by
78-
this ClusterQueue
77+
description: |-
78+
admissionChecks lists the AdmissionChecks required by this ClusterQueue.
79+
Cannot be used along with AdmissionCheckStrategy.
7980
items:
8081
type: string
8182
type: array
83+
admissionChecksStrategy:
84+
description: |-
85+
admissionCheckStrategy defines a list of strategies to determine which ResourceFlavors require AdmissionChecks.
86+
This property cannot be used in conjunction with the 'admissionChecks' property.
87+
properties:
88+
admissionChecks:
89+
description: admissionChecks is a list of strategies for AdmissionChecks
90+
items:
91+
description: AdmissionCheckStrategyRule defines rules for a
92+
single AdmissionCheck
93+
properties:
94+
name:
95+
description: name is an AdmissionCheck's name.
96+
type: string
97+
onFlavors:
98+
description: |-
99+
onFlavors is a list of ResourceFlavors' names that this AdmissionCheck should run for.
100+
If empty, the AdmissionCheck will run for all workloads submitted to the ClusterQueue.
101+
items:
102+
description: ResourceFlavorReference is the name of the
103+
ResourceFlavor.
104+
maxLength: 253
105+
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$
106+
type: string
107+
type: array
108+
required:
109+
- name
110+
type: object
111+
type: array
112+
type: object
82113
cohort:
83114
description: |-
84115
cohort that this ClusterQueue belongs to. CQs that belong to the

‎client-go/applyconfiguration/kueue/v1beta1/admissionchecksstrategy.go‎

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

‎client-go/applyconfiguration/kueue/v1beta1/admissioncheckstrategyrule.go‎

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

‎client-go/applyconfiguration/kueue/v1beta1/clusterqueuespec.go‎

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

‎client-go/applyconfiguration/utils.go‎

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

‎config/components/crd/bases/kueue.x-k8s.io_clusterqueues.yaml‎

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,42 @@ spec:
5959
description: ClusterQueueSpec defines the desired state of ClusterQueue
6060
properties:
6161
admissionChecks:
62-
description: admissionChecks lists the AdmissionChecks required by
63-
this ClusterQueue
62+
description: |-
63+
admissionChecks lists the AdmissionChecks required by this ClusterQueue.
64+
Cannot be used along with AdmissionCheckStrategy.
6465
items:
6566
type: string
6667
type: array
68+
admissionChecksStrategy:
69+
description: |-
70+
admissionCheckStrategy defines a list of strategies to determine which ResourceFlavors require AdmissionChecks.
71+
This property cannot be used in conjunction with the 'admissionChecks' property.
72+
properties:
73+
admissionChecks:
74+
description: admissionChecks is a list of strategies for AdmissionChecks
75+
items:
76+
description: AdmissionCheckStrategyRule defines rules for a
77+
single AdmissionCheck
78+
properties:
79+
name:
80+
description: name is an AdmissionCheck's name.
81+
type: string
82+
onFlavors:
83+
description: |-
84+
onFlavors is a list of ResourceFlavors' names that this AdmissionCheck should run for.
85+
If empty, the AdmissionCheck will run for all workloads submitted to the ClusterQueue.
86+
items:
87+
description: ResourceFlavorReference is the name of the
88+
ResourceFlavor.
89+
maxLength: 253
90+
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$
91+
type: string
92+
type: array
93+
required:
94+
- name
95+
type: object
96+
type: array
97+
type: object
6798
cohort:
6899
description: |-
69100
cohort that this ClusterQueue belongs to. CQs that belong to the

‎pkg/cache/cache.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ func (c *Cache) ClusterQueuesUsingAdmissionCheck(ac string) []string {
728728
var cqs []string
729729

730730
for _, cq := range c.clusterQueues {
731-
if cq.AdmissionChecks.Has(ac) {
731+
if _, found := cq.AdmissionChecks[ac]; found {
732732
cqs = append(cqs, cq.Name)
733733
}
734734
}

0 commit comments

Comments
 (0)