agent (unreleased): root files older than the agent are not a trust problem on a pinned box (a false operator mail at every box's update)
gates / gates (push) Successful in 41s
gates / gates (push) Successful in 41s
Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
This commit is contained in:
1 parent
3ea208b8fb
commit
5ecdd3d521
3 files changed
+64
No files matched your search
@@ -29,6 +29,7 @@ import (
|
||||
"log/slog"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@@ -246,6 +247,15 @@ func (m *Manager) Ensure(ctx context.Context, why string) bool {
|
||||
c, err := m.EnsureCopy(cctx)
|
||||
ccancel()
|
||||
if err != nil {
|
||||
if rootStepTooOld(err) && cur.Fingerprint != "" {
|
||||
// The agent is newer than the box's root files: between the agent update and the root-files job the
|
||||
// wrapper does not know the step yet. The pinned certificate works; this is not a trust problem, and
|
||||
// naming one mailed the operator at every box's update (seen on Tester 1, 2026-11-15). The bundle
|
||||
// install calls Ensure again.
|
||||
lg.Info("pvetrust: the root files are older than this agent (no CA-copy step yet) — the pinned certificate stays; the next root-files update moves the box", "err", err)
|
||||
set(modeOf(cur), "", "", nil)
|
||||
return false
|
||||
}
|
||||
lg.Warn("pvetrust: the root step gave no CA copy — the trust stays as it is", "err", err)
|
||||
set(modeOf(cur), ProblemCopyUnavailable, truncate(err.Error(), 240), nil)
|
||||
return false
|
||||
@@ -404,3 +414,10 @@ func (m *Manager) writeConfig(caPath string) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// rootStepTooOld says whether the root step refused because it does not know the CA-copy mode at all (the wrapper's
|
||||
// R11 „unknown mode”): the box's root files are older than the agent. Pinned by
|
||||
// TestRootStepOlderThanTheAgent_IsNotATrustProblem.
|
||||
func rootStepTooOld(err error) bool {
|
||||
return err != nil && strings.Contains(err.Error(), "unknown mode")
|
||||
}
|
||||
@@ -487,3 +487,42 @@ func TestProofCannotBeMadeNow_NoCauseNamed(t *testing.T) {
|
||||
t.Fatalf("status = %+v moved=%v", st, b.m.Moved())
|
||||
}
|
||||
}
|
||||
|
||||
// Between the agent update and the root-files job the wrapper does not know the CA-copy step. A pinned box then has
|
||||
// NO trust problem (the pin works): naming one mails the operator at every box's update. A box with NO working pin
|
||||
// that gets the same refusal still names the problem.
|
||||
func TestRootStepOlderThanTheAgent_IsNotATrustProblem(t *testing.T) {
|
||||
p := newPKI(t, "PVE CA")
|
||||
leaf := p.leaf()
|
||||
srv := newPVE(t, leaf)
|
||||
old := errors.New(`pve-ca-copy refused: {"code": "R11", "reason": "unknown mode 'pve-ca-copy'"}`)
|
||||
|
||||
b := newBox(t, srv, proxmox.TLSConfig{Fingerprint: fp(leaf)}, nil)
|
||||
b.m.EnsureCopy = func(context.Context) (Copy, error) { return Copy{}, old }
|
||||
before, _ := os.ReadFile(b.cfgPath)
|
||||
if b.m.Ensure(context.Background(), "start") {
|
||||
t.Fatal("the trust changed with no copy")
|
||||
}
|
||||
if st := b.m.Status(); st.Problem != "" || st.Mode != "fingerprint" {
|
||||
t.Fatalf("a pinned box with older root files reports a trust problem: %+v", st)
|
||||
}
|
||||
if after, _ := os.ReadFile(b.cfgPath); string(after) != string(before) {
|
||||
t.Fatal("the config was written")
|
||||
}
|
||||
|
||||
// the same refusal on a box that is NOT pinned is still a problem: nothing else holds its trust up
|
||||
b2 := newBox(t, srv, proxmox.TLSConfig{}, nil)
|
||||
b2.m.EnsureCopy = func(context.Context) (Copy, error) { return Copy{}, old }
|
||||
b2.m.Ensure(context.Background(), "start")
|
||||
if st := b2.m.Status(); st.Problem != ProblemCopyUnavailable {
|
||||
t.Fatalf("an unpinned box with no copy step must name the problem: %+v", st)
|
||||
}
|
||||
|
||||
// and another refusal on a pinned box is still named
|
||||
b3 := newBox(t, srv, proxmox.TLSConfig{Fingerprint: fp(leaf)}, nil)
|
||||
b3.m.EnsureCopy = func(context.Context) (Copy, error) { return Copy{}, errors.New(`pve-ca-copy refused: {"code": "T3"}`) }
|
||||
b3.m.Ensure(context.Background(), "start")
|
||||
if st := b3.m.Status(); st.Problem != ProblemCopyUnavailable {
|
||||
t.Fatalf("a real refusal lost its name: %+v", st)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user