Repository navigation
feat(schema): external-cluster inputs — kubeconfig on kubernetes:, guest identity on kubevirt: - #221
Conversation
…dentity Two authored inputs an externally-managed Kubernetes cluster needs, neither of which the schema could express: * #Kubernetes.kubeconfig (+ the same key on #ResolvedKubernetes): the kubeconfig FILE a cluster is reached through, so pointing charly at a kubeconfig is all it takes to deploy onto the cluster in it. The deploy path could only ever read the ambient $KUBECONFIG / ~/.kube/config, and a context name alone cannot address a per-cluster file. * #KubeVirt.distro / .ssh_user: the guest identity of a boot medium that carries no VM-box metadata (data_volume / pvc / clone), mirroring #VmBoxMetadata's existing pair. Without it the CDI data_volume arm — the one external-cluster boot path that needs no image registry and no node SSH — hard-errored in the kind provider's resolveGuestIdentity, even with cloud_init supplied. Both fields are plain `string`, and the id/presence rules live in the kind provider's OpValidate: #DistroID is `@go(-)` (referencing it emits an undefined Go identifier) and a CUE `if` keyed on the @go(-) union discriminator collapses #KubeVirt to an IncompleteKind. Regenerated with `charly task cue-gen`; a clean regen is a no-op. Closes #220 Agent: dsh-k8s-ext Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated)
Review — BLOCKHead SHA: Change class: Contract / library module ( Blocks
Verdict: BLOCK ollama-cloud/deepseek-v4.1-flash — action-review. |
|
RCA + round fix — validator BLOCK on head Four findings, three distinct failure signatures, each with its own mechanism. Enumerated
Blast radius. All three classes are body/process, so they can affect every remaining PR in Root fix (this round).
No code change was needed: every finding is body/process. The head Agent: dsh-k8s-ext |
Review — PASSHead SHA: Security screen: PASS — additive optional schema keys; no secrets/exfil, no guardrail weakening, no self-modifying-security change, no injected directives in body/diff. Comments considered:
Verdict: PASS ollama-cloud/deepseek-v4.1-flash — action-review. |
…ide the context (#376) * feat(loaderkit): the cluster resolver carries the kubeconfig file beside the context A `cluster: <profile>` resolved to ONE string — the context name. A cluster template addresses a per-cluster kubeconfig FILE (opencharly/spec#221), and that name cannot select it, so every consumer of this helper was structurally unable to honour the file the template declared. `ResolveClusterViaExecutor` now returns the resolved template itself — the kubeconfig file, the context inside it, and the opaque cluster model — and `ResolveClusterContextViaExecutor` stays the thin wrapper over it, so every existing caller keeps its exact contract: one implementation, two views (R2), with the existing arms' tests unchanged as the witness. Miss and failure semantics are preserved bit for bit: (nil, nil) for a legitimate miss, a loud error naming the cluster otherwise — the asymmetry opencharly/plugin-kube#15 depends on, which the new tests pin from the full view's side too. Pins: spec v0.2026287.638 (opencharly/spec#221, merged and tagged). Closes #375 Agent: dsh-k8s-ext Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated) * test(loaderkit): call the exported resolver directly, and state the reviewed revision Round-1 fix. The validator's finding was fair: the "How tested" block was headed with the BASE SHA (`2f4014b`, captured before the commit, by construction), while the PR head was `f018de0`, so the pasted gate could not be attributed to the changed tree — and the same SHA appeared in the R6 line as `origin/main`, which read as a contradiction. Root fix in the control, not just the prose: the gate is now run on the COMMITTED tree and pasted with that head SHA, so the ordering is commit -> gate -> paste -> push. Two SHAs named in one body are now labelled by role (base vs head). Also closes the validator's non-blocking R7 note: the new tests exercised only the unexported seam, so `ResolveClusterViaExecutor` itself had no call in the diff. The exported resolver is now called directly and its nil-executor arm pinned. Agent: dsh-k8s-ext Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated) --------- Co-authored-by: Andreas Trawoeger <[email protected]>
…file, the shared resolver, and the caller's deadline (#25) * feat(kubernetes): honour the cluster template's kubeconfig file, and delegate the resolution `#Kubernetes` and `#KubernetesDeployVenue` carry a kubeconfig FILE (opencharly/spec#221, #224), and `loaderkit.ResolveClusterViaExecutor` hands it out (opencharly/sdk#376). This plugin could use neither: the `kube:` verb read the context-only view, the preresolver built a context-only venue, and `kubectlContextArgs` therefore emitted only `--context`. "Point charly at a kubeconfig and deploy onto the cluster in it" stopped one hop short of working for the workload substrate — while the KubeVirt CR path already honoured the file, which is what made the asymmetry visible on a real external cluster. * the verb's cluster resolution is now `loaderkit.ResolveClusterViaExecutor`, and `applyResolvedCluster` merges BOTH halves into the step's connection inputs (an authored `kubeconfig:` still wins; a legitimate miss still leaves the caller's fallback alone); * `preresolve.go` fills the venue's `kubeconfig` from the template; * ONE argv builder — `kubectlClusterArgs` / `kubectlClusterPrefix` — emits `--kubeconfig` beside `--context`, each half omitted when unset, for the apply, the recorded teardown and both cluster substrates (a kindcluster passes no file: its context is kind's own locally generated kubeconfig). R2/R5: the local `resolveKubeVerbCluster` copy is DELETED, not taught the new field — it was the second occurrence the sdk hoisted in opencharly/sdk#338, and its arms' tests moved to the sdk with it; what stays here is the wiring, now covered by `TestApplyResolvedCluster` / `TestKubectlClusterArgs` / `TestKubectlClusterPrefix`. The `plugin-kube:` candy prose that described the context-only resolution is corrected in the same commit. The five pre-existing `errcheck` findings in `kindcluster.go` and its test are fixed here rather than filed: `golangci-lint run ./...` now reports 0 issues module-wide. Pins: `spec v0.2026287.716` (the tag carrying #224), `sdk v0.2026287.726` (#376). NOT spec v0.2026287.727: that tag carries #225, whose removal `sdk v0.2026287.726` still re-exports in `vmshared/spec_aliases.go` — measured here, and exactly the scheduled break opencharly/sdk#377 tracks. This plugin takes the removal on its own pin wave, after that. Closes #23 Agent: dsh-k8s-ext Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated) * fix(kube): the verb honours its caller's deadline, so a hung dial fails fast and names its phase The kube op runs inside the host's RPC call and receives that call's context, but 20 client call sites passed context.TODO() — an uncancellable, deadline-free context. A hung dial therefore outlived the host's deadline, kept the plugin blocked on a call nothing could cancel, and surfaced only as `verb "kube": rpc error: code = DeadlineExceeded` with no phase named. Measured on a bed probe (#24). dispatch now bounds the WHOLE op by the step's own timeout — one canonical defaultOpTimeout, replacing four scattered parseTimeout(op.Timeout, ...) calls — nested inside the caller's deadline, whichever is shorter, and threads it into all 13 methods and the addons helper. The client is injectable, and a test asserts the context the verb hands its client carries a deadline bounded by the step's timeout and by a tighter caller deadline alike; it FAILS against context.TODO(). Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated) * fix(kube): every deadline routes through one helper, so the claim matches the diff The review found the body describing an intent the diff did not implement: it said the scattered parseTimeout calls had been replaced, but only the 120s ones actually had been. This makes that true rather than softening the sentence — opTimeout(method, op) is now THE deadline of a kube op, with the per-method defaults in a single methodTimeouts table (wait-* 120s, addons 180s, lb-external-ip 60s, exactly as the in-tree Kong tags document), and every one of the four waiting methods calls it. `grep -c 'parseTimeout(' methods.go` is 0, and the only call left in the package is inside the helper. Also settles the go.sum discrepancy the same review flagged: `go list -m` selects spec v0.2026287.716, nothing in the module graph requires v0.2026287.727, so that checksum was a stale entry and `go mod tidy` prunes it here rather than leaving a version named nowhere. Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated) --------- Co-authored-by: Andreas Trawoeger <[email protected]>
…uest identity + the cluster template's kubeconfig (#34) * fix(kubevirt): deploy onto an externally-managed cluster — explicit guest identity + the cluster template's kubeconfig Two gates kept a kind:kubevirt VM off a cluster charly did not create. resolveGuestIdentity returned an UNCONDITIONAL error for every non-containerDisk source — even when cloud_init was supplied — because the guest distro/ssh-user pair had no home on #KubeVirt. That made the CDI data_volume arm undeployable, and that arm is the one boot path on an externally-managed cluster needing neither an image registry nor node SSH (the containerDisk in-node delivery is skipped by design there). The pair is now resolved from the entity, with the VM box's OCI labels as the container_disk fallback; an explicit value wins. kind.go's OpValidate enforces the presence rule (and the #DistroID vocabulary) that schema/kubevirt.cue documents and delegates to it — guarded on the known-valid kind set so an unknown kind reports its own error alone. The cluster template's kubeconfig FILE is now resolved beside its context and carried into clusterConn and the managed virtctl port-forward argv (--kubeconfig). On an externally-managed cluster that file is a per-cluster kubeconfig the ambient $KUBECONFIG never points at, so omitting it dialled whatever cluster the current-context happened to name — and the port-forward is the ONLY route into the guest. Pins: spec v0.2026287.638 (opencharly/spec#221), sdk v0.2026286.932 (the tag whose deploykit no longer references the removed LocalPkgInstallStep.Version). Closes #24 Agent: dsh-k8s-ext Assisted-by: DeepSeek Harness deepseek-v4.1-flash (syntax check only) * fix(kubevirt): emit EFI secureBoot explicitly (a plain UEFI guest was impossible) MEASURED on the OVH quant-dev cluster: applying a `firmware: {bootloader: efi}` VM was REJECTED by KubeVirt's admission webhook — spec.template.spec.domain has EFI SecureBoot enabled. SecureBoot requires SMM, which is currently disabled. Mechanism: KubeVirt's API DEFAULTS an unset `efi.secureBoot` to true. The renderer emitted `efi: {}` both when `efi_secure_boot` was unset AND when it was false, so neither spelling reached the API as a decision and the API's default decided — a plain UEFI guest (which is what an Ubuntu cloud image needs, its bootloader living on the ESP) could not be expressed at all. secureBoot is now emitted explicitly in both directions, and `efi_secure_boot: true` also emits KubeVirt's SMM feature, which is what the webhook requires for it. Agent: dsh-k8s-ext Assisted-by: DeepSeek Harness deepseek-v4.1-flash (syntax check only) * fix(kubevirt): the venue's guest-agent wait was too short for a NESTED venue MEASURED on a disposable bed (2026-10-14). The bed passed eight steps — vm-build, vm-create, deploy-add (30m57s), bring-up-members (26m36s, the change's own guest identity + managed port-forward + in-guest walk), check-live (15m58s), rebuild-members-down, update (41m22s) — and then FAILED at re-bring-up-members: plugin-kubevirt prepare-venue: timeout waiting for the guest agent on default/charly-check-kubevirt-vm-guest (AgentConnected) The VMI by then read `Running … AgentConnected True` at 14 minutes. The bounds in kvPrepareVenue allowed 5: WaitVMIReady 10m WaitAgentConnected 5m WaitInterfaceIP 5m A nested KubeVirt guest — a VM inside the venue's own cluster VM — is not a bare-metal cluster: it needs minutes, not seconds, to bring its agent up. The three bounds are now 15m / 20m / 10m, with the measurement in a comment at the site so the numbers are not "tidied" back, and ordered so the IP bound clears the agent bound (virt-handler publishes status.interfaces[].ipAddress only AFTER AgentConnected). This was pre-existing rather than introduced here — the diff does not touch those lines — but this change's gate is red because of it, which R1 makes blocking: fixed here, whoever caused it. What is NOT fixed, and is filed rather than papered over: the bounds are still constants. The venue path cannot see authored vars (lifecycleParams carries none), so an operator with a slow or emulated venue cannot say so. plugin-kubevirt#28 carries that gap and the proposal to share the verb side's waitSecondsFor resolution instead of growing a second one. Agent: dsh-k8s-ext Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated) * fix(kubevirt): the managed port-forward must PROVE it reaches the VM before being reused The venue reused its forward whenever the pidfile named a live process, and asked nothing else. A supervisor outlives its VMI when a deploy is interrupted, so the pidfile stayed live while its tunnel led nowhere: the next run adopted it and spent an entire ssh cap talking to a VM that had been destroyed. Measured live on this PR's own gate — the isolated check-kubevirt-vm run failed bring-up-members after 42m16s with `wait-for-sshd: … absolute cap exceeded (cap 30m0s)`, the pidfile naming a supervisor ten hours old while four such orphans held ports, one aged sixteen hours. Reuse now depends on the tunnel carrying THIS VM's ssh — an `SSH-` banner read under a named sshProbeWait, because an orphaned supervisor still ACCEPTS a connection and then tunnels nowhere, so a successful dial proves nothing — and when it cannot, the supervisor's process GROUP is reaped. Killing only its virtctl child is not enough and is worse than nothing: the detached `sh -c while :` loop respawns it, which this session did by hand before writing this. Proven both ways. TestForwardCarriesSSH rejects a listener that accepts and says nothing, and accepts a real banner, so the healthy idempotent reuse is preserved. And live: a supervisor-lookalike planted in the pidfile was reaped by the venue prep, which then started a fresh forward — the changed branch executing against a fault planted deliberately, because a re-run over hand-cleaned state would have proved nothing. Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated) --------- Co-authored-by: Andreas Trawoeger <[email protected]>
Summary
Two authored inputs an externally-managed Kubernetes cluster needs, neither of which
charly.ymlcould express. The gap is exercised, not theoretical: on a live OVH-managedcluster (
quant-dev, 3 nodes, k8sv1.35.2) KubeVirtv1.9.0+ CDIv1.66.1were installedand a
VirtualMachineInstancereachedRunning(virt-launcher 2/2) — and the two missinginputs are exactly what stood in the way of doing it from config.
1.
#Kubernetes.kubeconfig(+ the same key on#ResolvedKubernetes). Today#Kubernetescarries a context name only (
schema/kubernetes.cue:18),#KubernetesDeployVenuecarrieskube_contextonly (schema/deploy.cue:805-810), and the deploy path shellskubectl --contextwith no--kubeconfig(plugin-kube/candy/plugin-kube/deploy.go:169-174). Anexternally-managed cluster is normally addressed by a per-cluster file, not by the ambient
$KUBECONFIG/~/.kube/config, and a context name cannot be resolved against a file charlywas never told about. The
kube:andkubevirt:verbs already acceptkubeconfig:(
plugin-kube/.../schema/kube.cue:60,plugin-kubevirt/.../schema/kubevirt.cue:47) — thatasymmetry is the gap. Empty keeps today's behaviour (the ambient file a charly-created
k3s/kind cluster relies on).
2.
#KubeVirt.distro/.ssh_user.resolveGuestIdentityhard-errors for everynon-containerDisk source even when
cloud_init:is supplied(
plugin-kubevirt/candy/plugin-kubevirt/lifecycle.go:383-386; its own message says the pair is"not yet carried by #KubeVirt"). That makes the CDI
data_volumearm — the one external-clusterboot path that needs no image registry and no node SSH — undeployable. The pair mirrors
#VmBoxMetadata's existingdistro/ssh_user(same Go field names, one vocabulary); anexplicit value always wins over box metadata.
Both fields are plain
string, and the id/presence rules live in the kind provider'sOpValidate— the home this file's header documents for cross-arm rules. Two anomalies wererun through RCA while authoring and fixed in this same change:
ifkeyed on the@go(-)union discriminatorsource.kindcollapsed the whole#KubeVirttype toany /* IncompleteKind: _|_ */(gengotypes cannot complete a definitionwhose conditional depends on a
@go(-)union) — the presence rule moved toOpValidate;distro?: #DistroIDemittedundefined: DistroIDin the generated Go —#DistroIDis@go(-)and generates no Go type — so the field is astringvalidated against thevocabulary in
OpValidate, exactly as#VmBoxMetadata.distroalready is.Migration: additive only (two optional keys). The one tightening — the pair being required for
non-containerDisk arms — breaks nothing in the org; executed check below.
Closes #220
How tested
Change class: Contract / library module (
github.com/opencharly/spechas nodisposable: trueentity, so no bed can exist in it —/charly-check:check"R10 gate by changeclass"). The repo's OWN committed module CI is the gate; the negative premise is executed
below. The live bed belongs to the consumer PR named under Consumers.
Clean regeneration on this same head (the committed tree, which is what the check asserts):
Generated-type spot-check on this head — the two new authored keys are present and the
#KubeVirttype is complete again (it wasany /* IncompleteKind */during the anomaly):Migration impact — the new presence rule (a non-containerDisk
kubevirt:source must declaredistro/ssh_user) tightens no existing config. The sweep walks the whole umbrella WORKINGTREE with submodule checkouts included — a recursive
grep, becausegit grepinside asuperproject cannot see submodule content at all:
Rulebook compliance
/charly-internals:go,/charly-internals:plugin,/charly-internals:git-workflow,/charly-internals:strict-policy,/charly-internals:root-cause-analyzer,/charly-kubernetes:kubernetes,/charly-kubevirt:kubevirt,/charly-kubevirt:check-kubevirt,/charly-check:check, plus/charly-vm:vms-catalogand/charly-image:layerfor the consumer surfaces.IncompleteKindcollapse (mechanism: gengotypes cannot complete a conditional keyed on a
@go(-)union) andundefined: DistroID(mechanism:#DistroIDis@go(-), so no Go type is generated). Nowarnings:
golangci-lint run ./...→0 issues.;go testclean;gofmt -l .empty.The missed control was named: the repo has no pre-push control that regenerates CUE and
builds the module before a branch is authored — this PR's evidence is now the recipe.
(
#VmBoxMetadata.distro/ssh_user; the verbs' ownkubeconfig:). The duplicatedcluster:resolve helper between plugin-kube and plugin-kubevirt stays tracked atopencharly/sdk#338and is folded by the consumer change, not here.once, in schema +
OpValidate, never as a fallback branch.contradicts it (the
kubeconfigasymmetry, the kubevirt guest-identity gate) is swept by theconsumer change that makes the behaviour real.
here. The inert cluster-template fields (
secret,resources,hostnames,replica,plan,gateway_api,observability,network_policy) are a genuinely separable removalcutover and are FILED as
opencharly/spec#222; they are neither introduced nor touched bythis diff.
git statusclean before the branch; branch off freshorigin/main(6be6360,verified up to date); no force-push, no bypass, PR-only.
go test -count=1 ./...ran theschema(19.189s)and
spec(2.708s) suites on this head, andTestGenReproduciblevalidates the emittedartifact (the generated Go) at its real boundary. Would
schemafail without this change?Yes — it is the package that loads and validates
schema/*.cue.cluster/container/VM surface). N/A — the live boundary is named as the consumer bed below.
pasted above, including the executed no-disposable-target premise.
is deferred.
(
schema/*.cue+ generated Go = contract module, not docs); tier below matches the pastedproof.
Change classification
spec) — CUE schema + its generated Go.fully tested and validated— the class-mandated gate (module CI: build, test,gofmt, golangci-lint, plus the reproducible regen) passed on this exact head, and the
changed path executed live.
opencharly/sdk(carry the path through the clusterresolve) →
opencharly/plugin-kube(--kubeconfigon the deploy apply; prefer thetemplate's file in the
kube:verb's cluster resolve) →opencharly/plugin-kubevirt—the VM lifecycle, the
kubevirt:verb, the managedvirtctl port-forwardargv, and theexplicit guest identity in
resolveGuestIdentity; this is the PR that runs the live bed(
charly.check-kubevirt-vm+ an external-cluster run).Filed issues
opencharly/spec#222— the eight inert#Kubernetescluster-template fields (secret,resources,hostnames,replica,plan,gateway_api,observability,network_policy) validate and then do nothing;secret:in particular is a silent,security-relevant no-op. Separable: this change's claim holds without the removal.
opencharly/sdk#338— thecluster:resolve helper is duplicated between plugin-kube andplugin-kubevirt. Pre-existing and untouched by this diff; the consumer change named above
is the natural place to fold it.
The two anomalies surfaced while authoring this change are fixed in it, not filed.
Agent: dsh-k8s-ext
Assisted-by: DeepSeek Harness deepseek-v4.1-flash (fully tested and validated)