agent (unreleased): fixes after an independent review — one lock for the writers of agent.json, the trust run serialised and bounded, the CA copy keeps its previous root, the profile stanza from the wrapper's answer, a stale give-up ends, both boot tokens from one read
gates / gates (push) Successful in 48s
gates / gates (push) Successful in 48s
Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
This commit is contained in:
1 parent
61feb95c06
commit
ec7e699fd7
18 files changed
+333
-59
No files matched your search
@@ -152,6 +152,19 @@ func (s *Server) GuestPowerTick(ctx context.Context) {
|
||||
s.logger.Warn("guest-power: guest list unavailable — skipping sweep (ownership unproven)", "err", err)
|
||||
return
|
||||
}
|
||||
// A guest that left the list (destroyed, or re-made under another number) takes its attempt record with it — a
|
||||
// give-up for a guest that no longer exists would ride every host report until the agent restarts.
|
||||
present := make(map[int]bool, len(guests))
|
||||
for _, g := range guests {
|
||||
present[g.VMID] = true
|
||||
}
|
||||
guestPowerMu.Lock()
|
||||
for vmid := range s.guestPower {
|
||||
if !present[vmid] {
|
||||
delete(s.guestPower, vmid)
|
||||
}
|
||||
}
|
||||
guestPowerMu.Unlock()
|
||||
var stopped int
|
||||
for _, g := range guests {
|
||||
if ctx.Err() != nil {
|
||||
@@ -202,6 +215,7 @@ func (s *Server) recoverOneStoppedGuest(ctx context.Context, g proxmox.Guest) {
|
||||
// SCENARIO B — a deliberately stopped guest is left alone, forever. onboot:0 means the operator
|
||||
// (or the golden-image provisioning) does not want this guest running.
|
||||
if !onboot {
|
||||
s.forgetGuestPower(g.VMID) // not ours to start any more: a give-up for it must not be reported for ever
|
||||
return
|
||||
}
|
||||
|
||||
@@ -211,6 +225,7 @@ func (s *Server) recoverOneStoppedGuest(ctx context.Context, g proxmox.Guest) {
|
||||
if lock != "" {
|
||||
s.logger.Info("guest-power: guest is stopped but LOCKED — leaving it to the stale-lock path",
|
||||
"vmid", g.VMID, "lock", lock)
|
||||
s.forgetGuestPower(g.VMID) // another operation owns it now; if it ends stopped, the three tries start again
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user