Skip to content

Commit a07e328

Browse files
committed
[KEP] FlavorFungability: replace FlavorFungibilityImplicitPreferenceDefault feature gate with API
1 parent 825f811 commit a07e328

File tree

19 files changed

+386
-32
lines changed

19 files changed

+386
-32
lines changed

apis/kueue/v1beta1/clusterqueue_types.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,16 @@ const (
388388
TryNextFlavor FlavorFungibilityPolicy = "TryNextFlavor"
389389
)
390390

391+
type FlavorFungibilityPreference string
392+
393+
const (
394+
BorrowingOverPreemption FlavorFungibilityPreference = "BorrowingOverPreemption"
395+
PreemptionOverBorrowing FlavorFungibilityPreference = "PreemptionOverBorrowing"
396+
)
397+
391398
// FlavorFungibility determines whether a workload should try the next flavor
392399
// before borrowing or preempting in current flavor.
400+
// +kubebuilder:validation:XValidation:rule="!has(self.preference) || (self.whenCanBorrow == 'TryNextFlavor' && self.whenCanPreempt == 'TryNextFlavor')",message="preference can only be set when both whenCanBorrow and whenCanPreempt are TryNextFlavor"
393401
type FlavorFungibility struct {
394402
// whenCanBorrow determines whether a workload should try the next flavor
395403
// before borrowing in current flavor. The possible values are:
@@ -414,6 +422,20 @@ type FlavorFungibility struct {
414422
// +kubebuilder:validation:Enum={MayStopSearch,TryNextFlavor,Preempt}
415423
// +kubebuilder:default="TryNextFlavor"
416424
WhenCanPreempt FlavorFungibilityPolicy `json:"whenCanPreempt,omitempty"`
425+
// preference guides the choosing of the flavor for admission in case all candidate flavors
426+
// require either preemption, borrowing, or both. The possible values are:
427+
// - `BorrowingOverPreemption` (default): prefer to use borrowing rather than preemption
428+
// when such a choice is possible. More technically it minimizes the borrowing distance
429+
// in the cohort tree, and solves tie-breaks by preferring better preemption mode
430+
// (reclaim over preemption within ClusterQueue).
431+
// - `PreemptionOverBorrowing`: prefer to use preemption rather than borrowing
432+
// when such a choice is possible. More technically it optimizes the preemption mode
433+
// (reclaim over preemption within ClusterQueue), and solves tie-breaks by minimizing
434+
// the borrowing distance in the cohort tree.
435+
//
436+
// +kubebuilder:validation:Enum={BorrowingOverPreemption,PreemptionOverBorrowing}
437+
// +optional
438+
Preference *FlavorFungibilityPreference `json:"preference,omitempty"`
417439
}
418440

419441
// ClusterQueuePreemption contains policies to preempt Workloads from this

apis/kueue/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.

apis/kueue/v1beta1/zz_generated.deepcopy.go

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/kueue/v1beta2/clusterqueue_types.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,16 @@ const (
380380
TryNextFlavor FlavorFungibilityPolicy = "TryNextFlavor"
381381
)
382382

383+
type FlavorFungibilityPreference string
384+
385+
const (
386+
BorrowingOverPreemption FlavorFungibilityPreference = "BorrowingOverPreemption"
387+
PreemptionOverBorrowing FlavorFungibilityPreference = "PreemptionOverBorrowing"
388+
)
389+
383390
// FlavorFungibility determines whether a workload should try the next flavor
384391
// before borrowing or preempting in current flavor.
392+
// +kubebuilder:validation:XValidation:rule="!has(self.preference) || (self.whenCanBorrow == 'TryNextFlavor' && self.whenCanPreempt == 'TryNextFlavor')",message="preference can only be set when both whenCanBorrow and whenCanPreempt are TryNextFlavor"
385393
type FlavorFungibility struct {
386394
// whenCanBorrow determines whether a workload should try the next flavor
387395
// before borrowing in current flavor. The possible values are:
@@ -406,6 +414,20 @@ type FlavorFungibility struct {
406414
// +kubebuilder:default="TryNextFlavor"
407415
// +optional
408416
WhenCanPreempt FlavorFungibilityPolicy `json:"whenCanPreempt,omitempty"`
417+
// preference guides the choosing of the flavor for admission in case all candidate flavors
418+
// require either preemption, borrowing, or both. The possible values are:
419+
// - `BorrowingOverPreemption` (default): prefer to use borrowing rather than preemption
420+
// when such a choice is possible. More technically it minimizes the borrowing distance
421+
// in the cohort tree, and solves tie-breaks by preferring better preemption mode
422+
// (reclaim over preemption within ClusterQueue).
423+
// - `PreemptionOverBorrowing`: prefer to use preemption rather than borrowing
424+
// when such a choice is possible. More technically it optimizes the preemption mode
425+
// (reclaim over preemption within ClusterQueue), and solves tie-breaks by minimizing
426+
// the borrowing distance in the cohort tree.
427+
//
428+
// +kubebuilder:validation:Enum={BorrowingOverPreemption,PreemptionOverBorrowing}
429+
// +optional
430+
Preference *FlavorFungibilityPreference `json:"preference,omitempty"`
409431
}
410432

411433
// ClusterQueuePreemption contains policies to preempt Workloads from this

apis/kueue/v1beta2/zz_generated.deepcopy.go

Lines changed: 6 additions & 1 deletion
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: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,22 @@ spec:
192192
flavorFungibility defines whether a workload should try the next flavor
193193
before borrowing or preempting in the flavor being evaluated.
194194
properties:
195+
preference:
196+
description: |-
197+
preference guides the choosing of the flavor for admission in case all candidate flavors
198+
require either preemption, borrowing, or both. The possible values are:
199+
- `BorrowingOverPreemption` (default): prefer to use borrowing rather than preemption
200+
when such a choice is possible. More technically it minimizes the borrowing distance
201+
in the cohort tree, and solves tie-breaks by preferring better preemption mode
202+
(reclaim over preemption within ClusterQueue).
203+
- `PreemptionOverBorrowing`: prefer to use preemption rather than borrowing
204+
when such a choice is possible. More technically it optimizes the preemption mode
205+
(reclaim over preemption within ClusterQueue), and solves tie-breaks by minimizing
206+
the borrowing distance in the cohort tree.
207+
enum:
208+
- BorrowingOverPreemption
209+
- PreemptionOverBorrowing
210+
type: string
195211
whenCanBorrow:
196212
default: MayStopSearch
197213
description: |-
@@ -224,6 +240,9 @@ spec:
224240
- Preempt
225241
type: string
226242
type: object
243+
x-kubernetes-validations:
244+
- message: preference can only be set when both whenCanBorrow and whenCanPreempt are TryNextFlavor
245+
rule: '!has(self.preference) || (self.whenCanBorrow == ''TryNextFlavor'' && self.whenCanPreempt == ''TryNextFlavor'')'
227246
namespaceSelector:
228247
description: |-
229248
namespaceSelector defines which namespaces are allowed to submit workloads to
@@ -940,6 +959,22 @@ spec:
940959
flavorFungibility defines whether a workload should try the next flavor
941960
before borrowing or preempting in the flavor being evaluated.
942961
properties:
962+
preference:
963+
description: |-
964+
preference guides the choosing of the flavor for admission in case all candidate flavors
965+
require either preemption, borrowing, or both. The possible values are:
966+
- `BorrowingOverPreemption` (default): prefer to use borrowing rather than preemption
967+
when such a choice is possible. More technically it minimizes the borrowing distance
968+
in the cohort tree, and solves tie-breaks by preferring better preemption mode
969+
(reclaim over preemption within ClusterQueue).
970+
- `PreemptionOverBorrowing`: prefer to use preemption rather than borrowing
971+
when such a choice is possible. More technically it optimizes the preemption mode
972+
(reclaim over preemption within ClusterQueue), and solves tie-breaks by minimizing
973+
the borrowing distance in the cohort tree.
974+
enum:
975+
- BorrowingOverPreemption
976+
- PreemptionOverBorrowing
977+
type: string
943978
whenCanBorrow:
944979
default: MayStopSearch
945980
description: |-
@@ -968,6 +1003,9 @@ spec:
9681003
- TryNextFlavor
9691004
type: string
9701005
type: object
1006+
x-kubernetes-validations:
1007+
- message: preference can only be set when both whenCanBorrow and whenCanPreempt are TryNextFlavor
1008+
rule: '!has(self.preference) || (self.whenCanBorrow == ''TryNextFlavor'' && self.whenCanPreempt == ''TryNextFlavor'')'
9711009
namespaceSelector:
9721010
description: |-
9731011
namespaceSelector defines which namespaces are allowed to submit workloads to

client-go/applyconfiguration/kueue/v1beta1/flavorfungibility.go

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

client-go/applyconfiguration/kueue/v1beta2/flavorfungibility.go

Lines changed: 11 additions & 2 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: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,22 @@ spec:
163163
flavorFungibility defines whether a workload should try the next flavor
164164
before borrowing or preempting in the flavor being evaluated.
165165
properties:
166+
preference:
167+
description: |-
168+
preference guides the choosing of the flavor for admission in case all candidate flavors
169+
require either preemption, borrowing, or both. The possible values are:
170+
- `BorrowingOverPreemption` (default): prefer to use borrowing rather than preemption
171+
when such a choice is possible. More technically it minimizes the borrowing distance
172+
in the cohort tree, and solves tie-breaks by preferring better preemption mode
173+
(reclaim over preemption within ClusterQueue).
174+
- `PreemptionOverBorrowing`: prefer to use preemption rather than borrowing
175+
when such a choice is possible. More technically it optimizes the preemption mode
176+
(reclaim over preemption within ClusterQueue), and solves tie-breaks by minimizing
177+
the borrowing distance in the cohort tree.
178+
enum:
179+
- BorrowingOverPreemption
180+
- PreemptionOverBorrowing
181+
type: string
166182
whenCanBorrow:
167183
default: MayStopSearch
168184
description: |-
@@ -195,6 +211,11 @@ spec:
195211
- Preempt
196212
type: string
197213
type: object
214+
x-kubernetes-validations:
215+
- message: preference can only be set when both whenCanBorrow and
216+
whenCanPreempt are TryNextFlavor
217+
rule: '!has(self.preference) || (self.whenCanBorrow == ''TryNextFlavor''
218+
&& self.whenCanPreempt == ''TryNextFlavor'')'
198219
namespaceSelector:
199220
description: |-
200221
namespaceSelector defines which namespaces are allowed to submit workloads to
@@ -929,6 +950,22 @@ spec:
929950
flavorFungibility defines whether a workload should try the next flavor
930951
before borrowing or preempting in the flavor being evaluated.
931952
properties:
953+
preference:
954+
description: |-
955+
preference guides the choosing of the flavor for admission in case all candidate flavors
956+
require either preemption, borrowing, or both. The possible values are:
957+
- `BorrowingOverPreemption` (default): prefer to use borrowing rather than preemption
958+
when such a choice is possible. More technically it minimizes the borrowing distance
959+
in the cohort tree, and solves tie-breaks by preferring better preemption mode
960+
(reclaim over preemption within ClusterQueue).
961+
- `PreemptionOverBorrowing`: prefer to use preemption rather than borrowing
962+
when such a choice is possible. More technically it optimizes the preemption mode
963+
(reclaim over preemption within ClusterQueue), and solves tie-breaks by minimizing
964+
the borrowing distance in the cohort tree.
965+
enum:
966+
- BorrowingOverPreemption
967+
- PreemptionOverBorrowing
968+
type: string
932969
whenCanBorrow:
933970
default: MayStopSearch
934971
description: |-
@@ -957,6 +994,11 @@ spec:
957994
- TryNextFlavor
958995
type: string
959996
type: object
997+
x-kubernetes-validations:
998+
- message: preference can only be set when both whenCanBorrow and
999+
whenCanPreempt are TryNextFlavor
1000+
rule: '!has(self.preference) || (self.whenCanBorrow == ''TryNextFlavor''
1001+
&& self.whenCanPreempt == ''TryNextFlavor'')'
9601002
namespaceSelector:
9611003
description: |-
9621004
namespaceSelector defines which namespaces are allowed to submit workloads to

pkg/features/kube_features.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ const (
160160
// owner: @pajakd
161161
// kep: https://github.com/kubernetes-sigs/kueue/tree/main/keps/582-preempt-based-on-flavor-order
162162
//
163-
// In flavor fungibility, the preference whether to preempt or borrow is inferred from flavor fungibility policy
164-
// This feature gate is going to be replaced by an API before graduation or deprecation.
163+
// In flavor fungibility, the preference whether to preempt or borrow is inferred from flavor fungibility policy.
164+
// Deprecated: planned to be removed in v0.16.
165165
FlavorFungibilityImplicitPreferenceDefault featuregate.Feature = "FlavorFungibilityImplicitPreferenceDefault"
166166

167167
// owner: @alaypatel07
@@ -297,6 +297,7 @@ var defaultVersionedFeatureGates = map[featuregate.Feature]featuregate.Versioned
297297
},
298298
FlavorFungibilityImplicitPreferenceDefault: {
299299
{Version: version.MustParse("0.13"), Default: false, PreRelease: featuregate.Alpha},
300+
{Version: version.MustParse("0.15"), Default: false, PreRelease: featuregate.Deprecated}, // remove in 0.16
300301
},
301302
DynamicResourceAllocation: {
302303
{Version: version.MustParse("0.14"), Default: false, PreRelease: featuregate.Alpha},

0 commit comments

Comments
 (0)