Open-source inference server and production cluster for all the models your agent needs.
Python bgecolbertdata-pipelinedeep-learningembeddingsinferenceinference-serverinformation-retrievalllmmlmlopsnatural-language-processingnlppythonrerankingretrievalretrieval-augmented-generationsemantic-searchspladevector-search
fix(helm): reject mismatched trust-manager TLS namespaces (#783)
Krisztian Gajdar25bd316f1253
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 9335761c6..cba1cbaa3 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -79,7 +79,7 @@ jobs:mise exec -- uv run --frozen --project . --no-sync ruff format --check tools/cimise exec -- uv run --frozen --project . --no-sync ruff check --select E,F,I,UP,B tools/cimise exec -- uv run --frozen --project . --no-sync ruff check --select E9,F63,F7,F82 tools/mise_tasks- mise exec -- uv run --frozen --project . --no-sync pytest -q tools/ci/tests --ignore tools/ci/tests/test_required_ci.py --ignore tools/ci/tests/test_public_tree.py --ignore tools/ci/tests/test_helm_render.py --ignore tools/ci/tests/test_helm_dependency_credentials.py+ mise exec -- uv run --frozen --project . --no-sync pytest -q tools/ci/tests --ignore tools/ci/tests/test_required_ci.py --ignore tools/ci/tests/test_public_tree.py --ignore tools/ci/tests/test_helm_render.py --ignore tools/ci/tests/test_helm_dependency_credentials.py --ignore tools/ci/tests/test_helm_trust_namespace.py- name: OpenCode example checker and gateworking-directory: examples/coding-agent-opencoderun: |@@ -215,6 +215,8 @@ jobs:run: mise exec -- uv run --frozen --project . pytest -q tools/ci/tests/test_helm_render.py- name: Dependency credential render testsrun: mise exec -- uv run --frozen --project . pytest -q tools/ci/tests/test_helm_dependency_credentials.py+ - name: Trust-manager namespace render tests+ run: mise exec -- uv run --frozen --project . pytest -q tools/ci/tests/test_helm_trust_namespace.py- run: |destination="$(mktemp -d)"mise run helm -- package --destination "$destination"diff --git a/deploy/helm/sie-cluster/README.md b/deploy/helm/sie-cluster/README.mdindex fb61acb1c..88e433607 100644--- a/deploy/helm/sie-cluster/README.md+++ b/deploy/helm/sie-cluster/README.md@@ -1647,10 +1647,10 @@ separation, not that arbitrary TLS PEM data would be accepted as a runtime bearetoken.In pinned trust-manager, Helm-generated TLS is created in the release namespace-while its Deployment uses the child `namespace` override. Avoid combining a-separate child namespace with `app.webhook.tls.helmCert.enabled=true`; the guard-follows the actual Deployment namespace, and does not repair that inherited-certificate-generation mismatch ([#781](https://github.com/superlinked/sie/issues/781)).+while its Deployment uses the child `namespace` override. The render rejects a+separate child namespace with `app.webhook.tls.helmCert.enabled=true` to prevent+that inherited certificate-generation mismatch. Use the release namespace or+cert-manager generation instead; see [Bundling cert-manager](#bundling-cert-manager).When `gateway.extraEnv` sets `SIE_AUTH_MODE` from `valueFrom`, the mode isunknown at render time. The gateway then receives the generated token, as it@@ -2187,6 +2187,7 @@ Guards:2. A template-time `lookup` aborts the install when `certManagerBundle.certManager.install: true` is combined with an existing `certificates.cert-manager.io` CRD.3. A `pre-install` Job hook re-checks at apply time and aborts before any subchart resources are created (`lookup` returns empty during `helm template` / `--dry-run`, so the Job is the real safety net).4. Jetstack's `crds.keep: true` default is left in place, so `helm uninstall` does not silently delete `Certificate` / `Issuer` resources belonging to other operators.+5. Bundled trust-manager with `trust-manager.app.webhook.tls.helmCert.enabled=true` must use the Helm release namespace. The render rejects a different `trust-manager.namespace`: the pinned dependency generates its TLS Secret and certificate DNS in the release namespace, while its Deployment honors the child namespace override. For a separate child namespace, use `helmCert.enabled=false` with cert-manager. `global.namespace` and `app.trust.namespace` do not relocate that TLS producer.Override the conflict guard (DANGER):diff --git a/deploy/helm/sie-cluster/templates/_helpers.tpl b/deploy/helm/sie-cluster/templates/_helpers.tplindex 8304f8fbf..327409f53 100644--- a/deploy/helm/sie-cluster/templates/_helpers.tpl+++ b/deploy/helm/sie-cluster/templates/_helpers.tpl@@ -867,6 +867,14 @@ Runs from NOTES.txt so every install/upgrade is checked, regardless of which (or{{- end }}{{- define "sie-cluster.validateTls" -}}+{{/* Pinned trust-manager Helm TLS generation uses Release.Namespace for its+ Secret and DNS, while its Deployment honors the child namespace helper. */}}+{{- with index .Subcharts "trust-manager" -}}+{{- $namespace := include "trust-manager.namespace" . -}}+{{- if and .Values.app.webhook.tls.helmCert.enabled (ne $namespace .Release.Namespace) -}}+{{- fail (printf "trust-manager.namespace=%q must equal the Helm release namespace %q when trust-manager.app.webhook.tls.helmCert.enabled=true: the pinned dependency generates its TLS Secret and certificate DNS in the release namespace, while its Deployment uses the child namespace. Clear the namespace override or use helmCert.enabled=false with cert-manager." $namespace .Release.Namespace) -}}+{{- end -}}+{{- end -}}{{- $tls := include "sie-cluster.ingressTlsConfig" . | fromYaml }}{{- $hosts := include "sie-cluster.ingress.hosts" . | fromJsonArray }}{{- /* CRD existence is no longer a reliable "is cert-manager installed" signal — we vendor thediff --git a/tools/ci/tests/test_helm_dependency_credentials.py b/tools/ci/tests/test_helm_dependency_credentials.pyindex 733f33f32..be22564db 100644--- a/tools/ci/tests/test_helm_dependency_credentials.py+++ b/tools/ci/tests/test_helm_dependency_credentials.py@@ -463,10 +463,10 @@ INACTIVE.extend("ca",),(- "trust-helm-other-namespace",+ "trust-helm-other-sie-namespace",{TRUST: True,- "trust-manager.namespace": "monitoring",+ "global.namespace": "workers","trust-manager.app.webhook.tls.helmCert.enabled": True,},"trust-manager-tls",diff --git a/tools/ci/tests/test_helm_trust_namespace.py b/tools/ci/tests/test_helm_trust_namespace.pynew file mode 100644index 000000000..fbcc83519--- /dev/null+++ b/tools/ci/tests/test_helm_trust_namespace.py@@ -0,0 +1,121 @@+"""Keep trust-manager's TLS producer and consumer in the same namespace."""++from __future__ import annotations++import subprocess+from pathlib import Path++import pytest+import yaml++from tools.ci.tests.test_helm_render import ROOT, render_chart, rendered_documents+from tools.mise_tasks import helm+++def trust_values(+ *, installed: bool = True, helm_cert: bool = True, namespace: str = "", workload_namespace: str = ""+) -> dict:+ return {+ "certManagerBundle": {"trustManager": {"install": installed}},+ "trust-manager": {"namespace": namespace, "app": {"webhook": {"tls": {"helmCert": {"enabled": helm_cert}}}}},+ "global": {"namespace": workload_namespace},+ }++[email protected]("workload_namespace", ["", "monitoring", "workers"])+def test_helm_generated_trust_tls_rejects_a_foreign_child_namespace(tmp_path: Path, workload_namespace: str) -> None:+ result = render_chart(tmp_path, trust_values(namespace="monitoring", workload_namespace=workload_namespace))+ assert result.returncode != 0+ assert "trust-manager.namespace" in result.stderr+ assert "app.webhook.tls.helmCert.enabled=true" in result.stderr+ assert '"monitoring"' in result.stderr and '"sie"' in result.stderr+++ ("namespace", "helm_cert", "workload_namespace"),+ [("", True, ""), ("sie", True, ""), ("", True, "workers"), ("monitoring", False, "")],+)+def test_supported_trust_tls_modes_keep_producer_and_consumer_together(+ tmp_path: Path, namespace: str, helm_cert: bool, workload_namespace: str+) -> None:+ docs = rendered_documents(+ tmp_path, trust_values(namespace=namespace, helm_cert=helm_cert, workload_namespace=workload_namespace)+ )+ (deployment,) = [doc for doc in docs if doc["kind"] == "Deployment" and doc["metadata"]["name"] == "trust-manager"]+ volume = next(+ volume+ for volume in deployment["spec"]["template"]["spec"]["volumes"]+ if volume.get("secret", {}).get("secretName") == "trust-manager-tls"+ )+ producer_kind = "Secret" if helm_cert else "Certificate"+ (producer,) = [+ doc+ for doc in docs+ if doc["kind"] == producer_kind+ and doc["metadata"]["name"] == ("trust-manager-tls" if helm_cert else "trust-manager")+ ]+ assert deployment["metadata"]["namespace"] == producer["metadata"]["namespace"] == (namespace or "sie")+ assert volume["secret"]["secretName"] == (+ producer["metadata"]["name"] if helm_cert else producer["spec"]["secretName"]+ )+++def test_disabled_trust_manager_does_not_validate_stale_namespace_settings(tmp_path: Path) -> None:+ result = render_chart(tmp_path, trust_values(installed=False, namespace="monitoring"))+ assert result.returncode == 0, result.stderr+++def test_bundle_source_namespace_does_not_relocate_webhook_tls(tmp_path: Path) -> None:+ values = trust_values()+ values["trust-manager"]["app"]["trust"] = {"namespace": "monitoring"}+ result = render_chart(tmp_path, values)+ assert result.returncode == 0, result.stderr+++def test_namespace_suite_runs_in_the_prepared_helm_lane() -> None:+ workflow = (ROOT / ".github/workflows/ci.yml").read_text()+ assert "--ignore tools/ci/tests/test_helm_trust_namespace.py" in workflow+ assert (+ "run: mise exec -- uv run --frozen --project . pytest -q tools/ci/tests/test_helm_trust_namespace.py"+ in workflow+ )++[email protected]("child_namespace", ["system-edge", "sie"])+def test_trust_tls_uses_the_actual_helm_release_namespace(tmp_path: Path, child_namespace: str) -> None:+ values_file = tmp_path / "custom-release-values.yaml"+ values_file.write_text(yaml.safe_dump(trust_values(namespace=child_namespace, workload_namespace="workers")))+ result = subprocess.run(+ [+ "mise",+ "exec",+ "--",+ "helm",+ "template",+ "custom-release",+ str(helm.CHART_DIR),+ "--namespace",+ "system-edge",+ "-f",+ str(values_file),+ ],+ cwd=ROOT,+ capture_output=True,+ text=True,+ check=False,+ )+ if child_namespace != "system-edge":+ assert result.returncode != 0+ assert 'trust-manager.namespace="sie"' in result.stderr+ assert 'release namespace "system-edge"' in result.stderr+ else:+ assert result.returncode == 0, result.stderr+ docs = [doc for doc in yaml.safe_load_all(result.stdout) if doc]+ tls_pair = [+ doc+ for doc in docs+ if (doc["kind"], doc["metadata"]["name"])+ in {("Secret", "trust-manager-tls"), ("Deployment", "trust-manager")}+ ]+ assert len(tls_pair) == 2+ assert all(doc["metadata"]["namespace"] == "system-edge" for doc in tls_pair)