gofmt -w: 14 files, formatting only, no behaviour change (R-1160)
This commit is contained in:
@@ -2,9 +2,9 @@ package backup
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"log/slog"
|
||||
"testing"
|
||||
|
||||
@@ -48,7 +48,7 @@ func TestR689_GuestBackupArchiveShapes(t *testing.T) {
|
||||
{proxmox.StorageContent{VolID: "felhom-pbs:backup/vm/300/2026-07-28T05:31:14Z", VMID: 300}, true},
|
||||
{proxmox.StorageContent{VolID: "local:backup/felhom-golden-0.236.0.tar.zst"}, false},
|
||||
{proxmox.StorageContent{VolID: "local:backup/vzdump-lxc-9201-x.tar.zst", VMID: 9202}, false}, // vmid disagrees with the name
|
||||
{proxmox.StorageContent{VolID: "felhom-pbs:backup/ct/9201/2026-07-28T05:31:14Z"}, false}, // no vmid reported
|
||||
{proxmox.StorageContent{VolID: "felhom-pbs:backup/ct/9201/2026-07-28T05:31:14Z"}, false}, // no vmid reported
|
||||
} {
|
||||
if ok, why := guestBackupArchive(c.e); ok != c.ok {
|
||||
t.Errorf("%s vmid=%d: ok=%v (%s), want %v", c.e.VolID, c.e.VMID, ok, why, c.ok)
|
||||
|
||||
@@ -47,7 +47,7 @@ type Runner interface {
|
||||
// downgrades a HEALTHY probe to StatusInactive (broken plumbing stays degraded regardless).
|
||||
type Prober struct {
|
||||
Runner Runner
|
||||
Exists func(path string) bool // nil → os.Stat
|
||||
Exists func(path string) bool // nil → os.Stat
|
||||
GateActive func(gate string) bool // nil → every gate treated active
|
||||
}
|
||||
|
||||
|
||||
@@ -21,10 +21,10 @@ import (
|
||||
// The four inputs (the consumption contract — spike findings):
|
||||
// - blob: the opaque R-wrapped escrow blob (hub-served restore directive in 10D).
|
||||
// - recoveryCode (R): BY HAND from the customer — NEVER hub-sourced (zero-knowledge holds: a
|
||||
// hub compromise alone cannot decrypt). A secret: never logged/persisted.
|
||||
// hub compromise alone cannot decrypt). A secret: never logged/persisted.
|
||||
// - expectedFingerprint: hub-served — the gate target (F-C4).
|
||||
// - keyDest: where the PBS restore reads the key (`--keyfile` or the default
|
||||
// `$XDG_CONFIG_HOME/proxmox-backup/encryption-key.json`).
|
||||
// `$XDG_CONFIG_HOME/proxmox-backup/encryption-key.json`).
|
||||
//
|
||||
// Order (spike F-C2/F-C3/F-C4/F-C6): Unwrap → fingerprint-gate → install. On ANY failure there is
|
||||
// NO partial install (nothing at keyDest) and no key material leaks: the recovered key lives only
|
||||
|
||||
@@ -50,8 +50,8 @@ func TestParseConfMounts(t *testing.T) {
|
||||
func TestMissingBindSources(t *testing.T) {
|
||||
mounts := ParseConfMounts(sampleConf)
|
||||
present := map[string]bool{
|
||||
"/mnt/felhom-usb/felhom-data": true, // usb attached
|
||||
"/var/lib/felhom-agent/guests/9201/bootstrap": true, // bootstrap always present
|
||||
"/mnt/felhom-usb/felhom-data": true, // usb attached
|
||||
"/var/lib/felhom-agent/guests/9201/bootstrap": true, // bootstrap always present
|
||||
// "/mnt/felhom-flash/felhom-data" is ABSENT (drive unplugged)
|
||||
}
|
||||
got := MissingBindSources(mounts, func(p string) bool { return present[p] })
|
||||
|
||||
@@ -77,10 +77,10 @@ func TestLoop_FailedTailPushIsReArmedByNextEnvelope(t *testing.T) {
|
||||
env *ControlEnvelope
|
||||
err error
|
||||
}{
|
||||
{env: &ControlEnvelope{LogTailRequested: true}}, // arm
|
||||
{err: errors.New("hub 5xx")}, // the carrying push FAILS
|
||||
{env: &ControlEnvelope{LogTailRequested: true}}, // hub still pending → re-arm
|
||||
{env: &ControlEnvelope{}}, // fulfilled
|
||||
{env: &ControlEnvelope{LogTailRequested: true}}, // arm
|
||||
{err: errors.New("hub 5xx")}, // the carrying push FAILS
|
||||
{env: &ControlEnvelope{LogTailRequested: true}}, // hub still pending → re-arm
|
||||
{env: &ControlEnvelope{}}, // fulfilled
|
||||
}}
|
||||
l := tailLoop(rep)
|
||||
ctx := context.Background()
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
// the report stanza the hub surfaces:
|
||||
//
|
||||
// - /run/sshd present? — OpenSSH's SHARED privsep dir; its absence is the KEXINIT-reset
|
||||
// lockout (SPIKE-felhom-sshd-2026-07-05 §8).
|
||||
// lockout (SPIKE-felhom-sshd-2026-07-05 §8).
|
||||
// - stock sshd listener answers? — a TCP connect to the sshd port (22 for G1; H1 passes the
|
||||
// discovered felhom-sshd port later).
|
||||
// discovered felhom-sshd port later).
|
||||
// - did the watchdog auto-heal? — the watchdog writes an RFC3339 marker to /run when it heals;
|
||||
// its presence (+ timestamp) tells the hub a clobber recurred, so
|
||||
// the operator learns of a recurring cause BEFORE a lockout.
|
||||
// its presence (+ timestamp) tells the hub a clobber recurred, so
|
||||
// the operator learns of a recurring cause BEFORE a lockout.
|
||||
//
|
||||
// Read-only and dependency-light: os.Stat + os.ReadFile + a short net.Dial, no exec, no sudo. Safe to
|
||||
// run every heartbeat.
|
||||
@@ -44,9 +44,9 @@ const (
|
||||
type Reporter struct {
|
||||
privsepDir string
|
||||
marker string
|
||||
sshdAddr string // host:port dialed for the reachability probe
|
||||
statDir func(string) bool // dir-exists check (os.Stat wrapper; test seam)
|
||||
readMarker func(string) (string, bool) // marker read → (timestamp, present)
|
||||
sshdAddr string // host:port dialed for the reachability probe
|
||||
statDir func(string) bool // dir-exists check (os.Stat wrapper; test seam)
|
||||
readMarker func(string) (string, bool) // marker read → (timestamp, present)
|
||||
dialSSHD func(ctx context.Context, addr string) bool
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ const DefaultPool = "felhom"
|
||||
//
|
||||
// SysDataGrowGB itself is NOT removed — see its field comment: the host installer still passes
|
||||
// `-sysdata-grow`, and its GiB are FOLDED INTO the single volume's grow rather than dropped.
|
||||
const DefaultSysDataMount = ""
|
||||
const DefaultSysDataMount = ""
|
||||
|
||||
// Structural host-bind mountpoints every provisioned guest carries (GL-5; verdict of
|
||||
// SPIKE-dr-bindmount-source-2026-07-07): the permanent drives parent bind (mp8,
|
||||
|
||||
@@ -25,8 +25,8 @@ import (
|
||||
// operator's signing CLI (cmd/felhom-opsign) produces it; this runner consumes it. The hub never
|
||||
// forges one (it holds no signing key) and never opens it.
|
||||
type Envelope struct {
|
||||
OpBlobB64 string `json:"op_blob_b64"` // base64 of the canonical OpBlob JSON
|
||||
SigArmored string `json:"sig_armored"` // armored SSHSIG over the op-blob (namespace felhom-op-v1)
|
||||
OpBlobB64 string `json:"op_blob_b64"` // base64 of the canonical OpBlob JSON
|
||||
SigArmored string `json:"sig_armored"` // armored SSHSIG over the op-blob (namespace felhom-op-v1)
|
||||
}
|
||||
|
||||
// JobSource fetches + clears jobs. Satisfied by *hub.Client.
|
||||
|
||||
@@ -14,10 +14,10 @@ func TestClassifyClaim(t *testing.T) {
|
||||
nodes: []claimNode{{name: "sdd", fstype: "", mountpoint: ""}, {name: "sdd1", fstype: "ntfs", mountpoint: ""}}}
|
||||
}
|
||||
cases := []struct {
|
||||
name string
|
||||
mutate func(f *claimFacts)
|
||||
name string
|
||||
mutate func(f *claimFacts)
|
||||
wantUnclaimed bool
|
||||
reasonHas string
|
||||
reasonHas string
|
||||
}{
|
||||
{"clean unclaimed disk (ntfs, unmounted)", func(f *claimFacts) {}, true, "unclaimed"},
|
||||
{"blank disk", func(f *claimFacts) { f.nodes = []claimNode{{name: "sdd"}} }, true, "unclaimed"},
|
||||
|
||||
@@ -103,12 +103,12 @@ type MountSpec struct {
|
||||
// Binaries holds the absolute paths of the allow-listed binaries (overridable from config
|
||||
// so the sudoers entries and the agent agree on exact paths).
|
||||
type Binaries struct {
|
||||
Systemctl string
|
||||
Install string
|
||||
Systemctl string
|
||||
Install string
|
||||
// PrivApply is the root content checker (R-861, agent v0.146.0): a unit file reaches /etc/systemd/system only
|
||||
// through `felhom-priv-apply unit <name>`, which reads the staged copy from /var/lib/felhom-agent/units/ and
|
||||
// refuses anything the renderers here never produce (a bind over /etc, a Where outside /mnt, …).
|
||||
PrivApply string
|
||||
PrivApply string
|
||||
Smartctl string
|
||||
Lvs string
|
||||
Blkid string // device signature probe (8C data-bearing detection)
|
||||
|
||||
@@ -17,12 +17,12 @@ import (
|
||||
// Four states (3A):
|
||||
// - new : durable-id NOT in the store. Never auto-mounted (the user must enroll it).
|
||||
// - enrolled : desired = mounted + bound into the guest. Drift (present && unmounted) with
|
||||
// this intent → reconcile.
|
||||
// this intent → reconcile.
|
||||
// - ejected : an intentional, temporary unmount, set ONLY via the official eject endpoint.
|
||||
// Present && unmounted → left alone. CLEARED to `enrolled` when the drive goes
|
||||
// physically ABSENT, so a replug auto-mounts (the replug rule, for free).
|
||||
// Present && unmounted → left alone. CLEARED to `enrolled` when the drive goes
|
||||
// physically ABSENT, so a replug auto-mounts (the replug rule, for free).
|
||||
// - decommissioned : permanent. Never auto-mounted; SURVIVES absent/present; cleared only by an
|
||||
// explicit re-commission.
|
||||
// explicit re-commission.
|
||||
//
|
||||
// The elegant invariant: intent is recorded ONLY through the official enroll/eject/decommission
|
||||
// paths. "Is it unmounted" ≠ "did someone officially eject it."
|
||||
|
||||
@@ -93,11 +93,11 @@ systemd-1 /mnt/felhom-drives/live autofs rw,relatime,fd=86 0 0
|
||||
where string
|
||||
want bool
|
||||
}{
|
||||
{"/mnt/felhom-drives/live", true}, // real nfs4 (the autofs line for the same path must not confuse it)
|
||||
{"/mnt/felhom-drives/smb", true}, // cifs
|
||||
{"/mnt/felhom-drives/idle", false}, // autofs trigger ONLY — idle automount is NOT mounted
|
||||
{"/mnt/felhom-drives/disk", false}, // a local fs at the path is not a network mount
|
||||
{"/mnt/felhom-drives/nope", false}, // absent
|
||||
{"/mnt/felhom-drives/live", true}, // real nfs4 (the autofs line for the same path must not confuse it)
|
||||
{"/mnt/felhom-drives/smb", true}, // cifs
|
||||
{"/mnt/felhom-drives/idle", false}, // autofs trigger ONLY — idle automount is NOT mounted
|
||||
{"/mnt/felhom-drives/disk", false}, // a local fs at the path is not a network mount
|
||||
{"/mnt/felhom-drives/nope", false}, // absent
|
||||
}
|
||||
for _, tc := range cases {
|
||||
if got := networkMountedIn(procMounts, tc.where); got != tc.want {
|
||||
|
||||
@@ -96,11 +96,11 @@ type Watchdog struct {
|
||||
now func() time.Time
|
||||
spawn func(func()) // spawn a background task (overridable in tests; default `go f()`)
|
||||
|
||||
intent IntentReader // P3: gate re-mount by drive intent (nil = ungated legacy)
|
||||
intent IntentReader // P3: gate re-mount by drive intent (nil = ungated legacy)
|
||||
onAbsent func(durableID string) // P3: called when a known target goes ABSENT (clears `ejected`)
|
||||
|
||||
mu sync.Mutex
|
||||
last map[string]bool // name -> last observed present (only for seen targets)
|
||||
last map[string]bool // name -> last observed present (only for seen targets)
|
||||
lastFire time.Time
|
||||
fired bool // lastFire is valid
|
||||
pending bool // a transition is awaiting the debounce window
|
||||
|
||||
Reference in New Issue
Block a user