From 3e8ecf5ba4829ccf66427cd4d06aba3bb79bb43d Mon Sep 17 00:00:00 2001 From: Saurabh Parekh Date: Thu, 14 Mar 2024 00:42:13 -0700 Subject: [PATCH] Add feature flag to configure api server extra args --- pkg/api/v1alpha1/cluster.go | 8 ++++++++ pkg/features/features.go | 9 +++++++++ pkg/features/features_test.go | 8 ++++++++ test/e2e/cloudstack_test.go | 2 ++ test/e2e/vsphere_test.go | 2 ++ 5 files changed, 29 insertions(+) diff --git a/pkg/api/v1alpha1/cluster.go b/pkg/api/v1alpha1/cluster.go index 578c43c2a8b17..f3e886e320ee2 100644 --- a/pkg/api/v1alpha1/cluster.go +++ b/pkg/api/v1alpha1/cluster.go @@ -190,6 +190,7 @@ var clusterConfigValidations = []func(*Cluster) error{ validatePackageControllerConfiguration, validateEksaVersion, validateControlPlaneCertSANs, + validateControlPlaneAPIServerExtraArgs, } // GetClusterConfig parses a Cluster object from a multiobject yaml file in disk @@ -494,6 +495,13 @@ func validateControlPlaneCertSANs(cfg *Cluster) error { return nil } +func validateControlPlaneAPIServerExtraArgs(clusterConfig *Cluster) error { + if clusterConfig.Spec.ControlPlaneConfiguration.APIServerExtraArgs != nil && !features.IsActive(features.APIServerExtraArgsEnabled()) { + return errors.New("please enable feature flag to configure APIServerExtraArgs") + } + return nil +} + func validateWorkerNodeGroups(clusterConfig *Cluster) error { workerNodeGroupConfigs := clusterConfig.Spec.WorkerNodeGroupConfigurations if len(workerNodeGroupConfigs) <= 0 { diff --git a/pkg/features/features.go b/pkg/features/features.go index c462ca73da2f7..7cb88ec06d587 100644 --- a/pkg/features/features.go +++ b/pkg/features/features.go @@ -7,6 +7,7 @@ const ( UseNewWorkflowsEnvVar = "USE_NEW_WORKFLOWS" UseControllerForCli = "USE_CONTROLLER_FOR_CLI" VSphereInPlaceEnvVar = "VSPHERE_IN_PLACE_UPGRADE" + APIServerExtraArgsEnabledEnvVar = "API_SERVER_EXTRA_ARGS_ENABLED" ) func FeedGates(featureGates []string) { @@ -55,3 +56,11 @@ func VSphereInPlaceUpgradeEnabled() Feature { IsActive: globalFeatures.isActiveForEnvVar(VSphereInPlaceEnvVar), } } + +// APIServerExtraArgsEnabled is the feature flag for configuring api server extra args. +func APIServerExtraArgsEnabled() Feature { + return Feature{ + Name: "Configure api server extra args", + IsActive: globalFeatures.isActiveForEnvVar(APIServerExtraArgsEnabledEnvVar), + } +} diff --git a/pkg/features/features_test.go b/pkg/features/features_test.go index de3a262f8801d..739d5f4c146c4 100644 --- a/pkg/features/features_test.go +++ b/pkg/features/features_test.go @@ -77,3 +77,11 @@ func TestVSphereInPlaceUpgradeEnabledFeatureFlag(t *testing.T) { g.Expect(os.Setenv(VSphereInPlaceEnvVar, "true")).To(Succeed()) g.Expect(IsActive(VSphereInPlaceUpgradeEnabled())).To(BeTrue()) } + +func TestAPIServerExtraArgsEnabledFeatureFlag(t *testing.T) { + g := NewWithT(t) + setupContext(t) + + g.Expect(os.Setenv(APIServerExtraArgsEnabledEnvVar, "true")).To(Succeed()) + g.Expect(IsActive(APIServerExtraArgsEnabled())).To(BeTrue()) +} diff --git a/test/e2e/cloudstack_test.go b/test/e2e/cloudstack_test.go index 192cb2d97832c..560a4f96b3b62 100644 --- a/test/e2e/cloudstack_test.go +++ b/test/e2e/cloudstack_test.go @@ -22,6 +22,7 @@ func TestCloudStackKubernetes129RedHat8APIServerExtraArgsSimpleFlow(t *testing.T test := framework.NewClusterE2ETest( t, framework.NewCloudStack(t, framework.WithCloudStackRedhat129()), + framework.WithEnvVar(features.APIServerExtraArgsEnabledEnvVar, "true"), ).WithClusterConfig( api.ClusterToConfigFiller( api.WithKubernetesVersion(v1alpha1.Kube129), @@ -39,6 +40,7 @@ func TestCloudStackKubernetes129Redhat8APIServerExtraArgsUpgradeFlow(t *testing. t, framework.NewCloudStack(t, framework.WithCloudStackRedhat129()), framework.WithClusterFiller(api.WithKubernetesVersion(v1alpha1.Kube129)), + framework.WithEnvVar(features.APIServerExtraArgsEnabledEnvVar, "true"), ) addAPIServerExtraArgsclusterOpts = append( addAPIServerExtraArgsclusterOpts, diff --git a/test/e2e/vsphere_test.go b/test/e2e/vsphere_test.go index 162aea62fb725..53b31606bd71f 100644 --- a/test/e2e/vsphere_test.go +++ b/test/e2e/vsphere_test.go @@ -23,6 +23,7 @@ func TestVSphereKubernetes129BottlerocketAPIServerExtraArgsSimpleFlow(t *testing test := framework.NewClusterE2ETest( t, framework.NewVSphere(t, framework.WithBottleRocket129()), + framework.WithEnvVar(features.APIServerExtraArgsEnabledEnvVar, "true"), ).WithClusterConfig( api.ClusterToConfigFiller( api.WithKubernetesVersion(v1alpha1.Kube129), @@ -40,6 +41,7 @@ func TestVSphereKubernetes129BottlerocketAPIServerExtraArgsUpgradeFlow(t *testin t, framework.NewVSphere(t, framework.WithBottleRocket129()), framework.WithClusterFiller(api.WithKubernetesVersion(v1alpha1.Kube129)), + framework.WithEnvVar(features.APIServerExtraArgsEnabledEnvVar, "true"), ) addAPIServerExtraArgsclusterOpts = append( addAPIServerExtraArgsclusterOpts,