gofmt -w: 14 files, formatting only, no behaviour change (R-1160)
This commit is contained in:
1 parent
0bc0bc5da0
commit
1edfd8e331
14 files changed
+38
-38
No files matched your search
@@ -2,9 +2,9 @@ package backup
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"testing"
|
"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: "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/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: "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 {
|
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)
|
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).
|
// downgrades a HEALTHY probe to StatusInactive (broken plumbing stays degraded regardless).
|
||||||
type Prober struct {
|
type Prober struct {
|
||||||
Runner Runner
|
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
|
GateActive func(gate string) bool // nil → every gate treated active
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,10 +21,10 @@ import (
|
|||||||
// The four inputs (the consumption contract — spike findings):
|
// The four inputs (the consumption contract — spike findings):
|
||||||
// - blob: the opaque R-wrapped escrow blob (hub-served restore directive in 10D).
|
// - 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
|
// - 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).
|
// - expectedFingerprint: hub-served — the gate target (F-C4).
|
||||||
// - keyDest: where the PBS restore reads the key (`--keyfile` or the default
|
// - 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
|
// 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
|
// 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) {
|
func TestMissingBindSources(t *testing.T) {
|
||||||
mounts := ParseConfMounts(sampleConf)
|
mounts := ParseConfMounts(sampleConf)
|
||||||
present := map[string]bool{
|
present := map[string]bool{
|
||||||
"/mnt/felhom-usb/felhom-data": true, // usb attached
|
"/mnt/felhom-usb/felhom-data": true, // usb attached
|
||||||
"/var/lib/felhom-agent/guests/9201/bootstrap": true, // bootstrap always present
|
"/var/lib/felhom-agent/guests/9201/bootstrap": true, // bootstrap always present
|
||||||
// "/mnt/felhom-flash/felhom-data" is ABSENT (drive unplugged)
|
// "/mnt/felhom-flash/felhom-data" is ABSENT (drive unplugged)
|
||||||
}
|
}
|
||||||
got := MissingBindSources(mounts, func(p string) bool { return present[p] })
|
got := MissingBindSources(mounts, func(p string) bool { return present[p] })
|
||||||
|
|||||||
@@ -77,10 +77,10 @@ func TestLoop_FailedTailPushIsReArmedByNextEnvelope(t *testing.T) {
|
|||||||
env *ControlEnvelope
|
env *ControlEnvelope
|
||||||
err error
|
err error
|
||||||
}{
|
}{
|
||||||
{env: &ControlEnvelope{LogTailRequested: true}}, // arm
|
{env: &ControlEnvelope{LogTailRequested: true}}, // arm
|
||||||
{err: errors.New("hub 5xx")}, // the carrying push FAILS
|
{err: errors.New("hub 5xx")}, // the carrying push FAILS
|
||||||
{env: &ControlEnvelope{LogTailRequested: true}}, // hub still pending → re-arm
|
{env: &ControlEnvelope{LogTailRequested: true}}, // hub still pending → re-arm
|
||||||
{env: &ControlEnvelope{}}, // fulfilled
|
{env: &ControlEnvelope{}}, // fulfilled
|
||||||
}}
|
}}
|
||||||
l := tailLoop(rep)
|
l := tailLoop(rep)
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|||||||
@@ -6,12 +6,12 @@
|
|||||||
// the report stanza the hub surfaces:
|
// the report stanza the hub surfaces:
|
||||||
//
|
//
|
||||||
// - /run/sshd present? — OpenSSH's SHARED privsep dir; its absence is the KEXINIT-reset
|
// - /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
|
// - 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;
|
// - 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
|
// its presence (+ timestamp) tells the hub a clobber recurred, so
|
||||||
// the operator learns of a recurring cause BEFORE a lockout.
|
// 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
|
// Read-only and dependency-light: os.Stat + os.ReadFile + a short net.Dial, no exec, no sudo. Safe to
|
||||||
// run every heartbeat.
|
// run every heartbeat.
|
||||||
@@ -44,9 +44,9 @@ const (
|
|||||||
type Reporter struct {
|
type Reporter struct {
|
||||||
privsepDir string
|
privsepDir string
|
||||||
marker string
|
marker string
|
||||||
sshdAddr string // host:port dialed for the reachability probe
|
sshdAddr string // host:port dialed for the reachability probe
|
||||||
statDir func(string) bool // dir-exists check (os.Stat wrapper; test seam)
|
statDir func(string) bool // dir-exists check (os.Stat wrapper; test seam)
|
||||||
readMarker func(string) (string, bool) // marker read → (timestamp, present)
|
readMarker func(string) (string, bool) // marker read → (timestamp, present)
|
||||||
dialSSHD func(ctx context.Context, addr string) bool
|
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
|
// 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.
|
// `-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
|
// 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,
|
// 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
|
// 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.
|
// forges one (it holds no signing key) and never opens it.
|
||||||
type Envelope struct {
|
type Envelope struct {
|
||||||
OpBlobB64 string `json:"op_blob_b64"` // base64 of the canonical OpBlob JSON
|
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)
|
SigArmored string `json:"sig_armored"` // armored SSHSIG over the op-blob (namespace felhom-op-v1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// JobSource fetches + clears jobs. Satisfied by *hub.Client.
|
// 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: ""}}}
|
nodes: []claimNode{{name: "sdd", fstype: "", mountpoint: ""}, {name: "sdd1", fstype: "ntfs", mountpoint: ""}}}
|
||||||
}
|
}
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
name string
|
name string
|
||||||
mutate func(f *claimFacts)
|
mutate func(f *claimFacts)
|
||||||
wantUnclaimed bool
|
wantUnclaimed bool
|
||||||
reasonHas string
|
reasonHas string
|
||||||
}{
|
}{
|
||||||
{"clean unclaimed disk (ntfs, unmounted)", func(f *claimFacts) {}, true, "unclaimed"},
|
{"clean unclaimed disk (ntfs, unmounted)", func(f *claimFacts) {}, true, "unclaimed"},
|
||||||
{"blank disk", func(f *claimFacts) { f.nodes = []claimNode{{name: "sdd"}} }, 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
|
// Binaries holds the absolute paths of the allow-listed binaries (overridable from config
|
||||||
// so the sudoers entries and the agent agree on exact paths).
|
// so the sudoers entries and the agent agree on exact paths).
|
||||||
type Binaries struct {
|
type Binaries struct {
|
||||||
Systemctl string
|
Systemctl string
|
||||||
Install string
|
Install string
|
||||||
// PrivApply is the root content checker (R-861, agent v0.146.0): a unit file reaches /etc/systemd/system only
|
// 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
|
// 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, …).
|
// refuses anything the renderers here never produce (a bind over /etc, a Where outside /mnt, …).
|
||||||
PrivApply string
|
PrivApply string
|
||||||
Smartctl string
|
Smartctl string
|
||||||
Lvs string
|
Lvs string
|
||||||
Blkid string // device signature probe (8C data-bearing detection)
|
Blkid string // device signature probe (8C data-bearing detection)
|
||||||
|
|||||||
@@ -17,12 +17,12 @@ import (
|
|||||||
// Four states (3A):
|
// Four states (3A):
|
||||||
// - new : durable-id NOT in the store. Never auto-mounted (the user must enroll it).
|
// - 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
|
// - 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.
|
// - ejected : an intentional, temporary unmount, set ONLY via the official eject endpoint.
|
||||||
// Present && unmounted → left alone. CLEARED to `enrolled` when the drive goes
|
// Present && unmounted → left alone. CLEARED to `enrolled` when the drive goes
|
||||||
// physically ABSENT, so a replug auto-mounts (the replug rule, for free).
|
// physically ABSENT, so a replug auto-mounts (the replug rule, for free).
|
||||||
// - decommissioned : permanent. Never auto-mounted; SURVIVES absent/present; cleared only by an
|
// - 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
|
// The elegant invariant: intent is recorded ONLY through the official enroll/eject/decommission
|
||||||
// paths. "Is it unmounted" ≠ "did someone officially eject it."
|
// 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
|
where string
|
||||||
want bool
|
want bool
|
||||||
}{
|
}{
|
||||||
{"/mnt/felhom-drives/live", true}, // real nfs4 (the autofs line for the same path must not confuse it)
|
{"/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/smb", true}, // cifs
|
||||||
{"/mnt/felhom-drives/idle", false}, // autofs trigger ONLY — idle automount is NOT mounted
|
{"/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/disk", false}, // a local fs at the path is not a network mount
|
||||||
{"/mnt/felhom-drives/nope", false}, // absent
|
{"/mnt/felhom-drives/nope", false}, // absent
|
||||||
}
|
}
|
||||||
for _, tc := range cases {
|
for _, tc := range cases {
|
||||||
if got := networkMountedIn(procMounts, tc.where); got != tc.want {
|
if got := networkMountedIn(procMounts, tc.where); got != tc.want {
|
||||||
|
|||||||
@@ -96,11 +96,11 @@ type Watchdog struct {
|
|||||||
now func() time.Time
|
now func() time.Time
|
||||||
spawn func(func()) // spawn a background task (overridable in tests; default `go f()`)
|
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`)
|
onAbsent func(durableID string) // P3: called when a known target goes ABSENT (clears `ejected`)
|
||||||
|
|
||||||
mu sync.Mutex
|
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
|
lastFire time.Time
|
||||||
fired bool // lastFire is valid
|
fired bool // lastFire is valid
|
||||||
pending bool // a transition is awaiting the debounce window
|
pending bool // a transition is awaiting the debounce window
|
||||||
|
|||||||
Reference in new issue
Block a user