hub (unreleased): a give-up mark keeps its slot for a week after the box stops listing the guest (the commit's security review); docs for the CA copy's changeover
gates / gates (push) Successful in 2m10s
gates / gates (push) Successful in 2m10s
Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
This commit is contained in:
1 parent
78c08dc909
commit
d2683b28d3
7 files changed
+82
-12
No files matched your search
@@ -3313,6 +3313,9 @@ const guestPowerMaxEntries = 16
|
||||
// guestPowerMaxMarks bounds how many give-up marks ONE box can hold in the hub's settings at a time.
|
||||
const guestPowerMaxMarks = 8
|
||||
|
||||
// guestPowerMarkKeep: how long the mark of a guest the box stopped listing keeps its slot.
|
||||
const guestPowerMarkKeep = 7 * 24 * time.Hour
|
||||
|
||||
func (h *Handler) noteSignedJobOutcome(hostID, jobID, outcome, reason, op string) {
|
||||
switch outcome {
|
||||
case "rejected", "failed", "malformed":
|
||||
@@ -3380,20 +3383,22 @@ func (h *Handler) checkGuestPowerGaveUp(hostID, custID string, gave []hostGuestP
|
||||
prefix := fmt.Sprintf("guest_power:%s:", hostID)
|
||||
key := func(vmid int) string { return prefix + strconv.Itoa(vmid) }
|
||||
// The marks this box has now. The report's own guest list is the BOX's word too, so „the report lists the guest”
|
||||
// bounds nothing by itself (review, 2026-11-14): the number of marks per box is capped, and a mark for a guest the
|
||||
// box no longer lists is dropped — a destroyed guest must not hold a mark, or a slot, for ever.
|
||||
// bounds nothing by itself (review, 2026-11-14): one box holds at most guestPowerMaxMarks marks, and a mark for a
|
||||
// guest the box no longer lists keeps its slot for guestPowerMarkKeep before it is dropped. So a box that invents
|
||||
// new guests at every report gets guestPowerMaxMarks alarms in that time, not that many per report — each alarm
|
||||
// is mailed (the mail cooldown is per guest). A destroyed guest's mark still goes, a week later.
|
||||
raised := map[int]bool{}
|
||||
for _, k := range h.store.OSAlarmKeys(prefix) {
|
||||
vmid, err := strconv.Atoi(strings.TrimPrefix(k, prefix))
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
if !known[vmid] {
|
||||
if !known[vmid] && time.Since(h.store.OSAlarmRaised(k)) > guestPowerMarkKeep {
|
||||
_ = h.store.SetOSAlarmRaised(k, time.Time{})
|
||||
h.logger.Printf("[INFO] host %s: guest %d is no longer reported — its give-up mark is dropped", hostID, vmid)
|
||||
h.logger.Printf("[INFO] host %s: guest %d has not been reported for %s — its give-up mark is dropped", hostID, vmid, guestPowerMarkKeep)
|
||||
continue
|
||||
}
|
||||
raised[vmid] = true
|
||||
raised[vmid] = true // also a guest the box stopped listing, for guestPowerMarkKeep: its mark keeps its slot
|
||||
}
|
||||
for _, g := range gave {
|
||||
if g.VMID <= 0 || !known[g.VMID] || running[g.VMID] || raised[g.VMID] {
|
||||
|
||||
Reference in new issue
Block a user