generated from kubernetes/kubernetes-template-project
-
Notifications
You must be signed in to change notification settings - Fork 228
/
kube_features.go
141 lines (120 loc) · 5 KB
/
kube_features.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/*
Copyright 2023 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package features
import (
"fmt"
"testing"
"github.com/go-logr/logr"
"k8s.io/apimachinery/pkg/util/runtime"
utilfeature "k8s.io/apiserver/pkg/util/feature"
"k8s.io/component-base/featuregate"
featuregatetesting "k8s.io/component-base/featuregate/testing"
)
const (
// owner: @trasc
// kep: https://github.com/kubernetes-sigs/kueue/tree/main/keps/420-partial-admission
// alpha: v0.4
// beta: v0.5
//
// Enables partial admission.
PartialAdmission featuregate.Feature = "PartialAdmission"
// owner: @stuton
// kep: https://github.com/kubernetes-sigs/kueue/tree/main/keps/168-pending-workloads-visibility
// alpha: v0.5
//
// Enables queue visibility.
QueueVisibility featuregate.Feature = "QueueVisibility"
// owner: @KunWuLuan
// kep: https://github.com/kubernetes-sigs/kueue/tree/main/keps/582-preempt-based-on-flavor-order
// beta: v0.5
//
// Enables flavor fungibility.
FlavorFungibility featuregate.Feature = "FlavorFungibility"
// owner: @trasc
// kep: https://github.com/kubernetes-sigs/kueue/tree/main/keps/1136-provisioning-request-support
// alpha: v0.5
//
// Enables Provisioning Admission Check Controller.
ProvisioningACC featuregate.Feature = "ProvisioningACC"
// owner: @pbundyra
// kep: https://github.com/kubernetes-sigs/kueue/pull/1300
// alpha: v0.6
//
// Enables Kueue visibility on demand
VisibilityOnDemand featuregate.Feature = "VisibilityOnDemand"
// owner: @yaroslava-serdiuk
// kep: https://github.com/kubernetes-sigs/kueue/issues/1283
// beta: v0.6
//
// Enable priority sorting within the cohort.
PrioritySortingWithinCohort featuregate.Feature = "PrioritySortingWithinCohort"
// owner: @trasc
// kep: https://github.com/kubernetes-sigs/kueue/tree/main/keps/693-multikueue
// alpha: v0.6
//
// Enables MultiKueue support.
MultiKueue featuregate.Feature = "MultiKueue"
// owners: @B1F030, @kerthcet
// kep: https://github.com/kubernetes-sigs/kueue/tree/main/keps/1224-lending-limit
// alpha: v0.6
//
// Enables lending limit.
LendingLimit featuregate.Feature = "LendingLimit"
// owner: @trasc
// alpha: v0.8
//
// Enable the usage of batch.Job spec.managedBy field its MultiKueue integration.
MultiKueueBatchJobWithManagedBy featuregate.Feature = "MultiKueueBatchJobWithManagedBy"
)
func init() {
runtime.Must(utilfeature.DefaultMutableFeatureGate.Add(defaultFeatureGates))
}
// defaultFeatureGates consists of all known Kueue-specific feature keys.
// To add a new feature, define a key for it above and add it here. The features will be
// available throughout Kueue binaries.
//
// Entries are separated from each other with blank lines to avoid sweeping gofmt changes
// when adding or removing one entry.
var defaultFeatureGates = map[featuregate.Feature]featuregate.FeatureSpec{
PartialAdmission: {Default: true, PreRelease: featuregate.Beta},
QueueVisibility: {Default: false, PreRelease: featuregate.Alpha},
FlavorFungibility: {Default: true, PreRelease: featuregate.Beta},
ProvisioningACC: {Default: true, PreRelease: featuregate.Beta},
VisibilityOnDemand: {Default: false, PreRelease: featuregate.Alpha},
PrioritySortingWithinCohort: {Default: true, PreRelease: featuregate.Beta},
MultiKueue: {Default: false, PreRelease: featuregate.Alpha},
LendingLimit: {Default: false, PreRelease: featuregate.Alpha},
MultiKueueBatchJobWithManagedBy: {Default: false, PreRelease: featuregate.Alpha},
}
func SetFeatureGateDuringTest(tb testing.TB, f featuregate.Feature, value bool) func() {
return featuregatetesting.SetFeatureGateDuringTest(tb, utilfeature.DefaultFeatureGate, f, value)
}
// Enabled is helper for `utilfeature.DefaultFeatureGate.Enabled()`
func Enabled(f featuregate.Feature) bool {
return utilfeature.DefaultFeatureGate.Enabled(f)
}
// 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
func SetEnable(f featuregate.Feature, v bool) error {
return utilfeature.DefaultMutableFeatureGate.Set(fmt.Sprintf("%s=%v", f, v))
}
func LogFeatureGates(log logr.Logger) {
features := make(map[featuregate.Feature]bool, len(defaultFeatureGates))
for f := range utilfeature.DefaultMutableFeatureGate.GetAll() {
if _, ok := defaultFeatureGates[f]; ok {
features[f] = Enabled(f)
}
}
log.V(2).Info("Loaded feature gates", "featureGates", features)
}