Skip to content

armgit / sie

Public Imported from GitHub
0

Open-source inference server and production cluster for all the models your agent needs.

fix(helm): separate bundled dependency credential keys (#782)

Krisztian Gajdarac600a51d1c5
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index e331020ee..9335761c6 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/ci
mise exec -- uv run --frozen --project . --no-sync ruff check --select E,F,I,UP,B tools/ci
mise 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
+ 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
- name: OpenCode example checker and gate
working-directory: examples/coding-agent-opencode
run: |
@@ -213,6 +213,8 @@ jobs:
--set payloadStore.enabled=false >/dev/null
- name: Chart render tests
run: mise exec -- uv run --frozen --project . pytest -q tools/ci/tests/test_helm_render.py
+ - name: Dependency credential render tests
+ run: mise exec -- uv run --frozen --project . pytest -q tools/ci/tests/test_helm_dependency_credentials.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.md
index 8b7f97852..fb61acb1c 100644
--- a/deploy/helm/sie-cluster/README.md
+++ b/deploy/helm/sie-cluster/README.md
@@ -818,9 +818,9 @@ Below, `<fullname>` is the chart's full name: `<release>-sie-cluster`, or
entry that reads an upstream's Secret anywhere else fails the render. An
upstream's Secret key must also differ from the checked credential keys
listed in [Gateway token](#gateway-token), including the Hugging Face token,
- gateway tokens, sie-config tokens, NATS passwords, and bundled Grafana admin
- credentials. Optional dependency and arbitrary subchart configuration outside
- that list needs operator separation; see [#767](https://github.com/superlinked/sie/issues/767).
+ gateway tokens, sie-config tokens, NATS passwords, and the bundled dependency
+ credentials listed there. Arbitrary subchart configuration outside that list
+ needs operator separation.
- sie-config receives the upstream names (`SIE_UPSTREAM_NAMES`), built from the
same `upstreams` values as the remote lanes' file, and refuses with a `422` a
model whose remote profile names any other upstream. Without a remote lane it
@@ -1610,12 +1610,47 @@ token, a `gateway.extraEnv` token Secret, or the MCP edge cluster API key is
the same Secret key as a checked credential: the Hugging Face
token, a NATS password, the gateway admin token, either sie-config token, an
image pull secret, an oauth2-proxy secret, the Better Stack token, a bundled
-Grafana admin username or password in the same namespace, the MCP connector
+Grafana admin username or password, the dependency keys below, the MCP connector
secrets, or a chart-managed ingress TLS key. Gateway client credentials may
-share a key with each other. The guard checks this finite list; other optional
-dependency credentials and arbitrary subchart env/volume configuration need
-operator separation. Remaining dependency cases are tracked in
-[#767](https://github.com/superlinked/sie/issues/767).
+share a key with each other. Worker tokens, gateway client credentials (including
+`gateway.extraEnv` token refs and MCP edge client keys), and upstream credentials
+all use this same finite inventory.
+
+Bundled dependency refs are checked only when their actual consumer is enabled
+and its namespace matches the SIE workload namespace. The chart uses the enabled
+child chart's own naming/namespace helpers: `global.namespace` relocates SIE
+workloads, not every dependency. These rules follow the versions in `Chart.lock`:
+
+| Dependency consumer | Checked Secret keys |
+| --- | --- |
+| Grafana SMTP (`smtp.existingSecret` set) | Literal existing Secret, `smtp.userKey` / `smtp.passwordKey` (defaults `user` / `password`). |
+| Grafana LDAP (`ldap.enabled`) | Literal `ldap.existingSecret` or Grafana fullname, `ldap-toml`. |
+| KEDA operator and metrics TLS | Literal `certificates.secretName`, `ca.crt`, `tls.crt`, `tls.key`. Disabling certificate generation or webhooks does not remove these consumers. |
+| KEDA CA Issuer (`certificates.certManager.enabled` and `issuer.generate`) | Literal `caSecretName`, `tls.crt` / `tls.key`, including an existing CA when `generateCA=false`. |
+| Prometheus operator or separate admission webhook TLS | Child fullname + `-admission`, `cert` / `key`, or `tls.crt` / `tls.key` in cert-manager mode. `admissionWebhooks.enabled` does not disable these TLS mounts. |
+| Prometheus self-monitoring CA or certificate patch Jobs | Same admission Secret, `ca` (`ca.crt` for cert-manager self-monitoring). Patch Jobs read `ca` even when TLS and self-monitoring are off. |
+| Prometheus cert-manager CA Issuer (no external `issuerRef`) | Child fullname + `-root-cert`, `tls.crt` / `tls.key`, even with the operator disabled. |
+| trust-manager webhook TLS | Child name + `-tls`, `tls.crt` / `tls.key`, in both certificate-generation modes. |
+| Loki NGINX gateway basic auth | Literal `gateway.basicAuth.existingSecret` or gateway fullname, `.htpasswd`; excludes the enterprise GEL gateway. |
+| Loki's optional MinIO | Literal MinIO `existingSecret` or MinIO fullname, `rootUser` / `rootPassword`. |
+
+This is not an inventory of arbitrary dependency configuration. Operators must
+keep SIE credentials separate from Grafana `envValueFrom` / `envFromSecret`,
+extra env/volumes, raw Loki/enterprise/cloud-storage configuration, MinIO extra
+Secrets, Prometheus/Alertmanager Secret lists and provider configs, and KEDA
+`grpcTLSCertsSecret` / `hashiCorpVaultTLS` (whole-Secret mounts with scaler-defined
+filenames). External Issuer backing Secrets, custom CA/provider configuration,
+and custom dependency images also need operator review; their key layout cannot
+be inferred from the pinned chart's first-class refs; these surfaces are tracked in
+[#780](https://github.com/superlinked/sie/issues/780). Render tests enforce key
+separation, not that arbitrary TLS PEM data would be accepted as a runtime bearer
+token.
+
+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)).
When `gateway.extraEnv` sets `SIE_AUTH_MODE` from `valueFrom`, the mode is
unknown at render time. The gateway then receives the generated token, as it
diff --git a/deploy/helm/sie-cluster/templates/_helpers.tpl b/deploy/helm/sie-cluster/templates/_helpers.tpl
index 03d1932ac..8304f8fbf 100644
--- a/deploy/helm/sie-cluster/templates/_helpers.tpl
+++ b/deploy/helm/sie-cluster/templates/_helpers.tpl
@@ -1155,6 +1155,80 @@ token-separation check and the upstream-key collision check read this list.
{{- if and (not .Values.env.GF_SECURITY_ADMIN_PASSWORD) (not .Values.env.GF_SECURITY_ADMIN_PASSWORD__FILE) (not .Values.env.GF_SECURITY_DISABLE_INITIAL_ADMIN_CREATION) -}}
{{- $keys = append $keys (dict "owner" "the Grafana admin password" "name" "Grafana admin password" "ref" (printf "%s/%s" $secretName (default "admin-password" .Values.admin.passwordKey))) -}}
{{- end -}}
+{{- if .Values.smtp.existingSecret -}}
+{{- $smtpSecret := .Values.smtp.existingSecret -}}
+{{- range $key := list (default "user" .Values.smtp.userKey) (default "password" .Values.smtp.passwordKey) -}}
+{{- $keys = append $keys (dict "owner" "the Grafana SMTP credentials" "name" "Grafana SMTP credentials" "ref" (printf "%s/%s" $smtpSecret $key)) -}}
+{{- end -}}
+{{- end -}}
+{{- if .Values.ldap.enabled -}}
+{{- $ldapSecret := default (include "grafana.fullname" .) .Values.ldap.existingSecret -}}
+{{- $keys = append $keys (dict "owner" "the Grafana LDAP configuration" "name" "Grafana LDAP configuration" "ref" (printf "%s/ldap-toml" $ldapSecret)) -}}
+{{- end -}}
+{{- end -}}
+{{- end -}}
+{{- end -}}
+{{/* Dependency contexts exist only when Helm enabled that dependency. Match
+ actual consumer namespaces; SIE global.namespace does not relocate them. */}}
+{{- with index $root.Subcharts "keda" -}}
+{{- if eq .Release.Namespace (include "sie-cluster.namespace" $root) -}}
+{{/* Generation and webhooks flags do not disable operator/metrics TLS mounts. */}}
+{{- $secretName := .Values.certificates.secretName -}}
+{{- range $key := list "ca.crt" "tls.crt" "tls.key" -}}
+{{- $keys = append $keys (dict "owner" "the KEDA serving TLS credentials" "name" "KEDA serving TLS credentials" "ref" (printf "%s/%s" $secretName $key)) -}}
+{{- end -}}
+{{- $cm := .Values.certificates.certManager -}}
+{{- if and $cm.enabled $cm.issuer.generate -}}
+{{- range $key := list "tls.crt" "tls.key" -}}
+{{- $keys = append $keys (dict "owner" "the KEDA CA signer" "name" "KEDA CA signer" "ref" (printf "%s/%s" $cm.caSecretName $key)) -}}
+{{- end -}}
+{{- end -}}
+{{- end -}}
+{{- end -}}
+{{- with index $root.Subcharts "kube-prometheus-stack" -}}
+{{- if eq (include "kube-prometheus-stack.namespace" .) (include "sie-cluster.namespace" $root) -}}
+{{- $operator := .Values.prometheusOperator -}}
+{{- $admission := $operator.admissionWebhooks -}}
+{{- $fullname := include "kube-prometheus-stack.fullname" . -}}
+{{- if and $operator.enabled (or $operator.tls.enabled (and $admission.deployment.enabled $admission.deployment.tls.enabled)) -}}
+{{- $tlsKeys := ternary (list "tls.crt" "tls.key") (list "cert" "key") $admission.certManager.enabled -}}
+{{- range $key := $tlsKeys -}}
+{{- $keys = append $keys (dict "owner" "the Prometheus admission TLS credentials" "name" "Prometheus admission TLS credentials" "ref" (printf "%s-admission/%s" $fullname $key)) -}}
+{{- end -}}
+{{- end -}}
+{{/* certgen create/patch Jobs also read ca, even without serving TLS or a monitor. */}}
+{{- $patchReadsCA := and $admission.enabled $admission.patch.enabled (not $admission.certManager.enabled) -}}
+{{- if and $operator.enabled (or (and $operator.serviceMonitor.selfMonitor $operator.tls.enabled) $patchReadsCA) -}}
+{{- $key := ternary "ca.crt" "ca" $admission.certManager.enabled -}}
+{{- $keys = append $keys (dict "owner" "the Prometheus admission CA" "name" "Prometheus admission CA" "ref" (printf "%s-admission/%s" $fullname $key)) -}}
+{{- end -}}
+{{/* This CA Issuer exists even when the operator Deployment is disabled. */}}
+{{- if and $admission.certManager.enabled (not $admission.certManager.issuerRef) -}}
+{{- range $key := list "tls.crt" "tls.key" -}}
+{{- $keys = append $keys (dict "owner" "the Prometheus root CA signer" "name" "Prometheus root CA signer" "ref" (printf "%s-root-cert/%s" $fullname $key)) -}}
+{{- end -}}
+{{- end -}}
+{{- end -}}
+{{- end -}}
+{{- with index $root.Subcharts "trust-manager" -}}
+{{- if eq (include "trust-manager.namespace" .) (include "sie-cluster.namespace" $root) -}}
+{{- $secretName := printf "%s-tls" (include "trust-manager.name" .) -}}
+{{- range $key := list "tls.crt" "tls.key" -}}
+{{- $keys = append $keys (dict "owner" "the trust-manager serving TLS credentials" "name" "trust-manager serving TLS credentials" "ref" (printf "%s/%s" $secretName $key)) -}}
+{{- end -}}
+{{- end -}}
+{{- end -}}
+{{- with index $root.Subcharts "loki" -}}
+{{- if eq .Release.Namespace (include "sie-cluster.namespace" $root) -}}
+{{- if and .Values.gateway.enabled .Values.gateway.basicAuth.enabled (not (and .Values.enterprise.enabled .Values.enterprise.gelGateway)) -}}
+{{- $secretName := include "loki.gatewayAuthSecret" . -}}
+{{- $keys = append $keys (dict "owner" "the Loki gateway basic auth credentials" "name" "Loki gateway basic auth credentials" "ref" (printf "%s/.htpasswd" $secretName)) -}}
+{{- end -}}
+{{- with index .Subcharts "minio" -}}
+{{- $secretName := include "minio.secretName" . -}}
+{{- range $key := list "rootUser" "rootPassword" -}}
+{{- $keys = append $keys (dict "owner" "the Loki MinIO root credentials" "name" "Loki MinIO root credentials" "ref" (printf "%s/%s" $secretName $key)) -}}
+{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
diff --git a/deploy/helm/sie-cluster/values.yaml b/deploy/helm/sie-cluster/values.yaml
index f62070ce7..453b581d1 100644
--- a/deploy/helm/sie-cluster/values.yaml
+++ b/deploy/helm/sie-cluster/values.yaml
@@ -336,9 +336,9 @@ gateway:
# and key of a checked credential, such as the Hugging Face
# token, a NATS password, the gateway admin token, either sie-config token,
# an image pull secret, an oauth2-proxy secret, the Better Stack token, the
- # bundled same-namespace Grafana admin key, MCP connector secrets, or an
- # ingress TLS key (the render fails). Other optional dependency credentials
- # and arbitrary subchart env/volume refs need operator separation; see #767.
+ # bundled same-namespace dependency keys listed in README "Gateway token",
+ # MCP connector secrets, or an ingress TLS key (the render fails). Arbitrary
+ # dependency env/volume/provider refs still need operator separation.
tokenSecretName: ""
tokenSecretKey: "SIE_AUTH_TOKEN"
# -- Generate the gateway token (a boolean). When tokenSecretName is empty,
diff --git a/tools/ci/tests/test_helm_dependency_credentials.py b/tools/ci/tests/test_helm_dependency_credentials.py
new file mode 100644
index 000000000..733f33f32
--- /dev/null
+++ b/tools/ci/tests/test_helm_dependency_credentials.py
@@ -0,0 +1,549 @@
+"""Real pinned-dependency consumers must not alias SIE credentials (#767)."""
+
+from __future__ import annotations
+
+from pathlib import Path
+
+import pytest
+
+from tools.ci.tests.test_helm_render import (
+ GATEWAY_TOKEN_SECRET,
+ ROOT,
+ WORKER_TOKEN_SECRET,
+ render_chart,
+ rendered_documents,
+ upstream,
+ worker_with,
+)
+
+
+def values_at(paths: dict) -> dict:
+ values: dict = {}
+ for path, value in paths.items():
+ target = values
+ *parents, leaf = path.split(".")
+ for parent in parents:
+ target = target.setdefault(parent, {})
+ target[leaf] = value
+ return values
+
+
+PROM = "kube-prometheus-stack"
+GRAFANA = f"{PROM}.grafana"
+OPERATOR = f"{PROM}.prometheusOperator"
+ADMISSION = f"{OPERATOR}.admissionWebhooks"
+CM = f"{ADMISSION}.certManager"
+KEDA_CM = "keda.certificates.certManager"
+TRUST = "certManagerBundle.trustManager.install"
+LOKI = {
+ "observability.logs.loki.install": True,
+ "loki.gateway.basicAuth.username": "test-user",
+ "loki.gateway.basicAuth.password": "test-password",
+}
+PROM_NAME = "sie-kube-prometheus-stack"
+
+# id, enabled settings, actual Secret name, actual data key. Names/keys are
+# verified against rendered consumers below, rather than just an error string.
+CASES = [
+ ("smtp-user", {f"{PROM}.install": True, f"{GRAFANA}.smtp.existingSecret": "mail"}, "mail", "user"),
+ ("smtp-password", {f"{PROM}.install": True, f"{GRAFANA}.smtp.existingSecret": "mail"}, "mail", "password"),
+ (
+ "smtp-custom",
+ {f"{PROM}.install": True, f"{GRAFANA}.smtp.existingSecret": "mail", f"{GRAFANA}.smtp.passwordKey": "login"},
+ "mail",
+ "login",
+ ),
+ ("ldap-generated", {f"{PROM}.install": True, f"{GRAFANA}.ldap.enabled": True}, "sie-grafana", "ldap-toml"),
+ (
+ "ldap-existing",
+ {f"{PROM}.install": True, f"{GRAFANA}.ldap.enabled": True, f"{GRAFANA}.ldap.existingSecret": "directory"},
+ "directory",
+ "ldap-toml",
+ ),
+ ("keda-serving", {"keda.install": True}, "kedaorg-certs", "tls.key"),
+ ("keda-ca-cert", {"keda.install": True}, "kedaorg-certs", "ca.crt"),
+ (
+ "keda-external-serving",
+ {
+ "keda.install": True,
+ "keda.certificates.autoGenerated": False,
+ "keda.webhooks.enabled": False,
+ "keda.certificates.secretName": "custom-keda",
+ "keda.operator.name": "other",
+ },
+ "custom-keda",
+ "tls.key",
+ ),
+ (
+ "keda-ca-signer",
+ {"keda.install": True, f"{KEDA_CM}.enabled": True, f"{KEDA_CM}.issuer.generate": True},
+ "kedaorg-ca",
+ "tls.key",
+ ),
+ (
+ "keda-existing-ca",
+ {
+ "keda.install": True,
+ f"{KEDA_CM}.enabled": True,
+ f"{KEDA_CM}.generateCA": False,
+ f"{KEDA_CM}.issuer.generate": True,
+ f"{KEDA_CM}.caSecretName": "existing-ca",
+ },
+ "existing-ca",
+ "tls.crt",
+ ),
+ ("prom-serving", {f"{PROM}.install": True}, f"{PROM_NAME}-admission", "key"),
+ (
+ "prom-admission-disabled",
+ {f"{PROM}.install": True, f"{ADMISSION}.enabled": False},
+ f"{PROM_NAME}-admission",
+ "key",
+ ),
+ (
+ "prom-webhook-only",
+ {
+ f"{PROM}.install": True,
+ f"{OPERATOR}.tls.enabled": False,
+ f"{ADMISSION}.enabled": False,
+ f"{ADMISSION}.deployment.enabled": True,
+ },
+ f"{PROM_NAME}-admission",
+ "key",
+ ),
+ ("prom-ca-monitor", {f"{PROM}.install": True}, f"{PROM_NAME}-admission", "ca"),
+ ("prom-cert-manager", {f"{PROM}.install": True, f"{CM}.enabled": True}, f"{PROM_NAME}-admission", "tls.key"),
+ ("prom-cm-ca-monitor", {f"{PROM}.install": True, f"{CM}.enabled": True}, f"{PROM_NAME}-admission", "ca.crt"),
+ (
+ "prom-root-signer",
+ {f"{PROM}.install": True, f"{CM}.enabled": True, f"{OPERATOR}.enabled": False},
+ f"{PROM_NAME}-root-cert",
+ "tls.key",
+ ),
+ (
+ "prom-custom-name",
+ {
+ f"{PROM}.install": True,
+ f"{PROM}.fullnameOverride": "custom-prometheus-stack-long-name",
+ f"{OPERATOR}.fullnameOverride": "not-secret",
+ },
+ "custom-prometheus-stack-lo-admission",
+ "key",
+ ),
+ ("trust-cert-manager", {TRUST: True}, "trust-manager-tls", "tls.key"),
+ (
+ "trust-helm",
+ {TRUST: True, "trust-manager.app.webhook.tls.helmCert.enabled": True},
+ "trust-manager-tls",
+ "tls.key",
+ ),
+ (
+ "trust-custom-name",
+ {TRUST: True, "trust-manager.nameOverride": "custom-trust", "trust-manager.app.trust.namespace": "elsewhere"},
+ "custom-trust-tls",
+ "tls.crt",
+ ),
+ (
+ "loki-generated",
+ {**LOKI, "loki.gateway.enabled": True, "loki.gateway.basicAuth.enabled": True},
+ "loki-gateway",
+ ".htpasswd",
+ ),
+ (
+ "loki-existing",
+ {
+ **LOKI,
+ "loki.gateway.enabled": True,
+ "loki.gateway.basicAuth.enabled": True,
+ "loki.gateway.basicAuth.existingSecret": "gateway-auth",
+ },
+ "gateway-auth",
+ ".htpasswd",
+ ),
+ ("minio-generated-user", {**LOKI, "loki.minio.enabled": True}, "sie-minio", "rootUser"),
+ ("minio-generated-password", {**LOKI, "loki.minio.enabled": True}, "sie-minio", "rootPassword"),
+ (
+ "minio-existing",
+ {
+ **LOKI,
+ "loki.minio.enabled": True,
+ "loki.minio.existingSecret": "object-store",
+ "loki.minio.mode": "standalone",
+ },
+ "object-store",
+ "rootPassword",
+ ),
+ (
+ "grafana-same-namespace",
+ {
+ f"{PROM}.install": True,
+ f"{GRAFANA}.namespaceOverride": "workers",
+ "global.namespace": "workers",
+ f"{GRAFANA}.smtp.existingSecret": "mail",
+ },
+ "mail",
+ "password",
+ ),
+ (
+ "prom-same-namespace",
+ {f"{PROM}.install": True, f"{PROM}.namespaceOverride": "workers", "global.namespace": "workers"},
+ f"{PROM_NAME}-admission",
+ "key",
+ ),
+ (
+ "trust-same-namespace",
+ {TRUST: True, "trust-manager.namespace": "workers", "global.namespace": "workers"},
+ "trust-manager-tls",
+ "tls.key",
+ ),
+]
+
+
+CASES.extend(
+ [
+ (
+ "prom-patch-ca-without-tls",
+ {
+ f"{PROM}.install": True,
+ f"{OPERATOR}.tls.enabled": False,
+ f"{OPERATOR}.serviceMonitor.selfMonitor": False,
+ },
+ f"{PROM_NAME}-admission",
+ "ca",
+ ),
+ (
+ "smtp-custom-user",
+ {f"{PROM}.install": True, f"{GRAFANA}.smtp.existingSecret": "mail", f"{GRAFANA}.smtp.userKey": "login"},
+ "mail",
+ "login",
+ ),
+ (
+ "ldap-custom-fullname",
+ {f"{PROM}.install": True, f"{GRAFANA}.fullnameOverride": "custom-grafana", f"{GRAFANA}.ldap.enabled": True},
+ "custom-grafana",
+ "ldap-toml",
+ ),
+ (
+ "loki-custom-fullname",
+ {
+ **LOKI,
+ "loki.fullnameOverride": "custom-loki",
+ "loki.gateway.enabled": True,
+ "loki.gateway.basicAuth.enabled": True,
+ },
+ "custom-loki-gateway",
+ ".htpasswd",
+ ),
+ (
+ "minio-custom-fullname",
+ {**LOKI, "loki.minio.enabled": True, "loki.minio.fullnameOverride": "custom-minio"},
+ "custom-minio",
+ "rootUser",
+ ),
+ ]
+)
+
+
+def consumer_values(paths: dict, name: str, key: str, role: str) -> dict:
+ values = values_at(paths)
+ if role == "worker":
+ values["workers"] = worker_with(tokenSecretName=name, tokenSecretKey=key)
+ elif role == "gateway":
+ values["gateway"] = {"auth": {"mode": "token", "tokenSecretName": name, "tokenSecretKey": key}}
+ elif role == "gateway-extra-env":
+ values["gateway"] = {
+ "auth": {"mode": "token"},
+ "extraEnv": [{"name": "SIE_AUTH_TOKEN", "valueFrom": {"secretKeyRef": {"name": name, "key": key}}}],
+ }
+ elif role == "upstream":
+ values["upstreams"] = {"team": upstream(api_key_secret={"name": name, "key": key})}
+ elif role == "mcp":
+ values["mcpEdge"] = {"enabled": True, "clusterApiKey": {"existingSecretName": name, "secretKey": key}}
+ else:
+ raise AssertionError(role)
+ return values
+
+
+def consumed_refs(docs: list[dict]) -> set[tuple[str, str, str | None]]:
+ """Structured consumers only; Secret creation alone is not consumption."""
+ refs = set()
+ for doc in docs:
+ namespace = doc["metadata"].get("namespace", "sie")
+ if doc["kind"] in {"Deployment", "StatefulSet"}:
+ spec = doc["spec"]["template"]["spec"]
+ for container in (spec.get("containers") or []) + (spec.get("initContainers") or []):
+ for env in container.get("env", []) or []:
+ ref = env.get("valueFrom", {}).get("secretKeyRef")
+ if ref:
+ refs.add((namespace, ref["name"], ref["key"]))
+ for volume in spec.get("volumes", []) or []:
+ if ref := volume.get("secret"):
+ for item in ref.get("items", [{"key": None}]):
+ refs.add((namespace, ref["secretName"], item["key"]))
+ elif doc["kind"] == "Job":
+ for container in doc["spec"]["template"]["spec"].get("containers", []):
+ args = container.get("args", [])
+ if args and args[0] in {"create", "patch"}:
+ for arg in args:
+ if arg.startswith("--secret-name="):
+ refs.add((namespace, arg.split("=", 1)[1], "ca"))
+ elif doc["kind"] == "Issuer" and (ref := doc["spec"].get("ca")):
+ refs.update((namespace, ref["secretName"], key) for key in ("tls.crt", "tls.key"))
+ elif doc["kind"] == "ServiceMonitor":
+ for endpoint in doc["spec"]["endpoints"]:
+ ref = endpoint.get("tlsConfig", {}).get("ca", {}).get("secret")
+ if ref:
+ refs.add((namespace, ref["name"], ref["key"]))
+ return refs
+
+
[email protected](("case", "paths", "name", "key"), CASES, ids=[case[0] for case in CASES])
+def test_dependency_fixture_has_the_actual_consumer(
+ tmp_path: Path, case: str, paths: dict, name: str, key: str
+) -> None:
+ values = values_at(paths)
+ namespace = values.get("global", {}).get("namespace", "sie")
+ refs = consumed_refs(rendered_documents(tmp_path, values))
+ assert (namespace, name, key) in refs or (namespace, name, None) in refs, (case, refs)
+
+
[email protected]("role", ["worker", "gateway", "gateway-extra-env", "upstream", "mcp"])
[email protected](("case", "paths", "name", "key"), CASES, ids=[case[0] for case in CASES])
+def test_dependency_key_cannot_be_a_sie_credential(
+ tmp_path: Path, role: str, case: str, paths: dict, name: str, key: str
+) -> None:
+ result = render_chart(tmp_path, consumer_values(paths, name, key, role))
+ assert result.returncode != 0, case
+ assert "same Secret key" in result.stderr, result.stderr
+ assert f"{name}/{key}" in result.stderr, result.stderr
+
+
[email protected](("case", "paths", "name", "key"), CASES, ids=[case[0] for case in CASES])
+def test_another_key_in_the_same_secret_remains_allowed(
+ tmp_path: Path, case: str, paths: dict, name: str, key: str
+) -> None:
+ result = render_chart(tmp_path, consumer_values(paths, name, "separate-sie-token", "worker"))
+ assert result.returncode == 0, (case, result.stderr)
+
+
+INACTIVE = [
+ (
+ "grafana-disabled",
+ {f"{PROM}.install": True, f"{GRAFANA}.enabled": False, f"{GRAFANA}.smtp.existingSecret": "mail"},
+ "mail",
+ "password",
+ ),
+ ("prom-stack-disabled", {f"{PROM}.install": False, f"{GRAFANA}.smtp.existingSecret": "mail"}, "mail", "password"),
+ ("smtp-unset", {f"{PROM}.install": True}, "mail", "password"),
+ (
+ "ldap-disabled",
+ {f"{PROM}.install": True, f"{GRAFANA}.ldap.existingSecret": "directory"},
+ "directory",
+ "ldap-toml",
+ ),
+ ("keda-disabled", {"keda.install": False}, "kedaorg-certs", "tls.key"),
+ ("keda-ca-disabled", {"keda.install": True, f"{KEDA_CM}.enabled": False}, "kedaorg-ca", "tls.key"),
+ (
+ "keda-issuer-external",
+ {"keda.install": True, f"{KEDA_CM}.enabled": True, f"{KEDA_CM}.issuer.generate": False},
+ "kedaorg-ca",
+ "tls.key",
+ ),
+ (
+ "prom-operator-disabled",
+ {f"{PROM}.install": True, f"{OPERATOR}.enabled": False},
+ f"{PROM_NAME}-admission",
+ "key",
+ ),
+ ("prom-tls-disabled", {f"{PROM}.install": True, f"{OPERATOR}.tls.enabled": False}, f"{PROM_NAME}-admission", "key"),
+ (
+ "prom-webhook-tls-disabled",
+ {
+ f"{PROM}.install": True,
+ f"{OPERATOR}.tls.enabled": False,
+ f"{ADMISSION}.deployment.enabled": True,
+ f"{ADMISSION}.deployment.tls.enabled": False,
+ },
+ f"{PROM_NAME}-admission",
+ "key",
+ ),
+ ("prom-cm-unused-filename", {f"{PROM}.install": True, f"{CM}.enabled": True}, f"{PROM_NAME}-admission", "key"),
+ ("prom-patch-unused-filename", {f"{PROM}.install": True}, f"{PROM_NAME}-admission", "tls.key"),
+ (
+ "prom-root-external-issuer",
+ {f"{PROM}.install": True, f"{CM}.enabled": True, f"{CM}.issuerRef.name": "external"},
+ f"{PROM_NAME}-root-cert",
+ "tls.key",
+ ),
+ ("prom-root-disabled", {f"{PROM}.install": True}, f"{PROM_NAME}-root-cert", "tls.key"),
+ ("trust-disabled", {TRUST: False}, "trust-manager-tls", "tls.key"),
+ (
+ "loki-disabled",
+ {
+ "observability.logs.install": False,
+ "observability.logs.loki.install": True,
+ "loki.gateway.enabled": True,
+ "loki.gateway.basicAuth.enabled": True,
+ },
+ "loki-gateway",
+ ".htpasswd",
+ ),
+ ("loki-gateway-disabled", {**LOKI, "loki.gateway.basicAuth.enabled": True}, "loki-gateway", ".htpasswd"),
+ (
+ "loki-basic-auth-disabled",
+ {**LOKI, "loki.gateway.enabled": True, "loki.gateway.basicAuth.existingSecret": "gateway-auth"},
+ "gateway-auth",
+ ".htpasswd",
+ ),
+ ("minio-disabled", {**LOKI, "loki.minio.existingSecret": "object-store"}, "object-store", "rootPassword"),
+ (
+ "grafana-other-namespace",
+ {
+ f"{PROM}.install": True,
+ f"{GRAFANA}.namespaceOverride": "monitoring",
+ f"{GRAFANA}.smtp.existingSecret": "mail",
+ },
+ "mail",
+ "password",
+ ),
+ ("keda-other-namespace", {"keda.install": True, "global.namespace": "workers"}, "kedaorg-certs", "tls.key"),
+ (
+ "prom-other-namespace",
+ {f"{PROM}.install": True, f"{PROM}.namespaceOverride": "monitoring"},
+ f"{PROM_NAME}-admission",
+ "key",
+ ),
+ ("trust-other-namespace", {TRUST: True, "trust-manager.namespace": "monitoring"}, "trust-manager-tls", "tls.key"),
+ (
+ "loki-other-namespace",
+ {**LOKI, "loki.gateway.enabled": True, "loki.gateway.basicAuth.enabled": True, "global.namespace": "workers"},
+ "loki-gateway",
+ ".htpasswd",
+ ),
+ (
+ "minio-other-namespace",
+ {**LOKI, "loki.minio.enabled": True, "global.namespace": "workers"},
+ "sie-minio",
+ "rootPassword",
+ ),
+]
+
+
+INACTIVE.extend(
+ [
+ (
+ "prom-patch-ca-disabled",
+ {
+ f"{PROM}.install": True,
+ f"{OPERATOR}.tls.enabled": False,
+ f"{OPERATOR}.serviceMonitor.selfMonitor": False,
+ f"{ADMISSION}.patch.enabled": False,
+ },
+ f"{PROM_NAME}-admission",
+ "ca",
+ ),
+ (
+ "prom-admission-ca-disabled",
+ {
+ f"{PROM}.install": True,
+ f"{OPERATOR}.tls.enabled": False,
+ f"{OPERATOR}.serviceMonitor.selfMonitor": False,
+ f"{ADMISSION}.enabled": False,
+ },
+ f"{PROM_NAME}-admission",
+ "ca",
+ ),
+ (
+ "prom-monitor-ca-disabled",
+ {
+ f"{PROM}.install": True,
+ f"{OPERATOR}.serviceMonitor.selfMonitor": False,
+ f"{ADMISSION}.patch.enabled": False,
+ },
+ f"{PROM_NAME}-admission",
+ "ca",
+ ),
+ (
+ "trust-helm-other-namespace",
+ {
+ TRUST: True,
+ "trust-manager.namespace": "monitoring",
+ "trust-manager.app.webhook.tls.helmCert.enabled": True,
+ },
+ "trust-manager-tls",
+ "tls.key",
+ ),
+ ]
+)
+
+
+INACTIVE.append(
+ (
+ "loki-enterprise-gel",
+ {
+ **LOKI,
+ "loki.gateway.enabled": True,
+ "loki.gateway.basicAuth.enabled": True,
+ "loki.enterprise.enabled": True,
+ "loki.enterprise.gelGateway": True,
+ },
+ "loki-gateway",
+ ".htpasswd",
+ )
+)
+
+
+# These key-mode controls still mount the same whole Secret for other known
+# filenames. A whole-volume render alone cannot prove which file the binary reads.
+NO_SECRET_CONSUMERS = [
+ case
+ for case in INACTIVE
+ if case[0] not in {"prom-cm-unused-filename", "prom-patch-unused-filename", "prom-monitor-ca-disabled"}
+]
+
+
+ ("case", "paths", "name", "key"), NO_SECRET_CONSUMERS, ids=[case[0] for case in NO_SECRET_CONSUMERS]
+)
+def test_inactive_fixture_has_no_matching_consumer(tmp_path: Path, case: str, paths: dict, name: str, key: str) -> None:
+ values = values_at(paths)
+ namespace = values.get("global", {}).get("namespace", "sie")
+ refs = consumed_refs(rendered_documents(tmp_path, values))
+ assert (namespace, name, key) not in refs and (namespace, name, None) not in refs, (case, refs)
+
+
[email protected]("role", ["worker", "gateway", "gateway-prepare"])
+def test_generated_sie_tokens_cannot_alias_dependency_credentials(tmp_path: Path, role: str) -> None:
+ name = WORKER_TOKEN_SECRET if role == "worker" else GATEWAY_TOKEN_SECRET
+ values = values_at(
+ {
+ f"{PROM}.install": True,
+ f"{GRAFANA}.smtp.existingSecret": name,
+ f"{GRAFANA}.smtp.passwordKey": "SIE_AUTH_TOKEN",
+ }
+ )
+ if role == "worker":
+ values["workers"] = worker_with()
+ else:
+ values["gateway"] = {"auth": {"generateToken": True, "mode": "token" if role == "gateway" else "none"}}
+ result = render_chart(tmp_path, values)
+ assert result.returncode != 0
+ assert "same Secret key" in result.stderr, result.stderr
+ assert f"{name}/SIE_AUTH_TOKEN" in result.stderr, result.stderr
+
+
[email protected]("role", ["worker", "gateway", "upstream"])
[email protected](("case", "paths", "name", "key"), INACTIVE, ids=[case[0] for case in INACTIVE])
+def test_inactive_or_other_namespace_credentials_remain_allowed(
+ tmp_path: Path, role: str, case: str, paths: dict, name: str, key: str
+) -> None:
+ result = render_chart(tmp_path, consumer_values(paths, name, key, role))
+ assert result.returncode == 0, (case, result.stderr)
+
+
+def test_dependency_suite_runs_only_in_the_prepared_helm_lane() -> None:
+ workflow = (ROOT / ".github/workflows/ci.yml").read_text()
+ assert "--ignore tools/ci/tests/test_helm_dependency_credentials.py" in workflow
+ assert (
+ "run: mise exec -- uv run --frozen --project . pytest -q tools/ci/tests/test_helm_dependency_credentials.py"
+ in workflow
+ )