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
11 changes: 8 additions & 3 deletions docs/klaus-gateway.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,14 @@ platform:
`state/agent-platform-values.yaml`: `a2a` on the in-cluster target,
`namespace: kagent`, the proof's fixture `agentlab-klaus-gateway-test` as
`defaultAgent` (the Slack adapter refuses to start without one; the name
resolves on a turn, never at start); `slack.enabled` in `events` mode on
the placeholder Secret (no `web` key: the Slack-only chart's closed schema
has none); `obo.enabled` with
resolves on a turn, never at start) — except on a lab whose
`platform.valuesFiles` turn on `platformPublicNamespace.changeOver` (the
overlays merged in order, as `helm -f` reads them): the block then names
neither key, because the chart sets `a2a.namespace` to `public-agents` and
fails the render on any other value, and derives `a2a.defaultAgent`,
`public-agents/default-agent` while the default agent runs;
`slack.enabled` in `events` mode on the placeholder Secret (no `web` key:
the Slack-only chart's closed schema has none); `obo.enabled` with
`store: secret`, `musterUrl` the lab muster's public URL, `callbackBaseUrl`
`https://agentgateway.<domain>` (no port: the connectivity chart derives
the hostname of the OBO route it renders on the edge from it, and a
Expand Down
34 changes: 32 additions & 2 deletions internal/lab/klausgateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ import (
// Service over plaintext h2c (the JWT policy validates the forwarded
// token there), AgentTemplates from the kagent namespace, the proof's
// fixture as the default agent (the Slack adapter refuses to start
// without one; the name is resolved on a turn, never at start);
// without one; the name is resolved on a turn, never at start) — but
// neither the namespace nor the default agent on a lab whose overlays
// turn on the change-over to public-agents (PlatformChangeOver below);
// - the Slack adapter — the gateway's only channel — in events mode on a
// placeholder credentials Secret, its Web API base patched to the lab's
// Service in front of the proof's fake Slack Web API (the chart has no
Expand Down Expand Up @@ -127,7 +129,8 @@ type klausGatewayValues struct {
AgentNamespace string
// DefaultAgent is the AgentTemplate a channel turn runs on when it names
// none: the proof's fixture (klausgatewaytest.go), which exists while
// the proof runs.
// the proof runs. The template writes neither AgentNamespace nor
// DefaultAgent under the change-over (PlatformChangeOver).
DefaultAgent string
// SlackSecret and KeysSecret are the two Secrets above.
SlackSecret string
Expand Down Expand Up @@ -166,6 +169,33 @@ func klausGatewayValuesFor(cfg *config.Config) klausGatewayValues {
}
}

// changeOverPath is the meta chart's switch of the change-over to
// public-agents as the platform's shared place (giantswarm/giantswarm#39703).
var changeOverPath = []string{"platformPublicNamespace", "changeOver"}

// PlatformChangeOver says whether the lab's platform.valuesFiles, merged in
// order as `helm -f` merges them, turn on platformPublicNamespace.changeOver.
// The meta chart then sets klausGateway.a2a.namespace to public-agents, where
// Slack's bare agent names resolve, and fails the render on any other value;
// and it derives a2a.defaultAgent, public-agents/default-agent while the
// default agent is on (components.default-agent, on with kagent, muster and
// agent-manager). So the `klausGateway:` block writes neither key then. The
// values template asks it inside that block only, so no other render reads
// the overlays, and a render that turns the component on for itself
// (chartGatewayVersion) gets the same answer as the install.
func (t *tmplData) PlatformChangeOver() (bool, error) {
if len(t.Platform.ValuesFiles) == 0 {
return false, nil
}
values, err := helmValuesFiles(t.Platform.ValuesFiles...)
if err != nil {
return false, err
}
v, _ := lookupPath(values, changeOverPath)
on, _ := v.(bool)
return on, nil
}

// klausGatewayOBOHost is the hostname the component serves its OBO routes on
// through the edge: agentgateway.<domain>.
func klausGatewayOBOHost(cfg *config.Config) string {
Expand Down
58 changes: 58 additions & 0 deletions internal/lab/render_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package lab

import (
"fmt"
"os"
"path/filepath"
"reflect"
"runtime"
"slices"
Expand Down Expand Up @@ -1246,6 +1248,62 @@ func TestPlatformValuesKlausGateway(t *testing.T) {
}
}

// The change-over to public-agents (platformPublicNamespace.changeOver in a
// platform.valuesFiles overlay): the values the meta chart receives — the
// lab's render with the overlays merged over it — carry no
// klausGateway.a2a.namespace, which the chart sets itself and refuses when it
// differs, and no a2a.defaultAgent, which it derives. The same holds for
// the render that turns the component on for itself (chartGatewayVersion)
// on a lab whose agentlab.yaml has it off. The overlays merge in order: a
// later changeOver: false keeps today's namespace and default agent.
func TestPlatformValuesKlausGatewayChangeOver(t *testing.T) {
dir := t.TempDir()
overlay := func(name string, on bool) string {
path := filepath.Join(dir, name)
if err := os.WriteFile(path, fmt.Appendf(nil, "platformPublicNamespace:\n changeOver: %t\n", on), 0o600); err != nil {
t.Fatal(err)
}
return path
}
on, off := overlay("change-over.yaml", true), overlay("back.yaml", false)
for _, c := range []struct {
name string
overlays []string
componentInConfig bool
changedOver bool
}{
{"the change-over", []string{on}, true, true},
{"the component on for the render only", []string{on}, false, true},
{"a later overlay turns it off", []string{on, off}, true, false},
} {
t.Run(c.name, func(t *testing.T) {
cfg := config.Default()
cfg.Platform.KlausGateway.Enabled = c.componentInConfig
cfg.Platform.ValuesFiles = c.overlays
values, err := platformValuesWith(cfg, func(d *tmplData) { d.KlausGatewayEnabled = true })
if err != nil {
t.Fatal(err)
}
raw, _ := lookupPath(values, []string{"klausGateway", "a2a"})
a2a, _ := raw.(map[string]any)
if a2a["enabled"] != true || a2a["url"] != klausGatewayInClusterTarget {
t.Fatalf("klausGateway.a2a = %v, want it on at the in-cluster target", raw)
}
namespace, hasNamespace := a2a["namespace"]
defaultAgent, hasDefault := a2a["defaultAgent"]
if c.changedOver {
if hasNamespace || hasDefault {
t.Errorf("under the change-over klausGateway.a2a names namespace %v and defaultAgent %v, want neither", namespace, defaultAgent)
}
return
}
if namespace != kagentNamespace || defaultAgent != klausGatewayTestAgent {
t.Errorf("klausGateway.a2a namespace %v defaultAgent %v, want %s and the proof's fixture %s", namespace, defaultAgent, kagentNamespace, klausGatewayTestAgent)
}
})
}
}

// The serving switch's render: the llm-d components and the modelServing
// switch on, the classic controller off with the llm-d controller rendering
// the shared objects and naming the models Gateway, the lab's CPU preset on
Expand Down
6 changes: 6 additions & 0 deletions internal/lab/templates/agent-platform-values.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -1483,8 +1483,14 @@ klausGateway:
a2a:
enabled: true
url: {{ .KlausGateway.A2ATarget }}
{{- if .PlatformChangeOver }}
# The overlays turn on platformPublicNamespace.changeOver: the chart sets
# the namespace to public-agents (it refuses another one) and derives the
# default agent there, so neither is written (klausgateway.go).
{{- else }}
namespace: {{ .KlausGateway.AgentNamespace }}
defaultAgent: {{ .KlausGateway.DefaultAgent }}
{{- end }}
slack:
enabled: true
mode: events
Expand Down
Loading