Skip to content

Commit

Permalink
Add PriorityQueue feature gate
Browse files Browse the repository at this point in the history
  • Loading branch information
sbueringer committed Jan 20, 2025
1 parent 8c4355e commit 7b21251
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 4 deletions.
2 changes: 1 addition & 1 deletion config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ spec:
- "--diagnostics-address=${CAPI_DIAGNOSTICS_ADDRESS:=:8443}"
- "--insecure-diagnostics=${CAPI_INSECURE_DIAGNOSTICS:=false}"
- --v=4
- "--feature-gates=NodeAntiAffinity=${EXP_NODE_ANTI_AFFINITY:=false},NamespaceScopedZones=${EXP_NAMESPACE_SCOPED_ZONES:=false}"
- "--feature-gates=NodeAntiAffinity=${EXP_NODE_ANTI_AFFINITY:=false},NamespaceScopedZones=${EXP_NAMESPACE_SCOPED_ZONES:=false},PriorityQueue=${EXP_PRIORITY_QUEUE:=false}"
image: controller:latest
imagePullPolicy: IfNotPresent
name: manager
Expand Down
5 changes: 5 additions & 0 deletions controllers/vmware/test/controllers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
"sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/config"
"sigs.k8s.io/controller-runtime/pkg/controller"
ctrlmgr "sigs.k8s.io/controller-runtime/pkg/manager"
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
Expand All @@ -46,6 +47,7 @@ import (
vmwarev1 "sigs.k8s.io/cluster-api-provider-vsphere/apis/vmware/v1beta1"
"sigs.k8s.io/cluster-api-provider-vsphere/controllers"
"sigs.k8s.io/cluster-api-provider-vsphere/controllers/vmware"
"sigs.k8s.io/cluster-api-provider-vsphere/feature"
vmwarewebhooks "sigs.k8s.io/cluster-api-provider-vsphere/internal/webhooks/vmware"
"sigs.k8s.io/cluster-api-provider-vsphere/pkg/constants"
capvcontext "sigs.k8s.io/cluster-api-provider-vsphere/pkg/context"
Expand Down Expand Up @@ -222,6 +224,9 @@ func getManager(cfg *rest.Config, networkProvider string, withWebhooks bool) man

opts := manager.Options{
Options: ctrlmgr.Options{
Controller: config.Controller{
UsePriorityQueue: ptr.To[bool](feature.Gates.Enabled(feature.PriorityQueue)),
},
Scheme: localScheme,
NewCache: func(config *rest.Config, opts cache.Options) (cache.Cache, error) {
syncPeriod := 1 * time.Second
Expand Down
7 changes: 7 additions & 0 deletions feature/feature.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ const (
//
// alpha: v1.11
NamespaceScopedZones featuregate.Feature = "NamespaceScopedZones"

// PriorityQueue is a feature gate that controls if the controller uses the controller-runtime PriorityQueue
// instead of the default queue implementation.
//
// alpha: v1.10
PriorityQueue featuregate.Feature = "PriorityQueue"
)

func init() {
Expand All @@ -50,4 +56,5 @@ var defaultCAPVFeatureGates = map[featuregate.Feature]featuregate.FeatureSpec{
// Every feature should be initiated here:
NodeAntiAffinity: {Default: false, PreRelease: featuregate.Alpha},
NamespaceScopedZones: {Default: false, PreRelease: featuregate.Alpha},
PriorityQueue: {Default: false, PreRelease: featuregate.Alpha},
}
6 changes: 6 additions & 0 deletions internal/test/helpers/envtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,19 @@ import (
"k8s.io/component-base/logs"
logsv1 "k8s.io/component-base/logs/api/v1"
"k8s.io/klog/v2"
"k8s.io/utils/ptr"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
"sigs.k8s.io/cluster-api/util/kubeconfig"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/config"
"sigs.k8s.io/controller-runtime/pkg/envtest"
ctrlmgr "sigs.k8s.io/controller-runtime/pkg/manager"
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
"sigs.k8s.io/controller-runtime/pkg/webhook"

infrav1 "sigs.k8s.io/cluster-api-provider-vsphere/apis/v1beta1"
"sigs.k8s.io/cluster-api-provider-vsphere/feature"
"sigs.k8s.io/cluster-api-provider-vsphere/internal/test/helpers/vcsim"
"sigs.k8s.io/cluster-api-provider-vsphere/internal/webhooks"
capvcontext "sigs.k8s.io/cluster-api-provider-vsphere/pkg/context"
Expand Down Expand Up @@ -171,6 +174,9 @@ func NewTestEnvironment(ctx context.Context) *TestEnvironment {

managerOpts := manager.Options{
Options: ctrl.Options{
Controller: config.Controller{
UsePriorityQueue: ptr.To[bool](feature.Gates.Enabled(feature.PriorityQueue)),
},
Scheme: scheme,
Metrics: metricsserver.Options{
BindAddress: "0",
Expand Down
5 changes: 5 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (
logsv1 "k8s.io/component-base/logs/api/v1"
_ "k8s.io/component-base/logs/json/register"
"k8s.io/klog/v2"
"k8s.io/utils/ptr"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
"sigs.k8s.io/cluster-api/controllers/clustercache"
"sigs.k8s.io/cluster-api/controllers/remote"
Expand All @@ -47,6 +48,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/config"
"sigs.k8s.io/controller-runtime/pkg/controller"
ctrlmgr "sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/webhook"
Expand Down Expand Up @@ -327,6 +329,9 @@ func main() {
managerOpts.WebhookServer = webhook.NewServer(webhookOpts)
managerOpts.AddToManager = addToManager
managerOpts.Metrics = *metricsOptions
managerOpts.Controller = config.Controller{
UsePriorityQueue: ptr.To[bool](feature.Gates.Enabled(feature.PriorityQueue)),
}

// Set up the context that's going to be used in controllers and for the manager.
ctx := ctrl.SetupSignalHandler()
Expand Down
7 changes: 4 additions & 3 deletions test/e2e/config/vsphere.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,6 @@ variables:
CPI_IMAGE_K8S_VERSION: "v1.32.1"
CNI: "./data/cni/calico/calico.yaml"
AUTOSCALER_WORKLOAD: "./data/autoscaler/autoscaler-to-management-workload.yaml"
EXP_CLUSTER_RESOURCE_SET: "true"
EXP_KUBEADM_BOOTSTRAP_FORMAT_IGNITION: "true"
CONTROL_PLANE_MACHINE_COUNT: 1
WORKER_MACHINE_COUNT: 1
IP_FAMILY: "IPv4"
Expand Down Expand Up @@ -343,14 +341,17 @@ variables:
FLATCAR_VSPHERE_TEMPLATE: "flatcar-stable-4081.2.0-kube-v1.32.0"
KUBETEST_CONFIGURATION: "./data/kubetest/conformance.yaml"
NODE_DRAIN_TIMEOUT: "60s"
EXP_CLUSTER_RESOURCE_SET: "true"
EXP_KUBEADM_BOOTSTRAP_FORMAT_IGNITION: "true"
CLUSTER_TOPOLOGY: "true"
EXP_RUNTIME_SDK: "true"
EXP_MACHINE_SET_PREFLIGHT_CHECKS: "true"
EXP_PRIORITY_QUEUE: "false"
# These IDs correspond to Tesla T4s, they are the decimal representation of the hex values.
DEVICE_ID: 7864
VENDOR_ID: 4318
# CAPV feature flags
EXP_NODE_ANTI_AFFINITY: "true"
EXP_MACHINE_SET_PREFLIGHT_CHECKS: "true"
EXP_NAMESPACE_SCOPED_ZONE: "false"
CAPI_DIAGNOSTICS_ADDRESS: ":8080"
CAPI_INSECURE_DIAGNOSTICS: "true"
Expand Down

0 comments on commit 7b21251

Please sign in to comment.