Skip to content

fix(spe): render SecurityPolicyExceptions only when the CRD exists - #231

Open
duckhawk wants to merge 1 commit into
mainfrom
fix/spe-requires-crd
Open

duckhawk wants to merge 1 commit into
mainfrom
fix/spe-requires-crd

Conversation

@duckhawk

@duckhawk duckhawk commented Nov 8, 2026 •

Copy link
Copy Markdown
Member

Description

Every SecurityPolicyException (and the pod label that refers to it) rendered by the CAPI controller manager, cloud controller manager, CSI controller and CSI node templates is now gated on deckhouse.io/v1alpha1/SecurityPolicyException being available according to helm_lib_api_version_exists (modules' CRDs in global.discovery.apiVersions or cluster discovery), together with securityPolicyExceptionEnabled. The admission-policy-engine-crd check in global.enabledModules is removed. Unit tests are updated: the API presence alone renders the object and the label, the module entry alone does not, and the label tests now assert the pod template labels instead of spec.selector.matchLabels, where the label is never set. The chart version is bumped to 1.72.35.

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

addon-operator adds <module>-crd to global.enabledModules for every enabled module that ships CRDs, so admission-policy-engine-crd is present on DKP 1.73 even though that release has no deckhouse.io/v1alpha1 SecurityPolicyException CRD. A module using these templates with securityPolicyExceptionEnabled: true then fails to install with no matches for kind "SecurityPolicyException" in version "deckhouse.io/v1alpha1". The CRD presence is the actual precondition for creating the object.

What is the expected result?

On releases without the SecurityPolicyException API neither the SecurityPolicyException nor the security.deckhouse.io/security-policy-exception pod label is rendered, and the module installs. Where the API exists, both are rendered regardless of the admission-policy-engine-crd entry.

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.

The admission-policy-engine-crd entry in global.enabledModules is not a
proof that the SecurityPolicyException API is served: addon-operator adds
<module>-crd for every enabled module that ships CRDs, so the entry is
present on releases whose admission-policy-engine has no such CRD.
Modules using the lib-helm SecurityPolicyException templates then fail to
install with "no matches for kind SecurityPolicyException".

Gate the SecurityPolicyException object and the pod label that refers to
it in the CAPI, cloud controller manager, CSI controller and CSI node
templates on the GVK alone through helm_lib_api_version_exists, instead
of the admission-policy-engine-crd entry.

The label tests asserted spec.selector.matchLabels, where the label is
never set, so the negative cases passed regardless of the guard; they now
check the pod template labels.

Signed-off-by: v.oleynikov <vasily.oleynikov@flant.com>
@duckhawk
duckhawk force-pushed the fix/spe-requires-crd branch from 37eee83 to 5d5a754 Compare November 8, 2026 16:45

This branch has not been deployed

No deployments
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.

1 participant