-
Notifications
You must be signed in to change notification settings - Fork 456
FlavorFungability: replace FlavorFungibilityImplicitPreferenceDefault feature gate with API #7316
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -388,8 +388,16 @@ const ( | |||||||||||||||||||||
| TryNextFlavor FlavorFungibilityPolicy = "TryNextFlavor" | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| type FlavorFungibilityPreference string | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const ( | ||||||||||||||||||||||
| BorrowingOverPreemption FlavorFungibilityPreference = "BorrowingOverPreemption" | ||||||||||||||||||||||
| PreemptionOverBorrowing FlavorFungibilityPreference = "PreemptionOverBorrowing" | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // FlavorFungibility determines whether a workload should try the next flavor | ||||||||||||||||||||||
| // before borrowing or preempting in current flavor. | ||||||||||||||||||||||
| // +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" | ||||||||||||||||||||||
| type FlavorFungibility struct { | ||||||||||||||||||||||
| // whenCanBorrow determines whether a workload should try the next flavor | ||||||||||||||||||||||
| // before borrowing in current flavor. The possible values are: | ||||||||||||||||||||||
|
|
@@ -414,6 +422,17 @@ type FlavorFungibility struct { | |||||||||||||||||||||
| // +kubebuilder:validation:Enum={MayStopSearch,TryNextFlavor,Preempt} | ||||||||||||||||||||||
| // +kubebuilder:default="TryNextFlavor" | ||||||||||||||||||||||
| WhenCanPreempt FlavorFungibilityPolicy `json:"whenCanPreempt,omitempty"` | ||||||||||||||||||||||
| // preference selects the order between minimizing preemption and avoiding borrowing | ||||||||||||||||||||||
| // when both policies are set to TryNextFlavor. The possible values are: | ||||||||||||||||||||||
| // | ||||||||||||||||||||||
| // - `BorrowingOverPreemption` (default): prefer lower borrowing distance before preferring lower preemption mode. | ||||||||||||||||||||||
| // - `PreemptionOverBorrowing`: prefer lower preemption mode before preferring lower borrowing distance. | ||||||||||||||||||||||
|
Comment on lines
+428
to
+429
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. make sure aligned with the KEP |
||||||||||||||||||||||
| // | ||||||||||||||||||||||
| // Deprecated values from earlier releases are not supported; please use the names above. | ||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a new field, there are no depreacted values from earlier releases. Remove this line |
||||||||||||||||||||||
| // | ||||||||||||||||||||||
| // +kubebuilder:validation:Enum={BorrowingOverPreemption,PreemptionOverBorrowing} | ||||||||||||||||||||||
| // +optional | ||||||||||||||||||||||
| Preference *FlavorFungibilityPreference `json:"preference,omitempty"` | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // ClusterQueuePreemption contains policies to preempt Workloads from this | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
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.
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.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -160,8 +160,8 @@ const ( | |
| // owner: @pajakd | ||
| // kep: https://github.com/kubernetes-sigs/kueue/tree/main/keps/582-preempt-based-on-flavor-order | ||
| // | ||
| // In flavor fungibility, the preference whether to preempt or borrow is inferred from flavor fungibility policy | ||
| // This feature gate is going to be replaced by an API before graduation or deprecation. | ||
| // In flavor fungibility, the preference whether to preempt or borrow is inferred from flavor fungibility policy. | ||
| // Deprecated: planned to be removed in v0.17. Will remain enabled by default through v0.16. | ||
| FlavorFungibilityImplicitPreferenceDefault featuregate.Feature = "FlavorFungibilityImplicitPreferenceDefault" | ||
|
|
||
| // owner: @alaypatel07 | ||
|
|
@@ -297,6 +297,9 @@ var defaultVersionedFeatureGates = map[featuregate.Feature]featuregate.Versioned | |
| }, | ||
| FlavorFungibilityImplicitPreferenceDefault: { | ||
| {Version: version.MustParse("0.13"), Default: false, PreRelease: featuregate.Alpha}, | ||
| // TODO: what to do with feature gate? | ||
| // {Version: version.MustParse("0.15"), Default: true, PreRelease: featuregate.Beta}, | ||
| // {Version: version.MustParse("0.16"), Default: true, PreRelease: featuregate.Deprecated}, // remove in 0.17 | ||
|
Comment on lines
+300
to
+302
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. // {Version: version.MustParse("0.15"), Default: false, PreRelease: featuregate.Deprecated}, // remove in 0.16 |
||
| }, | ||
| DynamicResourceAllocation: { | ||
| {Version: version.MustParse("0.14"), Default: false, PreRelease: featuregate.Alpha}, | ||
|
|
@@ -327,6 +330,11 @@ func Enabled(f featuregate.Feature) bool { | |
| return utilfeature.DefaultFeatureGate.Enabled(f) | ||
| } | ||
|
|
||
| // Disabled is helper for `!utilfeature.DefaultFeatureGate.Enabled()` | ||
| func Disabled(f featuregate.Feature) bool { | ||
| return !Enabled(f) | ||
| } | ||
|
Comment on lines
+333
to
+336
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why just not use !Enabled(f)?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, I don't see value in the extra helper |
||
|
|
||
| // SetEnable helper function that can be used to set the enabled value of a feature gate, | ||
| // it should only be used in integration test pending the merge of | ||
| // https://github.com/kubernetes/kubernetes/pull/118346 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -379,25 +379,39 @@ func isPreferred(a, b granularMode, fungibilityConfig kueue.FlavorFungibility) b | |
| return true | ||
| } | ||
|
|
||
| if !features.Enabled(features.FlavorFungibilityImplicitPreferenceDefault) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. /hold
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. /unhold |
||
| borrowingOverPreemption := func() bool { | ||
| if a.preemptionMode != b.preemptionMode { | ||
| return a.preemptionMode > b.preemptionMode | ||
| } else { | ||
| return a.borrowingLevel.betterThan(b.borrowingLevel) | ||
| } | ||
| return a.borrowingLevel.betterThan(b.borrowingLevel) | ||
| } | ||
|
|
||
| if fungibilityConfig.WhenCanBorrow == kueue.TryNextFlavor { | ||
| preemptionOverBorrowing := func() bool { | ||
| if a.borrowingLevel != b.borrowingLevel { | ||
| return a.borrowingLevel.betterThan(b.borrowingLevel) | ||
| } | ||
| return a.preemptionMode > b.preemptionMode | ||
| } else { | ||
| if a.preemptionMode != b.preemptionMode { | ||
| return a.preemptionMode > b.preemptionMode | ||
| } | ||
|
|
||
| if fungibilityConfig.Preference != nil { | ||
| switch *fungibilityConfig.Preference { | ||
| case kueue.BorrowingOverPreemption: | ||
| return preemptionOverBorrowing() | ||
| case kueue.PreemptionOverBorrowing: | ||
| return borrowingOverPreemption() | ||
| } | ||
| return a.borrowingLevel.betterThan(b.borrowingLevel) | ||
| } | ||
|
|
||
| // BorrowingOverPreemption preference | ||
| if features.Disabled(features.FlavorFungibilityImplicitPreferenceDefault) { | ||
| return borrowingOverPreemption() | ||
| } | ||
|
|
||
| // PreemptionOverBorrowing preference | ||
| if fungibilityConfig.WhenCanBorrow == kueue.TryNextFlavor { | ||
| return preemptionOverBorrowing() | ||
| } | ||
| // BorrowingOverPreemption preference | ||
| return borrowingOverPreemption() | ||
| } | ||
|
|
||
| func fromPreemptionPossibility(preemptionPossibility preemptioncommon.PreemptionPossibility) preemptionMode { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make sure aligned with the KEP