Repository navigation
Description
Problem
With the bed's own kube_context fix in place (charly#880), check-k3s-vm's nine kubernetes probes resolve a context and dial the forwarded port correctly - and then fail on certificate validity, as seen from the guest at probe time:
stderr: listing nodes: Get "https://127.0.0.1:40179/api/v1/nodes": tls: failed to verify certificate:
x509: certificate has expired or is not yet valid: current time 202…
Measured on charly fix/877-kube-context (step log 2026.286.1339/check-live.log, bed steps=5). Three things are NOT the cause, each checked against the artefact:
- the context: resolved (this row's precondition, fixed by check-k3s-vm's nine kubernetes steps name cluster: but no kube_context, so the bed can never resolve its own cluster #880);
- the server URL: the merged kubeconfig carries server: https://127.0.0.1:40179, i.e. the forwarded port - the rewrite works;
- a missing CA: certificate-authority-data is present and no insecure-skip-tls-verify is set.
Root cause
Mechanism: the certificate presented by the forwarded k3s endpoint is outside its validity window as evaluated by the probe. The likelier of two candidates is a freshly booted disposable VM whose clock has not been synchronised, so a certificate issued moments earlier reads as not yet valid; a genuinely expired certificate is the other.
Missed control: nothing in the bed asserts that guest time is sane before, or at, k3s start - so a clock that is behind produces a TLS failure that reads like a cluster problem.
Blast radius: every bed that probes a freshly created VM over TLS - this one, and any future bed that stands a cluster up and immediately talks to it.
Root fix: establish sane guest time before k3s starts (or before the probes), and assert it: the k3s VM bed's bring-up should check the guest clock against the host and synchronise (NTP, or the qemu-guest-agent path already present), so the certificate verification cannot fail for a reason that has nothing to do with the cluster.
What to check first, in-guest, before changing anything
date -u vs the server certificate's notBefore
openssl s_client -connect 127.0.0.1: </dev/null 2>/dev/null | openssl x509 -noout -dates
If the guest clock lags, the fix is the clock; if the certificate is genuinely expired, the fix is the k3s install path.
Acceptance
A bed run on a fresh disposable VM shows the nine kubernetes probes passing (or failing for a real cluster reason), with the guest clock asserted sane as part of bring-up. Either the clock check lands in the bed's plumbing, or the certificate lifetime is proven wrong and that is fixed instead.
Agent: dsh-opencharly
Assisted-by: dsh deepseek-v4.1-flash (analysed on a live system)
Activity
aitrawog commentedon Oct 13, 2026
CONFIRMED IN A PROPERLY STAGED EXPERIMENT — the certificate-validity wall is the one the bed actually reports, and it is the only one left.
The experiment: charly at fix/877-kube-context (the nine steps name kube_context, charly#880), built with the guarded plugin-kube from my worktree via the dev-build path (bootstrap-charly.sh --dev-plugin plugin-kube=…; the guard's messages verified inside the built plugin, cache plugin-kube-721f3ef0a9059393, 15:58). Run id 2026.286.1357:
[vm-build] PASS 25.409s [vm-create] PASS 2m17.417s [deploy-add] PASS 7m5.926s [bring-up-members] PASS
[check-live] FAIL 2m33.258s → 26 steps: 13 passed, 9 failed, 4 skipped
FAIL [kv-kubernetes-nodes] listing nodes: Get "https://127.0.0.1:43641/api/v1/nodes":
tls: failed to verify certificate: x509: certificate has expired or is not yet valid: current time 202…
Three facts, each load-bearing:
And one elimination this run performed by construction rather than argument: the guarded plugin did NOT fire. Had rewriteK3sServerToForward hit either of its two no-op exits, deploy-add would have FAILED with the guard's message instead of passing in 7m5s. It passed. So plugin-kube#22's original premise — a silently no-opping rewrite leaving the merged context at 127.0.0.1:6443 — does not hold in this configuration; the 6443 seen earlier came from the CACHED kubeconfig that an unfixed wall 1 makes the probe read. That row is corrected there; the guard remains a correct observability change but was never the wall.
So the in-guest check in this row's body is the next action for whoever takes it: date -u in the guest against the server certificate's notBefore, and openssl s_client -connect 127.0.0.1:43641 | openssl x509 -noout -dates on the host. Guest clock behind → fix the clock in bring-up; certificate genuinely expired → fix the k3s install path.
Agent: dsh-opencharly
Assisted-by: dsh deepseek-v4.1-flash (fully tested and validated)
aitrawog commentedon Oct 13, 2026
FIX BRIEF — the file, the line and the pattern, read rather than guessed, so whoever takes this starts from the edit instead of the search.
WHERE THE PRODUCT FIX GOES: opencharly/vm-k3s-server, its single root charly.yml, in the k3s service block:
charly.yml:124 service:
charly.yml:126 exec: /usr/local/bin/k3s server
charly.yml:217-227 (existing comment distinguishing ExecStartPost from ExecStartPre for the apiserver wait)
The fix: a PRE-START precondition on that service — do not hand control to k3s server until guest time is trustworthy (wait for time synchronisation, e.g. systemd NTPSynchronized, or set the clock from the host through the guest-agent channel the VM substrate already has). The candy already reasons in those terms for a different wait, so the pattern to copy is in the same file.
WHY IT BELONGS THERE AND NOT IN THE BED: the bed's plan (charly check-k3s-vm) contains no clock control at all - no date, no ntp, no chrony, verified by reading its steps - so a bed-side fix would be an assertion about someone else's readiness. Assertions are still worth adding (a check: comparing guest date -u with the host reports the skew visibly instead of leaving a TLS failure to be decoded), but the product half belongs in the service that cannot start safely without it, and that fixes it for every consumer.
EVIDENCE THIS IS THE WALL (not a theory): run 2026.286.1357, charly at fix/877-kube-context, dev-built with the guarded plugin-kube. deploy-add PASSED (7m5.926s) - so k3s came up happily on the clock it should not have trusted - and then check-live FAILED with listing nodes: Get "https://127.0.0.1:43641/api/v1/nodes": tls: failed to verify certificate: x509: certificate has expired or is not yet valid. The probes resolved their context and dialled the forwarded port, so both of the other candidate causes are eliminated by that same run.
HOW TO CONFIRM BEFORE EDITING, in-guest: date -u against the server certificate's notBefore, and on the host: openssl s_client -connect 127.0.0.1: </dev/null 2>/dev/null | openssl x509 -noout -dates. Clock behind means the clock is the fix; a genuinely expired certificate means the k3s install path is.
Gate: a bed run on a fresh disposable VM showing the nine kubernetes probes pass, with the clock precondition asserted as part of bring-up.
Agent: dsh-opencharly
Assisted-by: dsh deepseek-v4.1-flash (fully tested and validated)
aitrawog commentedon Oct 13, 2026
CORRECTION to my fix brief above — the edit is smaller than I said, and the correction comes from reading the service block instead of stopping at the first matching line.
I wrote add a pre-start precondition on that service. Reading the block in full shows the candy ALREADY brackets k3s's own start, in its own words:
exec: /usr/local/bin/k3s server
after: [network-online.target]
Two guards bracketing k3s's own start. Both are systemd-only, which is
exactly the coverage needed: every deploy of this candy is a vm: deploy, …
So the fix is not to invent a hook: it is to add the clock to an existing pair of guards — one more condition in a place whose pattern, placement and systemd-only reasoning are already written down by the author. Cheaper than my brief said, and less likely to be done wrong.
And one adjacent line worth having, because it corrects something else I filed: just above the service block, the retrieved kubeconfig is rewritten declaratively —
replace: "${K3S_KUBECONFIG_SERVER:-https://127.0.0.1:6443}"
— as an artifact substitution at retrieve time. The server URL rewrite is a first-class declarative mechanism in this manifest, which is a third independent reason the silent-no-op claim I filed on plugin-kube#22 was wrong, and the reason the merged context carried the forwarded port in run 2026.286.1357.
Neither point changes the diagnosis (the clock wall stands, evidence unchanged); both change the work.
Agent: dsh-opencharly
Assisted-by: dsh deepseek-v4.1-flash (analysed on a live system)
aitrawog commentedon Oct 13, 2026
RECIPE — the schema-correct shape of the fix, read from the guards themselves, so the edit needs no guessing.
The candy's two guards, verbatim from vm-k3s-server/charly.yml:
exec_start_pre:
- /usr/local/bin/k3s-cpuset-ensure.sh
exec_start_post:
- -/usr/local/bin/k3s-crd-heal.sh %n
and each script is written by a plan step of this shape (the one immediately below, for the cpuset guard):
plan:
- run: install the cgroup cpuset pre-start guard the k3s service execs
write: /usr/local/bin/k3s-cpuset-ensure.sh
mode: "0755"
run_as: root
content: |
…
So the clock fix is three lines of the same pattern:
Gate: this repo's own disposable bed (charly.yml:533 from: k3s-srv-vm, disposable: true). No dependency on charly or on any other repo's row.
Two adjacent facts, so the next reader does not have to rediscover them: the service also declares after: [network-online.target] (so ordering exists and is used), and the retrieved kubeconfig's server URL is rewritten by a declarative find/replace at retrieve time - which is why the merged context in run 2026.286.1357 carried the forwarded port.
Agent: dsh-opencharly
Assisted-by: dsh deepseek-v4.1-flash (analysed on a live system)
aitrawog commentedon Oct 13, 2026
STEP 0 for whoever takes the recipe above, and the reason I am not starting the edit myself.
Part II #4: read the subrepo's own rulebook first. vm-k3s-server is a repo I have never worked in, and its AGENTS.md adds repo-specific rules on top of the org rulebook - it may constrain the service block, the guard scripts, the plan steps, or the bed. Starting the three-line edit without reading it would be a rule violation of exactly the kind this row exists to avoid, so:
One design note for step 2, taken from this repo's own vocabulary: its comments distinguish kubectl's condition-wait from a sleep, and describe a guard that must never take down the service it protects. So the clock guard should be a BOUNDED CONDITION-WAIT (wait for time synchronisation, e.g. timedatectl -p NTPSynchronized, with a ceiling) rather than a fixed sleep - and the choice about the leading '-' marker decides whether a failure blocks the start or merely reports. Blocking is defensible here, because starting k3s on untrustworthy time is what produced this wall; the file documents both readings.
Everything after that is three lines and an hour of bed time, in a repo whose gate depends on nothing else.
Agent: dsh-opencharly
Assisted-by: dsh deepseek-v4.1-flash (analysed on a live system)
aitrawog commentedon Oct 13, 2026
BLOCKS / cross-reference — this row's fix now has a home and a number in the repo that must make it: opencharly/vm-k3s-server#9.
That row carries the same measured failure, the reason it belongs in the k3s service rather than in a bed, the schema-correct fix (a plan step plus an entry in the existing exec_start_pre list), the two design notes (bounded condition-wait, and the deliberate choice about the '-' marker), the in-guest/host confirmation commands, and an acceptance clause that lets that repo declare k3s deliberately does not require a trustworthy clock - in which case the certificate lifetime is the defect and this row is the pointer to it.
So the chain is one row per repo, producer-first: vm-k3s-server#9 (the condition) -> charly#882 (this row: the evidence, in the consumer that observes it) -> charly#880 (the bed's kube_context, fix validated on fix/877-kube-context @ 1af84901) -> charly#877 (the pin wave at fdd045b, ci/go green). Nothing in the chain is a duplicate of anything else in it.
What this row still owns after #9 lands: nothing new - it becomes the record that the wall was real, how it was found, and what it was not (the two eliminated causes). Close it when #9's fix is proven by a bed run that lets the probes pass.
Agent: dsh-opencharly
Assisted-by: dsh deepseek-v4.1-flash (analysed on a live system)
aitrawog commentedon Oct 13, 2026
STATUS — dsh-opencharly, end of session. Everything below is sourced in the ledger at .dsh/ledger/open-items-ledger.md (resume packet v5, section 11).
DONE (verified against the live org):
NOT DONE, and why (resource, not knowledge):
WHO IS BLOCKED: nothing of mine blocks another session. This row blocks nothing; it is the record.
NEXT: (1) implement the remedy half on vm-k3s-server#9; (2) then charly#880 and #877 land behind it. Operator decisions pending are listed in the ledger's section 9.1.
Agent: dsh-opencharly
Assisted-by: dsh deepseek-v4.1-flash (analysed on a live system)
fix(k3s-server): refuse to start k3s on an unsynchronised guest clock (…
aitrawog commentedon Oct 13, 2026
STATUS — candidate resolution, with the measurement that supports it and the half it does not cover.
The chain that produced this symptom landed tonight, and the bed that reported it now passes.
This issue's symptom — "the k3s server certificate is outside its validity window at probe time (x509 expired or not yet valid)" — is the "not yet valid" arm: a freshly booted VM whose clock reads 1970 signs a certificate that every client evaluates as not-yet-valid. That is the root of the chain, and the last leg merged this evening:
And the bed's own output, from the run that gated
vm-k3s-server#11on the committed tree:The nine failures are all host-side
kube:steps dialing the guest-local6443— filed asopencharly/charly#885— and not one of them is a certificate-validity failure. The cluster-level steps pass. That is the measurement: on a guest where the guard is installed, this bed reaches and evaluates the server certificate.What I am NOT claiming, and it is the other arm of this issue's own title. "x509 expired or not yet valid" names two causes. The clock guard addresses the second one — the race that makes a freshly booted VM sign outside its window — and nothing I have measured says anything about expiry of a long-lived certificate. If any of the failures you originally recorded was the expired arm, this evidence does not touch it, and I have not tried to distinguish them.
So: candidate resolution for the "not yet valid" arm, on measured bed output; the "expired" arm is untouched and unmeasured by me. If that matches what you saw, this can close; if your record includes an expired certificate, it should stay open with that named.
Agent: dsh-opencharly
Assisted-by: dsh deepseek-v4.1-flash (analysed on a live system)
aitrawog commentedon Oct 13, 2026
STATUS — follow-up to my comment above, and it closes the gap I flagged there.
I said I had evidence for the "not yet valid" arm and none for "expired". That has changed: the expired arm is now measured, by a different instrument than the clock guard.
From the chain's own investigation (
opencharly/charly#877, comment 6147389085, and the corrected model now in that PR's body):Two things follow, and the second is the one this issue needs:
6443URL that looked like a symptom of a broken forward path is the cached kubeconfig — what a probe reads when no context resolves, i.e. the symptom of wall 1 unfixed. The rewrite was never broken. That correction belongs to#877, not here, but it explains why this issue's original probe reported6443;opencharly/vm-k3s-server#11) addresses not yet valid and the probe still fails, what remains is the expired case — a certificate the venue presents which is outside its validity window at probe time, with a trustworthy clock.I am not claiming more than that. The probe's message names both possibilities, so strictly it is a disjunction; what makes the expired arm the likely survivor is that the guard removes the other one. A measurement that distinguishes them directly — the certificate's own
notBefore/notAfterfrom the venue, at probe time — is what would settle it, and I have not taken it.Why this matters for whoever picks this up: this issue and
opencharly/vm-k3s-server#11are the two halves of one symptom with different fixes. The guard prevents a client from evaluating a certificate before the clock is trustworthy; if the venue's certificate is genuinely outside its window, the guard will refuse to start k3s rather than let the probe fail — turning a confusing bed failure into a clear refusal, which is what a guard is for. But#882's row stays open until someone reads the certificate.Agent: dsh-opencharly
Assisted-by: dsh deepseek-v4.1-flash (analysed on a live system)