Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile.custom.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2268,7 +2268,7 @@ verify-worker-image: ## Assert the Substrate worker image follows the chart's ow
@echo "ok: $@"

.PHONY: verify-managers
verify-managers: ## Assert the model-manager / agent-manager wiring (routes, JWT policies, network policies in both flavors) and its guards, the four managers' OAuth inputs derived from muster's login (giantswarm/agent-platform#484), and the metrics port of model-manager, agent-manager and cluster-manager (observability.metrics.port, only while observability.metrics.enabled) admitted from the cluster entity, never the API port, in both flavors, with their ServiceMonitors on in the meta render and carrying the tenant label (giantswarm/giantswarm#36711).
verify-managers: ## Assert the model-manager / agent-manager wiring (routes, JWT policies, network policies in both flavors) and its guards, the managers' OAuth inputs (skill-manager's included) derived from muster's login (giantswarm/agent-platform#484), and the metrics port of model-manager, agent-manager and cluster-manager (observability.metrics.port, only while observability.metrics.enabled) admitted from the cluster entity, never the API port, in both flavors, with their ServiceMonitors on in the meta render and carrying the tenant label (giantswarm/giantswarm#36711).
@echo "====> $@ ($(CONNECTIVITY_DIR))"
@echo "--> both components off render nothing of theirs (agent-manager is off by default; model-manager is on since giantswarm/agent-platform#329)"
@$(HELM) template t $(CONNECTIVITY_DIR) $(VM) --set components.kagent.enabled=true --set components.model-manager.enabled=false >$(VERIFY_TMP)/vmg-off.out 2>&1 || { cat $(VERIFY_TMP)/vmg-off.out; exit 1; }
Expand Down
1 change: 1 addition & 0 deletions docs/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ The default agent is `default-agent` in the kagent namespace, shown as `defaultA

- `components.skill-manager` follows `components.agent-manager`. `enabled: false` leaves it out. `dependsOn: [muster]`. Nothing waits for it: agent-manager and the default agent install while it fails.
- Its `sources` are derived: the platform source, then `skillManager.sources`. An own `skill-manager.sources` fails the render.
- It is an OAuth resource server like the managers: the issuer, client, secret and CA come from `skill-manager.oauth`, else from `global.identity`. Anything still unset is filled from muster's OAuth server block (`muster.muster.oauth.server.dex.*`, `.existingSecret`).
- GitHub access goes in `skill-manager.github` (`app.secretName` or `tokenSecret.name`). Empty reads public repositories anonymously.
- agent-manager gets `skillManager.url`, the skill-manager's Service, from `agent-platform.agentManager.skillManagerFloor` on, `installation` (`backstage.installationName`), which `get_info` reports for the default agent's start links, and `defaultAgentModel.agent: default-agent` while the default agent is on. Below it, or with the skill-manager off, agent-manager gets `skills.repositories` as URLs, without the platform source. `agent-manager.skills.repositories` set while agent-manager uses the skill-manager fails the render.
- Its NetworkPolicy admits its callers' namespaces (`networkPolicy.ingressNamespaces`, derived: muster's, the portal's, agent-manager's, the kagent namespace). The connectivity chart registers it as muster's MCP backend and opens agent-manager's and its migrate run's egress to it.
Expand Down
12 changes: 7 additions & 5 deletions helm/agent-platform/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -4293,10 +4293,12 @@ Usage: include "agent-platform.scheduling.apply" (dict "values" $shaped)

{{/*
The platform's one login in the managers' OAuth blocks
(giantswarm/agent-platform#484). model-manager, agent-manager, vm-manager and
cluster-manager are OAuth resource servers of the login muster's OAuth server
names. Each chart resolves its issuer, client, Secret and trusted audiences
from its own oauth block, else global.identity; what both leave unset is filled
(giantswarm/agent-platform#484). model-manager, agent-manager, vm-manager,
cluster-manager, workspace-manager and skill-manager are OAuth resource servers
of the login muster's OAuth server names (skill-manager's block does not reach
the connectivity release: its own chart opens its identity-provider egress).
Each chart resolves its issuer, client, Secret and trusted audiences from its
own oauth block, else global.identity; what both leave unset is filled
here from muster.muster.oauth.server — oauth.dex.issuerURL from dex.issuerUrl,
oauth.dex.clientID from dex.clientId (and oauth.trustedAudiences [that client],
the charts' own default from global.identity.clientId), oauth.existingSecret
Expand Down Expand Up @@ -4330,7 +4332,7 @@ Usage: include "agent-platform.identity.apply" (dict "values" $shaped)
{{- if and (dig "enabled" true $server) (eq (toString (dig "provider" "dex" $server)) "dex") -}}
{{- $login = dict "issuerURL" (dig "dex" "issuerUrl" "" $server) "clientID" (dig "dex" "clientId" "" $server) "existingSecret" (dig "existingSecret" "" $server) -}}
{{- end -}}
{{- range $name, $wiring := dict "model-manager" "modelManager" "agent-manager" "agentManager" "vm-manager" "" "cluster-manager" "" "workspace-manager" "" -}}
{{- range $name, $wiring := dict "model-manager" "modelManager" "agent-manager" "agentManager" "vm-manager" "" "cluster-manager" "" "workspace-manager" "" "skill-manager" "" -}}
{{- $block := index $v $name -}}
{{- if and (kindIs "map" $block) (kindIs "map" (index $block "oauth")) (dig "oauth" "enabled" false $block) -}}
{{- $oauth := index $block "oauth" -}}
Expand Down
3 changes: 2 additions & 1 deletion helm/agent-platform/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5421,7 +5421,8 @@ skillManager:
# muster forwards (its MCPServer CR, labelled for the agent-platform tool
# group) and the one agent-manager forwards on its REST calls, acting as the
# person; the issuer, client, secret and CA fall back to global.identity
# inside the chart. GitHub is read with the App (github.app.secretName) or
# inside the chart, and what both leave unset is filled from muster's login
# (muster.muster.oauth.server, agent-platform.identity.apply). GitHub is read with the App (github.app.secretName) or
# token Secret (github.tokenSecret.name) set here; empty: anonymous, public
# repositories only. The connectivity chart registers it as muster's MCP
# backend (networkPolicy.mcpBackends.skill-manager, derived) and opens
Expand Down
68 changes: 61 additions & 7 deletions tests/verify-manager-identity.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,27 @@
The meta chart fills what a manager's oauth block and global.identity leave
unset from muster.muster.oauth.server (agent-platform.identity.apply):
oauth.dex.issuerURL, oauth.dex.clientID with oauth.trustedAudiences, and
oauth.existingSecret for model-manager, agent-manager, vm-manager and
cluster-manager; oauth.baseURL for the two routed managers. The connectivity release receives the same filled
blocks, so each case renders the meta chart, then the connectivity chart with
the values its HelmRelease carries — where the absence guard and the
one-login guard fire.
oauth.existingSecret for model-manager, agent-manager, vm-manager,
cluster-manager and skill-manager; oauth.baseURL for the two routed managers.
The connectivity release receives the same filled blocks (not skill-manager's,
which only its own release reads), so each case renders the meta chart, then
the connectivity chart with the values its HelmRelease carries — where the
absence guard and the one-login guard fire.

Usage: verify-manager-identity.py <meta chart> <connectivity chart> [helm flags...]
The helm flags (the Makefile's VM: API versions, required inputs) go to both renders.
"""

import re
import subprocess
import sys
import tempfile

import yaml

MANAGERS = ("model-manager", "agent-manager", "vm-manager", "cluster-manager")
MANAGERS = ("model-manager", "agent-manager", "vm-manager", "cluster-manager", "skill-manager")
# Blocks the connectivity release does not receive (components.agent-platform-connectivity.omitKeys).
NOT_IN_CONNECTIVITY = ("skill-manager",)
ROUTED = {"model-manager": "/model-manager", "agent-manager": "/agent-manager"}
ISSUER = "https://dex.ci.example.com"
CLIENT = "muster-acme"
Expand Down Expand Up @@ -86,9 +90,45 @@ def expect(what: str, got, want) -> None:
sys.exit(f"FAIL: {what}: got {got!r}, want {want!r}")


def roster_covered(meta: str) -> None:
"""Every roster component whose forwarded block has an oauth block is in the helper's list.

A manager that is an OAuth resource server and is not in the list gets no client
from muster's login, and its chart refuses to render where global.identity.clientId
is unset (skill-manager on enigma). A component that derives its login itself
(toolchain-manager.auth, agent-platform.toolchainManager.derived) has no oauth block.
"""
with open(f"{meta}/values.yaml") as f:
values = yaml.safe_load(f)
with open(f"{meta}/templates/_helpers.tpl") as f:
helpers = f.read()
line = re.search(r"\{\{- range \$name, \$wiring := dict (.*?) -\}\}", helpers)
if not line:
sys.exit("FAIL: roster: the agent-platform.identity.apply list is not found in _helpers.tpl")
pairs = line.group(1)
if re.sub(r'"[^"]+"\s+"[^"]*"', "", pairs).strip():
sys.exit(f"FAIL: roster: the agent-platform.identity.apply list is not pairs of quoted strings: {pairs}")
listed = set(re.findall(r'"([^"]+)"\s+"[^"]*"', pairs))
# The helper reads the top-level block (index $v $name): the component's valuesFrom key.
with_oauth = {
c["valuesFrom"] for c in values["components"].values()
if isinstance(values.get(c.get("valuesFrom") or ""), dict)
and isinstance(values[c["valuesFrom"]].get("oauth"), dict)
}
missing = sorted(with_oauth - listed)
if missing:
sys.exit(f"FAIL: roster: {missing} forward an oauth block but are not in agent-platform.identity.apply's list")
if not set(MANAGERS) <= with_oauth:
sys.exit(f"FAIL: roster: {sorted(set(MANAGERS) - with_oauth)} have no oauth block in values.yaml")


def main() -> None:
meta, conn, base = sys.argv[1], sys.argv[2], sys.argv[3:]

print("--> roster: every component that forwards an oauth block takes muster's login")
roster_covered(meta)
print("ok: roster")

print("--> derived: muster's login fills every manager; the routed ones get the route's base URL")
rels = releases(meta, [*base, *ALL_ON, *LOGIN])
for name in MANAGERS:
Expand All @@ -102,7 +142,8 @@ def main() -> None:
expect(f"{name} oauth.baseURL", o.get("baseURL"), want)
cvals = rels["agent-platform-connectivity"]
for name in MANAGERS:
expect(f"the connectivity release's {name}.oauth", cvals.get(name, {}).get("oauth"), oauth(rels, name))
if name not in NOT_IN_CONNECTIVITY:
expect(f"the connectivity release's {name}.oauth", cvals.get(name, {}).get("oauth"), oauth(rels, name))
result = connectivity(conn, cvals, base)
if result.returncode != 0:
sys.exit(f"FAIL: derived: the connectivity render failed\n{result.stderr}")
Expand Down Expand Up @@ -151,6 +192,19 @@ def main() -> None:
expect(f"{name} oauth.trustedAudiences with global.identity set", o.get("trustedAudiences"), None)
print("ok: global.identity wins")

print("--> global.identity without a client (enigma's shape): each key is filled on its own, the client from muster's login")
rels = releases(meta, [*base, *ALL_ON, *LOGIN, *sets(
f"global.identity.issuerUrl={ISSUER}",
f"global.identity.existingSecret={SECRET}",
)])
for name in MANAGERS:
o = oauth(rels, name)
expect(f"{name} oauth.dex.clientID without global.identity.clientId", o.get("dex", {}).get("clientID"), CLIENT)
expect(f"{name} oauth.trustedAudiences without global.identity.clientId", o.get("trustedAudiences"), [CLIENT])
expect(f"{name} oauth.dex.issuerURL with global.identity.issuerUrl set", o.get("dex", {}).get("issuerURL"), None)
expect(f"{name} oauth.existingSecret with global.identity.existingSecret set", o.get("existingSecret"), None)
print("ok: global.identity without a client")

print("--> one login: a global.identity.clientId that differs from muster's fails the connectivity render")
rels = releases(meta, [*base, *ALL_ON, *LOGIN, *sets(f"global.identity.issuerUrl={ISSUER}", "global.identity.clientId=platform")])
result = connectivity(conn, rels["agent-platform-connectivity"], base)
Expand Down
Loading