Skip to content

CSPL-4630: add feature gate infrastructure using k8s FeatureGate pattern#1848

Open
kubabuczak wants to merge 4 commits intodevelopfrom
CSPL-4630-feature-gate-infrastructure
Open

CSPL-4630: add feature gate infrastructure using k8s FeatureGate pattern#1848
kubabuczak wants to merge 4 commits intodevelopfrom
CSPL-4630-feature-gate-infrastructure

Conversation

@kubabuczak
Copy link
Copy Markdown
Collaborator

Description

Add a feature gate registry using k8s.io/component-base/featuregate so new controllers can be gated behind --feature-gates=<Gate>=true|false with Alpha/Beta/GA lifecycle. Migrate the validation webhook toggle from the ENABLE_VALIDATION_WEBHOOK env var to a ValidationWebhook feature gate with backwards-compatible env var support.

Key Changes

  • Feature gate registry in pkg/config/ with ValidationWebhook gate (Alpha, off by default) and legacy env var bridge
  • Migrate cmd/main.go from flag to pflag and wire --feature-gates CLI flag
  • Update webhook kustomize overlays to use container args instead of env var
  • Add docs/FeatureGates.md with 4-step checklist for adding new gates
  • Update docs/ValidationWebhook.md to reflect feature gate enablement

Testing and Verification

  • Unit tests cover gate registration, default-off behavior, and all three legacy env var paths (set to "true", unset, set to "false")
  • Existing flags behave identically after the flagpflag migration (1:1 rename)

Related Issues

PR Checklist

  • Code changes adhere to the project's coding standards
  • Relevant unit and integration tests are included
  • Documentation has been updated accordingly
  • If test framework files were changed (test/testenv/, test/run-tests.sh, test/env.sh), docs/IntegrationTesting.md has been updated
  • All tests pass locally
  • The PR description follows the project's guidelines

Introduce a feature gate registry backed by k8s.io/component-base/featuregate
so new capabilities can be gated behind --feature-gates=<Gate>=true|false with
Alpha/Beta/GA lifecycle. Migrate the validation webhook toggle from the
ENABLE_VALIDATION_WEBHOOK env var to a ValidationWebhook feature gate with
backwards-compatible env var support.
Remove non-existent Helm values snippet from FeatureGates.md, add
CLI-over-env-var precedence note to ValidationWebhook.md, and log
effective gate states instead of just known feature names.
Use os.LookupEnv instead of checking for exact "true" so the
deprecation warning fires whenever the env var is set.
Comment thread docs/FeatureGates.md Outdated

## Adding a New Feature Gate

Follow these four steps:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like there are only steps 1-2 and then some examples or optional steps for new controllers. Can we update this to reflect that?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Fixed!

@vivekr-splunk vivekr-splunk self-requested a review April 17, 2026 00:18
Copy link
Copy Markdown
Collaborator

@vivekr-splunk vivekr-splunk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few follow-up doc issues after the feature-gate refactor.

Comment thread docs/ValidationWebhook.md

```bash
# Build and apply the webhook-enabled configuration
kustomize build config/default-with-webhook | kubectl apply -f -
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example still renders placeholder values like WATCH_NAMESPACE_VALUE, SPLUNK_ENTERPRISE_IMAGE, and SPLUNK_GENERAL_TERMS_VALUE directly into the manifest. Unlike the config/default flow, there is not a make target here doing the sed substitutions first, so kustomize build config/default-with-webhook is not actually ready to apply as-is. Can we either document the required replacements here or switch the example to a supported path that produces a fully rendered manifest?

Comment thread docs/ValidationWebhook.md
```bash
kubectl logs -n splunk-operator deployment/splunk-operator-controller-manager | grep -i webhook
# Look for: "Validation webhook enabled via ENABLE_VALIDATION_WEBHOOK=true"
# Look for: "Validation webhook enabled via feature gate"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The troubleshooting text here says to grep for "Validation webhook enabled via feature gate", but cmd/main.go now logs "Validation webhook enabled". Can we update one side or the other so users are not searching for a string that never appears?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants