feat: gate all templates on storage-foundation not being enabled#72
Merged
feat: gate all templates on storage-foundation not being enabled#72
Conversation
4 tasks
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.
7f0eaa1 to
974871f
Compare
szhem
approved these changes
May 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Wrap every Helm template under
templates/withso the chart renders zero manifests as soon as the
storage-foundationmodule is enabled inglobal.enabledModules. Templates that contain{{- define ... }}helpers (templates/snapshot-controller/deployment.yamlandtemplates/webhooks/deployment.yaml) keep thedefineblock 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. Whenstorage-foundationis not inglobal.enabledModules, the chart renders byte-for-byte the same output as before; when it is,helm templateproduces an empty result. Both cases were verified locally withhelm templateagainst this branch.Why do we need it, and what problem does it solve?
We are migrating users from the
snapshot-controllermodule tostorage-foundation. The new module ships its own copies of the snapshot-controllerDeployment, the webhooksDeployment/Service/MutatingWebhookConfiguration, the registry secret, the namespace and all RBAC. Without a hand-off mechanism, enablingstorage-foundationwhilesnapshot-controlleris still on means:snapshot-controllerDeployments(ind8-snapshot-controllerandd8-storage-foundation) competing for the sameVolumeSnapshot*objects via separate leader-election leases;MutatingWebhookConfigurations mutating everyVolumeSnapshotCREATE;ClusterRole/ClusterRoleBindingnames (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 bystorage-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-deletehook intostorage-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-foundationfirst and only then disablesnapshot-controller, instead of having to do both at the exact samedeckhousereconciliation tick.What is the expected result?
storage-foundationis not in.Values.global.enabledModules,helm templateof this chart produces the same set of manifests as before this PR (verified for the RBAC files explicitly; smoke-rendered for the rest).storage-foundationis in.Values.global.enabledModules,helm templateof this chart emits no manifests at all — verified locally:snapshot-controllerDeployment,PodDisruptionBudget,VerticalPodAutoscaler,PodMonitorandServiceAccountare not rendered;webhooksDeployment,Service,Secret,MutatingWebhookConfiguration,ServiceAccount,ClusterRoleandClusterRoleBindingare not rendered;d8-snapshot-controller, the registry secrets, all RBAC roles and the user-authz / rbacv2 cluster roles are not rendered.storage-foundationsee no behavioural change.Checklist