Repository navigation
Conversation
…viders, degrade-loud rotation Closes #265 (final slice of epic #261). The operator now turns a KapeAgentServer's credentials[] registry into OpenShell provider records and hands the controller an env table that names only providers the gateway actually holds. Secret resolver (M4, operator/infra/k8s/secret_resolver.go) - Same-namespace reads only, gated on kape.io/credential=true; values stay in memory and never reach the CR, the env contract, or a log line. - Missing, unlabelled, empty, or unreadable Secrets are per-credential failures naming the entry — never a silent skip. Renderer credentials section (M2, operator/domain/agentserver) - Provider names follow handoff H2 (kape-<ns>-<cr>-<cred>); the git-https provider-profile document ships as operator code (endpointless: the CR's hostPatterns are the credential boundary, #269 finding 3). - KAPE_CREDENTIAL_BINDINGS carries [{provider, hosts[]}] (handoff H1) for pushed credentials only, in CR order. OpenShell writer (M3, operator/infra/openshell) - Lint → import → create/update per provider type, platform-scoped profiles so every workspace resolves them without profile_workspace. - Idempotent: an existing profile is neither re-imported nor re-linted (the gateway answers both with "already exists" — verified live), and unchanged credential values perform no write. Rotation is UpdateProvider with the new value; RotateProviderCredential only refreshes gateway-owned material and answers NotFound "provider refresh state not found" for pushed credentials. - Conflicts and transient unavailability retry with exponential backoff; a rejected credential fails alone. Watches and status - Labelled Secret edits requeue every KapeAgentServer in the namespace that references them (rotation = edit the Secret). - status.credentials[] carries Pushed per entry plus the H6 fail-closed gap; the aggregate Degraded condition names the entries that failed while the healthy rest of the profile keeps serving. Module wiring: the operator imports the v0.1.0 client generated into the controller module (handoff H3), so operator/go.mod gains a require + local replace, go.work includes ./controller, and the image build copies the module. The operator's k8s libraries unify on v0.34.2 as a result; the golden files were regenerated for that serializer. Chart: the operator Deployment gets its own mTLS gateway connection (operator.openshell.*, disabled unless a creds Secret is set) and the ClusterRole grants Secrets get/list/watch only. Also fixes the operator image build: `go build ./cmd/...` matched two packages.
…dential writer can be enabled The operator deployment rendered KAPE_OPERATOR_OPENSHHELL_* (double H) while ff derives env names from the flag names (--openshell-gateway-addr → KAPE_OPERATOR_OPENSHELL_GATEWAY_ADDR), so setting operator.openshell.credsSecret never enabled the credential writer. The render-test asserted the same misspelling, locking the bug in. - rename the three chart env vars to the single-H spelling and fix the two user-facing Go messages that named the same var - fix the three render-test assertions - hoist flag registration/parsing in operator/cmd into newFlagSet/parseConfig so a new test can derive env names from the flag definitions: every chart KAPE_OPERATOR_* var must resolve to a real flag, every flag must bind to its derived env name, and the openshell trio must land in config
Fix round 1 — chart→operator env-var spelling (P0)Commit What changed
Every chart-set Regression pin — expectation derived from the flag definitions
Mutation check (chart reverted to double-H, test run with Binding proof — real binary, not just the stringOperator binary built from this branch, run with A enables the writer and reads the value; C is ignored by Render + gatesPre-existing sandbox-only failures, untouched by this commit: |
Closes #265
Final slice of epic #261. The operator turns a KapeAgentServer's
credentials[]registry into OpenShell provider records and hands the controller an env table naming only the providers the gateway actually holds. Rotation is a Secret edit; a broken credential is loud about itself and nothing else.What changed
Secret resolver (M4) —
operator/infra/k8s/secret_resolver.goResolve(ctx, namespace, refs) (ResolvedSecrets, failures)— same-namespace reads only, gated on the Secret labelkape.io/credential=true; key/value material lives in memory and nothing else (never logged, never persisted, never placed on the CR).SecretNotFound,SecretNotLabeled,SecretNoData,SecretReadFailed,CrossNamespaceSecretRef. Messages name the credential and the Secret — never a value.get, list, watchonly (it previously had full verbs on Secrets; nothing else in the operator writes Secrets).Renderer credentials section (M2) —
operator/domain/agentserverkape-<crNamespace>-<crName>-<credName>.KAPE_CREDENTIAL_BINDINGSconsumes handoff H1 verbatim —[{"provider": "<name>", "hosts": ["host:port", …]}]— and carries only credentials present in the resolved-and-pushed set, in CR order (so it is deterministic and never binds an endpoint to a provider that is not there).git-httpsprovider-profile document as operator code (domain/agentserver/profiles.go), pinned by a golden test (testdata/git-https.profile.yaml) so the H5 debugging document cannot drift from what the operator imports.hostPatterns, carried inKAPE_CREDENTIAL_BINDINGSand merged into the sandbox policy by the controller; a profile-declared endpoint would collide with the controller-emittedcredential_bindingendpoint (network endpoint ambiguity). H5 below shows both the operator-imported form and the endpoint-declaring twin for manual debugging.OpenShell writer (M3) —
operator/infra/openshellLintProviderProfiles(only documents that are not on the gateway yet) →ImportProviderProfiles→CreateProvider/UpdateProvider.workspace_scope), so providers in any workspace resolve them withoutprofile_workspace— verified live.UpdateProviderwith the new value.RotateProviderCredentialis unusable for operator-pushed credentials on this gateway — it refreshes gateway-owned material only and answersNotFound: provider refresh state not found(recorded live). Not called.Aborted|ResourceExhausted|Unavailable, 3 attempts, 100 ms → 200 ms).Watches + status
MapSecretToAgentServers+CredentialSecretPredicate: a labelled Secret edit/delete in a namespace requeues every KapeAgentServer there that references it (rotation = edit the Secret). Unlabelled Secrets never enter the cache.status.credentials[]—Pushedper entry (reason + message), plusFailClosedEnforced=False/GatewayEnforcementUnavailableon live entries: the H6 gap surfaced as a per-credential condition, not a full-policy replace.Degraded—Truenaming every failed entry (credentials not pushed: github (SecretNotFound)),False/CredentialsCurrentotherwise,False/NoCredentialsfor an empty registry.Module wiring (handoff H3) and chart
github.com/dzungtr/kape/controller/gen), exactly as H3 states ("each Go slice that needs gateway types imports this package"). Consequences:operator/go.modgainsrequire+ localreplace,go.workincludes./controller, the operator image copies the controller module, and the operator's k8s libraries unify on v0.34.2 (from v0.32.0) — the renderer golden files were regenerated for that serializer'screationTimestampbehaviour.operator.openshell.*(gateway addr defaults tocontrollerWiring.gatewayAddr, its own mTLS Secret mount, workspace). The writer is disabled unlessoperator.openshell.credsSecretis set; without it every credential reportsPushed=False/GatewayNotConfiguredrather than staying silently unprovisioned.operator/Dockerfilerango build ./cmd/..., which matches two packages (cmd,cmd/playground) and failed withcannot write multiple packages to non-directory. Now./cmd,CGO_ENABLED=0; the image builds (verified locally with podman).Handoff H5 — git-https provider-profile document
The document the operator actually imports (endpointless), generated from the shipped registry (
operator/domain/agentserver/testdata/git-https.profile.yaml, pinned byTestGitHTTPSProfileDocument):Manual debugging twin — same document with endpoints, for
openshell profile import+provider createwhen you want a provider that carries its own boundary (this is the #269 proof shape; do not wire it into the controller path, the endpoints collide):Debugging notes (live-verified, v0.1.0):
custom provider profile '<id>' already exists.LintProviderProfilesreports the same for an already-registered profile, so lint is only meaningful for documents not yet on the gateway.Provider.profile_workspaceset to that workspace; platform-scoped profiles (the operator's choice) need nothing.GetProviderreturns the key with an opaque placeholder. The operator therefore detects value drift against the fingerprint of what it last pushed (in memory only); an operator restart re-pushes every credential — safe, and it converges on the Secret's truth.RotateProviderCredentialrequires gateway-owned refresh material (provider refresh configure); for operator-pushed credentials it answersNotFound: provider refresh state not found.openshell:resolve:env:<id>_token); the proxy substitutes the real value at egress — no real credential material is in the sandbox.openrouter/openrouter-spikeproviders still reference the retiredgenericprofile, socreate_agentremains down until their providers are recreated from a real profile. Out of scope here; noted so the next smoke does not chase it.Verification
Gate commands (local — CI has no runners, so this output is the gate):
The 8 failures are pre-existing and unrelated: verified identical on a clean worktree at
518f645(same 8 names,connect: permission deniedon127.0.0.1httptest servers — this sandbox denies loopback).New tests (all pass):
="false"), same-namespace only, missing/empty/nameless ref, no refsinfra/k8s/secret_resolver_test.go(7)domain/agentserver/render_test.go(+7, goldenTestGitHTTPSProfileDocument)infra/openshell/writer_test.go(13)controller/reconcile/agentserver_credentials_test.go(9)controller/watches_test.go(+4)Degraded=Truenaming the entry, labelled Secret → pushed + bindings env, Secret edit → rotation reaches the writertest/integration/agentserver_envtest_test.go::TestAgentServerReconcileCredentialsEnvtestFix round 1 — chart→operator env-var spelling (P0, commit
b0ef603)The chart set
KAPE_OPERATOR_OPENSHHELL_*(double H) whileff/v3.4.0derivesKAPE_OPERATOR_OPENSHELL_*, sooperator.openshell.credsSecretnever enabled the credential writer — the feature's only declarative path was dead, andrender-test.shasserted the same misspelling. Fixed the three chart vars, the three render-test assertions and two Go message strings. Newoperator/cmd/env_binding_test.goderives the expected env names from the flag definitions (newFlagSet) and asserts every chartKAPE_OPERATOR_*var resolves to a real flag, that every flag binds to its derived env name, and that the openshell trio reachesconfig. Binary-level proof:KAPE_OPERATOR_OPENSHELL_GATEWAY_ADDR=openshell-k265-probe.invalid:8080→OpenShell credential writer configured {"gateway": "openshell-k265-probe.invalid:8080"}; the double-H spelling → writer stays disabled.grep -rn OPENSHHELL→ 0.Acceptance criteria
credentials[]entry materializes an OpenShell provider, the controller env updates, fresh sandbox passes #264's verification with no manual provider setupoperator.openshell.credsSecret→KAPE_OPERATOR_OPENSHELL_*→ credential writer) is now proven — see Fix round 1; it was silently dead before the spelling fix. Provider materialization, profile import, CR conditions andKAPE_CREDENTIAL_BINDINGSproven live: provider materializes, profile imported, CR conditions +KAPE_CREDENTIAL_BINDINGScorrect — proven with the operator binary against microk8s. The "fresh sandbox passes without manual provider setup" leg is environment-blocked (needs a publishedkape-controllerimage; the live controller is ArgoCD-managed from the homelab repo — same blocker #262/#264 recorded)Degraded=False; the "new sandboxes use it" leg is environment-blocked with #1Degraded=Truenaming the entry; other credentials and sandbox creation keep workingDegraded/binding filtering:Degraded=True … github (SecretNotFound),github-backupstillPushed=True, bindings env carries only the healthy provider, the controller Deployment still converges. Sandbox creation itself is environment-blocked with #1secretRefrejected at schema/reconcile levelsecretRef must be same-namespace: omit namespace); the reconciler refuses it before any read (CrossNamespaceSecretRef)Extra live checks: label gating end to end (unlabelled Secret →
SecretNotLabeled, labelling recovers →all 2 credentials pushed) and AC "no secret values inkubectl logs"-equivalent — the operator's stdout contains zero token matches (grep -cE 'ghp_|gho_|ghs_|github_pat_'→0).Live run (operator binary vs microk8s, gateway v0.1.0)
kubectl port-forward svc/openshell 32353:8080 -n openshell, operator run locally with--openshell-gateway-addr=127.0.0.1:32353 --openshell-creds-dir=~/.config/openshell/gateways/k8s/mtls, CRk265-slice/k265with two git-https credentials on a labelled Secret:Live finding that changed the implementation: the first run reported
Pushed=False/ProfileLintFailed: custom provider profile 'git-https' already exists—LintProviderProfilestreats an already-registered profile as an error diagnostic. The writer now checks existence first and lints only new documents (pinned byTestWriter_ApplyReusesImportedProfile, and the fake gateway mirrors the gateway's behaviour).Environment-blocked / not done
ghcr.io/dzungtr/kape-controllerimage and a CR-managed controller Deployment. The live controller is ArgoCD-managed from the homelab repo (no registry credentials, no GitOps write path from here) — recorded by Proto re-pin to OpenShell v0.1.0 + workspace_scope fix (cluster upgrade done) #262/Credential-injection mechanism proof: controller binding merge + profile-backed manual provider #264 too. Left unfaked.go vet -tags envtest).RotateProviderCredential: recorded as unavailable for operator-pushed credentials (evidence above) rather than worked around.KAPE_CREDENTIAL_BINDINGS, so nothing binds it). Cleanup of orphanedkape-*providers is a follow-up, deliberately out of this slice.operator.openshell.credsSecret; the shipped default is off, because a missing mTLS Secret would otherwise crash-loop the operator.Cluster left as found: namespace
k265-slice, allk265-*providers/profiles and the port-forward removed; the four legacy CRDs installed only to start the operator locally were deleted again;openrouter/openrouter-spikeuntouched;kapeagentservers.kape.iountouched.