Skip to content

feat: gate all templates on storage-foundation not being enabled#72

Merged
duckhawk merged 1 commit intomainfrom
feat/coexist-with-storage-foundation
May 8, 2026
Merged

feat: gate all templates on storage-foundation not being enabled#72
duckhawk merged 1 commit intomainfrom
feat/coexist-with-storage-foundation

Conversation

@duckhawk
Copy link
Copy Markdown
Member

@duckhawk duckhawk commented May 7, 2026

Description

Wrap every Helm template under templates/ with

{{- if not (.Values.global.enabledModules | has "storage-foundation") }}
... existing body ...
{{- end }}

so the chart renders zero manifests as soon as the storage-foundation module is enabled in global.enabledModules. Templates that contain {{- define ... }} helpers (templates/snapshot-controller/deployment.yaml and templates/webhooks/deployment.yaml) keep the define block outside the gate, so the helper stays available regardless of whether the body is rendered.

No manifest content was changed — only the surrounding {{- if … }} … {{- end }} was added. When storage-foundation is not in global.enabledModules, the chart renders byte-for-byte the same output as before; when it is, helm template produces an empty result. Both cases were verified locally with helm template against this branch.

Why do we need it, and what problem does it solve?

We are migrating users from the snapshot-controller module to storage-foundation. The new module ships its own copies of the snapshot-controller Deployment, the webhooks Deployment / Service / MutatingWebhookConfiguration, the registry secret, the namespace and all RBAC. Without a hand-off mechanism, enabling storage-foundation while snapshot-controller is still on means:

  • two snapshot-controller Deployments (in d8-snapshot-controller and d8-storage-foundation) competing for the same VolumeSnapshot* objects via separate leader-election leases;
  • two MutatingWebhookConfigurations mutating every VolumeSnapshot CREATE;
  • clashing ClusterRole/ClusterRoleBinding names (d8:snapshot-controller:admin-kubeconfig, d8:user-authz:snapshot-controller:*, d8:manage:permission:module:snapshot-controller:*, d8:use:capability:module:snapshot-controller:*, d8:snapshot-controller:snapshot-controller:runner/:rbac-proxy) — these names are owned by this module, not by storage-foundation, so they wouldn't collide between releases, but they would also keep granting access to a controller that is no longer authoritative.

The companion PR deckhouse/storage-foundation#21 brings the missing RBAC, CRDs, doc-ru and the remove-finalizers-on-module-delete hook into storage-foundation, so it is safe to let it take over.

This PR is the operator-facing piece of the migration: it lets an admin enable storage-foundation first and only then disable snapshot-controller, instead of having to do both at the exact same deckhouse reconciliation tick.

What is the expected result?

  • When storage-foundation is not in .Values.global.enabledModules, helm template of this chart produces the same set of manifests as before this PR (verified for the RBAC files explicitly; smoke-rendered for the rest).
  • When storage-foundation is in .Values.global.enabledModules, helm template of this chart emits no manifests at all — verified locally:
    • the snapshot-controller Deployment, PodDisruptionBudget, VerticalPodAutoscaler, PodMonitor and ServiceAccount are not rendered;
    • the webhooks Deployment, Service, Secret, MutatingWebhookConfiguration, ServiceAccount, ClusterRole and ClusterRoleBinding are not rendered;
    • the namespace d8-snapshot-controller, the registry secrets, all RBAC roles and the user-authz / rbacv2 cluster roles are not rendered.
  • Existing clusters that do not enable storage-foundation see no behavioural change.

Checklist

  • The code is covered by unit tests.
  • e2e tests passed.
  • Documentation updated according to the changes.
  • Changes were tested in the Kubernetes cluster manually.

Wrap every Helm template in templates/ with
{{- if not (.Values.global.enabledModules | has "storage-foundation") }}
... {{- end }} so this module yields zero rendered manifests as soon as
storage-foundation is enabled. This lets the cluster admin enable
storage-foundation alongside snapshot-controller during migration
without colliding on:

  * the snapshot-controller Deployment and its leader election Lease,
  * the webhooks Deployment / Service / MutatingWebhookConfiguration,
  * shared RBAC names (admin-kubeconfig, user-authz, rbacv2/manage/use,
    runner, rbac-proxy),
  * the registry secret and module namespace.

Templates with helper {{- define ... }} blocks (snapshot-controller and
webhooks deployments) keep the define outside the gate so the helper
remains available regardless of the wrapper state.
@duckhawk duckhawk force-pushed the feat/coexist-with-storage-foundation branch from 7f0eaa1 to 974871f Compare May 8, 2026 11:39
@duckhawk duckhawk merged commit 4fd32b8 into main May 8, 2026
17 of 18 checks passed
@duckhawk duckhawk deleted the feat/coexist-with-storage-foundation branch May 8, 2026 12:20
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.

2 participants