Skip to content

Commit

Permalink
Introduce AdmissionCheckStrategy API, change assigning AdmissionCheck…
Browse files Browse the repository at this point in the history
…s to a Workload

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
  • Loading branch information
PBundyra committed Apr 16, 2024
1 parent 991e83a commit 181cdca
Show file tree
Hide file tree
Showing 26 changed files with 885 additions and 66 deletions.
25 changes: 24 additions & 1 deletion apis/kueue/v1beta1/clusterqueue_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,16 @@ type ClusterQueueSpec struct {
// +kubebuilder:default={}
Preemption *ClusterQueuePreemption `json:"preemption,omitempty"`

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

// admissionCheckStrategy defines a list of strategies to determine which ResourceFlavors require AdmissionChecks.
// This property cannot be used in conjunction with the 'admissionChecks' property.
// +optional
AdmissionChecksStrategy AdmissionChecksStrategy `json:"admissionChecksStrategy,omitempty"`

// stopPolicy - if set to a value different from None, the ClusterQueue is considered Inactive, no new reservation being
// made.
//
Expand All @@ -117,6 +123,23 @@ type ClusterQueueSpec struct {
StopPolicy *StopPolicy `json:"stopPolicy,omitempty"`
}

// AdmissionCheckStrategy defines a strategy for a AdmissionCheck.
type AdmissionChecksStrategy struct {
// admissionChecks is a list of strategies for AdmissionChecks
AdmissionChecks []AdmissionCheckStrategyRule `json:"admissionChecks,omitempty"`
}

// AdmissionCheckStrategyRule defines rules for a single AdmissionCheck
type AdmissionCheckStrategyRule struct {
// name is an AdmissionCheck's name.
Name string `json:"name"`

// onFlavors is a list of ResourceFlavors' names that this AdmissionCheck should run for.
// If empty, the AdmissionCheck will run for all workloads submitted to the ClusterQueue.
// +optional
OnFlavors []ResourceFlavorReference `json:"onFlavors"`
}

type QueueingStrategy string

const (
Expand Down
43 changes: 43 additions & 0 deletions apis/kueue/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 33 additions & 2 deletions charts/kueue/templates/crd/kueue.x-k8s.io_clusterqueues.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,42 @@ spec:
description: ClusterQueueSpec defines the desired state of ClusterQueue
properties:
admissionChecks:
description: admissionChecks lists the AdmissionChecks required by
this ClusterQueue
description: |-
admissionChecks lists the AdmissionChecks required by this ClusterQueue.
Cannot be used along with AdmissionCheckStrategy.
items:
type: string
type: array
admissionChecksStrategy:
description: |-
admissionCheckStrategy defines a list of strategies to determine which ResourceFlavors require AdmissionChecks.
This property cannot be used in conjunction with the 'admissionChecks' property.
properties:
admissionChecks:
description: admissionChecks is a list of strategies for AdmissionChecks
items:
description: AdmissionCheckStrategyRule defines rules for a
single AdmissionCheck
properties:
name:
description: name is an AdmissionCheck's name.
type: string
onFlavors:
description: |-
onFlavors is a list of ResourceFlavors' names that this AdmissionCheck should run for.
If empty, the AdmissionCheck will run for all workloads submitted to the ClusterQueue.
items:
description: ResourceFlavorReference is the name of the
ResourceFlavor.
maxLength: 253
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$
type: string
type: array
required:
- name
type: object
type: array
type: object
cohort:
description: |-
cohort that this ClusterQueue belongs to. CQs that belong to the
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 17 additions & 8 deletions client-go/applyconfiguration/kueue/v1beta1/clusterqueuespec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions client-go/applyconfiguration/utils.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 33 additions & 2 deletions config/components/crd/bases/kueue.x-k8s.io_clusterqueues.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,42 @@ spec:
description: ClusterQueueSpec defines the desired state of ClusterQueue
properties:
admissionChecks:
description: admissionChecks lists the AdmissionChecks required by
this ClusterQueue
description: |-
admissionChecks lists the AdmissionChecks required by this ClusterQueue.
Cannot be used along with AdmissionCheckStrategy.
items:
type: string
type: array
admissionChecksStrategy:
description: |-
admissionCheckStrategy defines a list of strategies to determine which ResourceFlavors require AdmissionChecks.
This property cannot be used in conjunction with the 'admissionChecks' property.
properties:
admissionChecks:
description: admissionChecks is a list of strategies for AdmissionChecks
items:
description: AdmissionCheckStrategyRule defines rules for a
single AdmissionCheck
properties:
name:
description: name is an AdmissionCheck's name.
type: string
onFlavors:
description: |-
onFlavors is a list of ResourceFlavors' names that this AdmissionCheck should run for.
If empty, the AdmissionCheck will run for all workloads submitted to the ClusterQueue.
items:
description: ResourceFlavorReference is the name of the
ResourceFlavor.
maxLength: 253
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$
type: string
type: array
required:
- name
type: object
type: array
type: object
cohort:
description: |-
cohort that this ClusterQueue belongs to. CQs that belong to the
Expand Down
2 changes: 1 addition & 1 deletion pkg/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ func (c *Cache) ClusterQueuesUsingAdmissionCheck(ac string) []string {
var cqs []string

for _, cq := range c.clusterQueues {
if cq.AdmissionChecks.Has(ac) {
if _, found := cq.AdmissionChecks[ac]; found {
cqs = append(cqs, cq.Name)
}
}
Expand Down
Loading

0 comments on commit 181cdca

Please sign in to comment.