Skip to content

Commit

Permalink
Add feature flag to configure api server extra args
Browse files Browse the repository at this point in the history
  • Loading branch information
sp1999 committed Mar 15, 2024
1 parent e544473 commit 3e8ecf5
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/api/v1alpha1/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
9 changes: 9 additions & 0 deletions pkg/features/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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),
}
}
8 changes: 8 additions & 0 deletions pkg/features/features_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
2 changes: 2 additions & 0 deletions test/e2e/cloudstack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions test/e2e/vsphere_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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,
Expand Down

0 comments on commit 3e8ecf5

Please sign in to comment.