Skip to content

Remove redundant Helm templating from networkpolicy.yaml bundle manifest - #1707

Closed
dislbenn wants to merge 1 commit into
stolostron:mainfrom
dislbenn:release-5.0
Closed

Remove redundant Helm templating from networkpolicy.yaml bundle manifest#1707
dislbenn wants to merge 1 commit into
stolostron:mainfrom
dislbenn:release-5.0

Conversation

@dislbenn

@dislbenn dislbenn commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Description

deploy/olm-catalog/multicluster-operators-subscription/manifests/networkpolicy.yaml (added in #1702) wraps its resources in {{- if .Values.global.networkPolicies.enabled }} / {{- end }}. Since this file lives in the OLM bundle's manifests/ directory — which is meant to contain plain, valid Kubernetes YAML that OLM applies directly via the CSV install path — the embedded Go/Helm template syntax breaks any tool that parses it as plain YAML.

This surfaced as a scheduled CI failure in stolostron/multiclusterhub-operator's bundle-regeneration automation: bundles-to-charts.py's addCRDs() crashed with yaml.parser.ParserError on this file ({{- isn't valid inside a YAML flow node), which took down chart regeneration for every other component processed in the same run, not just this one.

Why removing it is correct, not just a workaround

The wrapping is also redundant. multiclusterhub-operator's chart-generation tooling (installer-dev-tools's bundles-to-charts.py) already automatically wraps every NetworkPolicy resource it extracts from a bundle with the exact same {{- if .Values.global.networkPolicies.enabled }} condition when building the toggle Helm chart — confirmed by re-running the actual chart generation against this file with the wrapping removed:

INFO Found 6 NetworkPolicy templates
INFO Wrapped NetworkPolicy template with networkPolicies.enabled condition: .../multicluster-operators-hub-subscription-policy-networkpolicy.yaml
... (all 6 policies)

The generated chart output confirms the networkPolicies.enabled gate is present either way — this file doesn't need to add it manually, and the manual copy was the one causing the parse failure.

Why this targets main

release-5.0 and release-5.1 are kept in sync with main via a fast-forward cronjob, so fixing main is sufficient — merging directly into release-5.0 would have broken that fast-forward relationship (main would no longer be a strict descendant of release-5.0).

Changes Made

Removed the two {{- if }} / {{- end }} lines. Everything else in the file is unchanged — it's still exactly the same 6 NetworkPolicy resources.

Testing

  • yaml.safe_load_all() on the file now succeeds, parsing all 6 NetworkPolicy documents correctly (previously raised ParserError).
  • Ran the real multiclusterhub-operator chart-regeneration pipeline (generate-shell.py --update-charts-from-bundles) against this branch end-to-end: completes successfully, and the resulting toggle chart's NetworkPolicy templates are still correctly gated behind global.networkPolicies.enabled (see log excerpt above).
  • I have taken backward compatibility into consideration. — no behavior change for consumers of the generated Helm chart; this only affects the raw OLM bundle manifest, which OLM would otherwise choke on if it ever tried to render this file's Go template syntax outside of helm template.

Related

/cc @falconizmi @fxiang1 @jnpacker @mikeshng @rokej @philipwu08 @xiangjingli

@openshift-ci

openshift-ci Bot commented Aug 11, 2026

Copy link
Copy Markdown

Thanks for your pull request. Before we can look at it, you'll need to add a 'DCO signoff' to your commits.

📝 Please follow instructions in the contributing guide to update your commits with the DCO

Full details of the Developer Certificate of Origin can be found at developercertificate.org.

The list of commits missing DCO signoff:

  • 0967778 test: strip helm templating to verify yaml parse fix
Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@openshift-ci

openshift-ci Bot commented Aug 11, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: dislbenn
Once this PR has been reviewed and has the lgtm label, please assign mikeshng for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@dislbenn
dislbenn changed the base branch from release-5.0 to main August 11, 2026 19:51
@sonarqubecloud

Copy link
Copy Markdown

@openshift-ci

openshift-ci Bot commented Aug 11, 2026

Copy link
Copy Markdown

@dislbenn: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/test-unit 0967778 link true /test test-unit

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@dislbenn

Copy link
Copy Markdown
Contributor Author

Superseded by #1708, opened from a branch based on main instead of release-5.0.

@dislbenn dislbenn closed this Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant