Skip to content

Commit 6979dbe

Browse files
authored
Merge pull request #11698 from sbueringer/pr-priority-queue-fg
✨ Add PriorityQueue feature gate
2 parents 99e9a26 + 5e5909d commit 6979dbe

File tree

16 files changed

+54
-4
lines changed

16 files changed

+54
-4
lines changed

bootstrap/kubeadm/config/manager/manager.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ spec:
2222
- "--leader-elect"
2323
- "--diagnostics-address=${CAPI_DIAGNOSTICS_ADDRESS:=:8443}"
2424
- "--insecure-diagnostics=${CAPI_INSECURE_DIAGNOSTICS:=false}"
25-
- "--feature-gates=MachinePool=${EXP_MACHINE_POOL:=true},KubeadmBootstrapFormatIgnition=${EXP_KUBEADM_BOOTSTRAP_FORMAT_IGNITION:=false}"
25+
- "--feature-gates=MachinePool=${EXP_MACHINE_POOL:=true},KubeadmBootstrapFormatIgnition=${EXP_KUBEADM_BOOTSTRAP_FORMAT_IGNITION:=false},PriorityQueue=${EXP_PRIORITY_QUEUE:=false}"
2626
- "--bootstrap-token-ttl=${KUBEADM_BOOTSTRAP_TOKEN_TTL:=15m}"
2727
image: controller:latest
2828
name: manager

bootstrap/kubeadm/main.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@ import (
3737
logsv1 "k8s.io/component-base/logs/api/v1"
3838
_ "k8s.io/component-base/logs/json/register"
3939
"k8s.io/klog/v2"
40+
"k8s.io/utils/ptr"
4041
ctrl "sigs.k8s.io/controller-runtime"
4142
"sigs.k8s.io/controller-runtime/pkg/cache"
4243
"sigs.k8s.io/controller-runtime/pkg/client"
44+
"sigs.k8s.io/controller-runtime/pkg/config"
4345
"sigs.k8s.io/controller-runtime/pkg/controller"
4446
"sigs.k8s.io/controller-runtime/pkg/webhook"
4547

@@ -226,6 +228,9 @@ func main() {
226228
clusterSecretCacheSelector := labels.NewSelector().Add(*req)
227229

228230
ctrlOptions := ctrl.Options{
231+
Controller: config.Controller{
232+
UsePriorityQueue: ptr.To[bool](feature.Gates.Enabled(feature.PriorityQueue)),
233+
},
229234
Scheme: scheme,
230235
LeaderElection: enableLeaderElection,
231236
LeaderElectionID: "kubeadm-bootstrap-manager-leader-election-capi",

config/manager/manager.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ spec:
2424
- "--diagnostics-address=${CAPI_DIAGNOSTICS_ADDRESS:=:8443}"
2525
- "--insecure-diagnostics=${CAPI_INSECURE_DIAGNOSTICS:=false}"
2626
- "--use-deprecated-infra-machine-naming=${CAPI_USE_DEPRECATED_INFRA_MACHINE_NAMING:=false}"
27-
- "--feature-gates=MachinePool=${EXP_MACHINE_POOL:=true},ClusterResourceSet=${EXP_CLUSTER_RESOURCE_SET:=true},ClusterTopology=${CLUSTER_TOPOLOGY:=false},RuntimeSDK=${EXP_RUNTIME_SDK:=false},MachineSetPreflightChecks=${EXP_MACHINE_SET_PREFLIGHT_CHECKS:=true},MachineWaitForVolumeDetachConsiderVolumeAttachments=${EXP_MACHINE_WAITFORVOLUMEDETACH_CONSIDER_VOLUMEATTACHMENTS:=true}"
27+
- "--feature-gates=MachinePool=${EXP_MACHINE_POOL:=true},ClusterResourceSet=${EXP_CLUSTER_RESOURCE_SET:=true},ClusterTopology=${CLUSTER_TOPOLOGY:=false},RuntimeSDK=${EXP_RUNTIME_SDK:=false},MachineSetPreflightChecks=${EXP_MACHINE_SET_PREFLIGHT_CHECKS:=true},MachineWaitForVolumeDetachConsiderVolumeAttachments=${EXP_MACHINE_WAITFORVOLUMEDETACH_CONSIDER_VOLUMEATTACHMENTS:=true},PriorityQueue=${EXP_PRIORITY_QUEUE:=false}"
2828
image: controller:latest
2929
name: manager
3030
env:

controlplane/kubeadm/config/manager/manager.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ spec:
2323
- "--diagnostics-address=${CAPI_DIAGNOSTICS_ADDRESS:=:8443}"
2424
- "--insecure-diagnostics=${CAPI_INSECURE_DIAGNOSTICS:=false}"
2525
- "--use-deprecated-infra-machine-naming=${CAPI_USE_DEPRECATED_INFRA_MACHINE_NAMING:=false}"
26-
- "--feature-gates=MachinePool=${EXP_MACHINE_POOL:=true},ClusterTopology=${CLUSTER_TOPOLOGY:=false},KubeadmBootstrapFormatIgnition=${EXP_KUBEADM_BOOTSTRAP_FORMAT_IGNITION:=false}"
26+
- "--feature-gates=MachinePool=${EXP_MACHINE_POOL:=true},ClusterTopology=${CLUSTER_TOPOLOGY:=false},KubeadmBootstrapFormatIgnition=${EXP_KUBEADM_BOOTSTRAP_FORMAT_IGNITION:=false},PriorityQueue=${EXP_PRIORITY_QUEUE:=false}"
2727
image: controller:latest
2828
name: manager
2929
env:

controlplane/kubeadm/main.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,11 @@ import (
4141
logsv1 "k8s.io/component-base/logs/api/v1"
4242
_ "k8s.io/component-base/logs/json/register"
4343
"k8s.io/klog/v2"
44+
"k8s.io/utils/ptr"
4445
ctrl "sigs.k8s.io/controller-runtime"
4546
"sigs.k8s.io/controller-runtime/pkg/cache"
4647
"sigs.k8s.io/controller-runtime/pkg/client"
48+
"sigs.k8s.io/controller-runtime/pkg/config"
4749
"sigs.k8s.io/controller-runtime/pkg/controller"
4850
"sigs.k8s.io/controller-runtime/pkg/webhook"
4951

@@ -252,6 +254,9 @@ func main() {
252254
clusterSecretCacheSelector := labels.NewSelector().Add(*req)
253255

254256
ctrlOptions := ctrl.Options{
257+
Controller: config.Controller{
258+
UsePriorityQueue: ptr.To[bool](feature.Gates.Enabled(feature.PriorityQueue)),
259+
},
255260
Scheme: scheme,
256261
LeaderElection: enableLeaderElection,
257262
LeaderElectionID: "kubeadm-control-plane-manager-leader-election-capi",

docs/book/src/tasks/experimental-features/experimental-features.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Currently Cluster API has the following experimental features:
77
* `ClusterResourceSet` (env var: `EXP_CLUSTER_RESOURCE_SET`): [ClusterResourceSet](./cluster-resource-set.md)
88
* `MachinePool` (env var: `EXP_MACHINE_POOL`): [MachinePools](./machine-pools.md)
99
* `MachineSetPreflightChecks` (env var: `EXP_MACHINE_SET_PREFLIGHT_CHECKS`): [MachineSetPreflightChecks](./machineset-preflight-checks.md)
10+
* `PriorityQueue` (env var: `EXP_PRIORITY_QUEUE`): Enables the usage of the controller-runtime PriorityQueue: https://github.com/kubernetes-sigs/controller-runtime/issues/2374
1011
* `MachineWaitForVolumeDetachConsiderVolumeAttachments` (env var: `EXP_MACHINE_WAITFORVOLUMEDETACH_CONSIDER_VOLUMEATTACHMENTS`):
1112
* During Machine drain the Machine controller waits for volumes to be detached. Per default, the controller considers
1213
`Nodes.status.volumesAttached` and `VolumesAttachments`. This feature flag allows to opt-out from considering `VolumeAttachments`.

feature/feature.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ const (
6868
//
6969
// beta: v1.9
7070
MachineWaitForVolumeDetachConsiderVolumeAttachments featuregate.Feature = "MachineWaitForVolumeDetachConsiderVolumeAttachments"
71+
72+
// PriorityQueue is a feature gate that controls if the controller uses the controller-runtime PriorityQueue
73+
// instead of the default queue implementation.
74+
//
75+
// alpha: v1.10
76+
PriorityQueue featuregate.Feature = "PriorityQueue"
7177
)
7278

7379
func init() {
@@ -82,6 +88,7 @@ var defaultClusterAPIFeatureGates = map[featuregate.Feature]featuregate.FeatureS
8288
MachinePool: {Default: true, PreRelease: featuregate.Beta},
8389
MachineSetPreflightChecks: {Default: true, PreRelease: featuregate.Beta},
8490
MachineWaitForVolumeDetachConsiderVolumeAttachments: {Default: true, PreRelease: featuregate.Beta},
91+
PriorityQueue: {Default: false, PreRelease: featuregate.Alpha},
8592
ClusterTopology: {Default: false, PreRelease: featuregate.Alpha},
8693
KubeadmBootstrapFormatIgnition: {Default: false, PreRelease: featuregate.Alpha},
8794
RuntimeSDK: {Default: false, PreRelease: featuregate.Alpha},

internal/test/envtest/environment.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@ import (
4444
"k8s.io/component-base/logs"
4545
logsv1 "k8s.io/component-base/logs/api/v1"
4646
"k8s.io/klog/v2"
47+
"k8s.io/utils/ptr"
4748
ctrl "sigs.k8s.io/controller-runtime"
4849
"sigs.k8s.io/controller-runtime/pkg/client"
50+
"sigs.k8s.io/controller-runtime/pkg/config"
4951
"sigs.k8s.io/controller-runtime/pkg/envtest"
5052
"sigs.k8s.io/controller-runtime/pkg/manager"
5153
"sigs.k8s.io/controller-runtime/pkg/metrics"
@@ -65,6 +67,7 @@ import (
6567
expipamwebhooks "sigs.k8s.io/cluster-api/exp/ipam/webhooks"
6668
runtimev1 "sigs.k8s.io/cluster-api/exp/runtime/api/v1alpha1"
6769
expapiwebhooks "sigs.k8s.io/cluster-api/exp/webhooks"
70+
"sigs.k8s.io/cluster-api/feature"
6871
internalwebhooks "sigs.k8s.io/cluster-api/internal/webhooks"
6972
runtimewebhooks "sigs.k8s.io/cluster-api/internal/webhooks/runtime"
7073
"sigs.k8s.io/cluster-api/util/kubeconfig"
@@ -286,6 +289,9 @@ func newEnvironment(uncachedObjs ...client.Object) *Environment {
286289
}
287290

288291
options := manager.Options{
292+
Controller: config.Controller{
293+
UsePriorityQueue: ptr.To[bool](feature.Gates.Enabled(feature.PriorityQueue)),
294+
},
289295
Scheme: scheme.Scheme,
290296
Metrics: metricsserver.Options{
291297
BindAddress: "0",

main.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,11 @@ import (
4242
logsv1 "k8s.io/component-base/logs/api/v1"
4343
_ "k8s.io/component-base/logs/json/register"
4444
"k8s.io/klog/v2"
45+
"k8s.io/utils/ptr"
4546
ctrl "sigs.k8s.io/controller-runtime"
4647
"sigs.k8s.io/controller-runtime/pkg/cache"
4748
"sigs.k8s.io/controller-runtime/pkg/client"
49+
"sigs.k8s.io/controller-runtime/pkg/config"
4850
"sigs.k8s.io/controller-runtime/pkg/controller"
4951
"sigs.k8s.io/controller-runtime/pkg/webhook"
5052

@@ -332,6 +334,9 @@ func main() {
332334
clusterSecretCacheSelector := labels.NewSelector().Add(*req)
333335

334336
ctrlOptions := ctrl.Options{
337+
Controller: config.Controller{
338+
UsePriorityQueue: ptr.To[bool](feature.Gates.Enabled(feature.PriorityQueue)),
339+
},
335340
Scheme: scheme,
336341
LeaderElection: enableLeaderElection,
337342
LeaderElectionID: "controller-leader-election-capi",

test/e2e/config/docker.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ variables:
401401
CLUSTER_TOPOLOGY: "true"
402402
EXP_RUNTIME_SDK: "true"
403403
EXP_MACHINE_SET_PREFLIGHT_CHECKS: "true"
404+
EXP_PRIORITY_QUEUE: "false"
404405
CAPI_DIAGNOSTICS_ADDRESS: ":8080"
405406
CAPI_INSECURE_DIAGNOSTICS: "true"
406407

0 commit comments

Comments
 (0)