Skip to content

Commit

Permalink
Add feature flag to disable apiserver extra args validation
Browse files Browse the repository at this point in the history
  • Loading branch information
sp1999 committed Mar 5, 2024
1 parent 0b78dbd commit 1e0a265
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
10 changes: 6 additions & 4 deletions pkg/api/v1alpha1/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -496,10 +496,12 @@ func validateControlPlaneCertSANs(cfg *Cluster) error {
}

func validateControlPlaneAPIServerExtraArgs(clusterConfig *Cluster) error {
allowedFlags := map[string]string{"service-account-issuer": "", "service-account-jwks-uri": ""}
for k := range clusterConfig.Spec.ControlPlaneConfiguration.APIServerExtraArgs {
if _, ok := allowedFlags[k]; !ok {
return fmt.Errorf("invalid argument in ControlPlaneConfiguration.APIServerExtraArgs (service-account-issuer, service-account-jwks-uri): %v", k)
if !features.IsActive(features.ApiServerExtraArgsValidationDisabled()) {
allowedFlags := map[string]string{"service-account-issuer": "", "service-account-jwks-uri": ""}
for k := range clusterConfig.Spec.ControlPlaneConfiguration.APIServerExtraArgs {
if _, ok := allowedFlags[k]; !ok {
return fmt.Errorf("invalid argument in ControlPlaneConfiguration.APIServerExtraArgs (service-account-issuer, service-account-jwks-uri): %v", k)
}
}
}
return nil
Expand Down
19 changes: 14 additions & 5 deletions pkg/features/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package features

// These are environment variables used as flags to enable/disable features.
const (
CloudStackKubeVipDisabledEnvVar = "CLOUDSTACK_KUBE_VIP_DISABLED"
CheckpointEnabledEnvVar = "CHECKPOINT_ENABLED"
UseNewWorkflowsEnvVar = "USE_NEW_WORKFLOWS"
UseControllerForCli = "USE_CONTROLLER_FOR_CLI"
VSphereInPlaceEnvVar = "VSPHERE_IN_PLACE_UPGRADE"
CloudStackKubeVipDisabledEnvVar = "CLOUDSTACK_KUBE_VIP_DISABLED"
CheckpointEnabledEnvVar = "CHECKPOINT_ENABLED"
UseNewWorkflowsEnvVar = "USE_NEW_WORKFLOWS"
UseControllerForCli = "USE_CONTROLLER_FOR_CLI"
VSphereInPlaceEnvVar = "VSPHERE_IN_PLACE_UPGRADE"
ApiServerExtraArgsValidationDisabledEnvVar = "APISERVER_EXTRA_ARGS_VALIDATION_DISABLED"

Check warning on line 10 in pkg/features/features.go

View workflow job for this annotation

GitHub Actions / lint

var-naming: const ApiServerExtraArgsValidationDisabledEnvVar should be APIServerExtraArgsValidationDisabledEnvVar (revive)
)

func FeedGates(featureGates []string) {
Expand Down Expand Up @@ -63,3 +64,11 @@ func VSphereInPlaceUpgradeEnabled() Feature {
IsActive: globalFeatures.isActiveForEnvVar(VSphereInPlaceEnvVar),
}
}

// ApiServerExtraArgsValidationDisabled is the feature flag for disabling the API server extra args validation.
func ApiServerExtraArgsValidationDisabled() Feature {

Check warning on line 69 in pkg/features/features.go

View workflow job for this annotation

GitHub Actions / lint

var-naming: func ApiServerExtraArgsValidationDisabled should be APIServerExtraArgsValidationDisabled (revive)
return Feature{
Name: "Disable API server extra args validation",
IsActive: globalFeatures.isActiveForEnvVar(ApiServerExtraArgsValidationDisabledEnvVar),
}
}
8 changes: 8 additions & 0 deletions pkg/features/features_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,11 @@ func TestVSphereInPlaceUpgradeEnabledFeatureFlag(t *testing.T) {
g.Expect(os.Setenv(VSphereInPlaceEnvVar, "true")).To(Succeed())
g.Expect(IsActive(VSphereInPlaceUpgradeEnabled())).To(BeTrue())
}

func TestApiServerExtraArgsValidationDisabledFeatureFlag(t *testing.T) {
g := NewWithT(t)
setupContext(t)

g.Expect(os.Setenv(ApiServerExtraArgsValidationDisabledEnvVar, "true")).To(Succeed())
g.Expect(IsActive(ApiServerExtraArgsValidationDisabled())).To(BeTrue())
}

0 comments on commit 1e0a265

Please sign in to comment.