hub (unreleased): the hub keeps and shows which boxes were accepted on a small system disk (D83, R-1398 part 2)
gates / gates (push) Successful in 3m40s
gates / gates (push) Successful in 3m40s
Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
This commit is contained in:
1 parent
8378dc446b
commit
c3fa43a486
10 files changed
+407
-1
No files matched your search
@@ -1264,11 +1264,29 @@ func (h *Handler) handleHostEnroll(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
var req struct {
|
||||
CustomerID string `json:"customer_id"`
|
||||
// D83 (R-1398 part 2): an install that went on with --accept-small-disk says so; a later installer may add
|
||||
// the size. An older installer sends neither. Anything but the JSON `true` is „not said”.
|
||||
SmallDisk json.RawMessage `json:"small_disk"`
|
||||
SystemDiskBytes json.RawMessage `json:"system_disk_bytes"`
|
||||
}
|
||||
if err := json.Unmarshal(body, &req); err != nil || req.CustomerID == "" {
|
||||
http.Error(w, "Invalid payload: customer_id required", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
// noteSmallDisk is called only where the enrolment is ANSWERED with a host id (after the passphrase check): a
|
||||
// request that is refused marks nothing.
|
||||
noteSmallDisk := func(hostID string) {
|
||||
if string(req.SmallDisk) != "true" {
|
||||
return
|
||||
}
|
||||
var n int64
|
||||
_ = json.Unmarshal(req.SystemDiskBytes, &n) // not a whole number → 0 = „not told”
|
||||
if err := h.store.NoteSmallDisk(hostID, n, time.Now().UTC()); err != nil {
|
||||
h.logger.Printf("[WARN] host-enroll: the small-disk mark of %s was not stored: %v", hostID, err)
|
||||
return
|
||||
}
|
||||
h.logger.Printf("[WARN] host-enroll: %s was installed with --accept-small-disk (a system disk below 200 GB); shown on the box's page", hostID)
|
||||
}
|
||||
|
||||
// Passphrase auth — mirrors handleConfigRetrieve exactly (header, 404-then-401 order,
|
||||
// constant-time compare). Happens BEFORE any mint.
|
||||
@@ -1322,6 +1340,7 @@ func (h *Handler) handleHostEnroll(w http.ResponseWriter, r *http.Request) {
|
||||
h.refusePassphraseKeys(w, r, req.CustomerID, "POST /host-enroll", why)
|
||||
return
|
||||
}
|
||||
noteSmallDisk(existing.HostID)
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
json.NewEncoder(w).Encode(map[string]string{"host_id": existing.HostID, "api_key": existing.APIKey})
|
||||
@@ -1356,6 +1375,7 @@ func (h *Handler) handleHostEnroll(w http.ResponseWriter, r *http.Request) {
|
||||
// customer (first provision). Also re-issue the off-site login (F3) — since hub v0.127.0 that is the
|
||||
// HUB's own Storage Box login, not something the fresh box receives (R-1158; see offsiteReissuer).
|
||||
h.reissueOnReenroll(cc)
|
||||
noteSmallDisk(hostID)
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusCreated)
|
||||
@@ -3682,6 +3702,9 @@ func (h *Handler) noteAppList(customerID string, body []byte) {
|
||||
Deployed []string `json:"deployed"`
|
||||
} `json:"stacks"`
|
||||
Offsite *struct {
|
||||
// Enabled: the report shows the off-site tier switched on. Only then is an app that is missing from
|
||||
// ended_apps a take-back (store.NoteEndNotices).
|
||||
Enabled bool `json:"enabled"`
|
||||
EndedApps []struct {
|
||||
App string `json:"app"`
|
||||
// The box's own dates. Carried on the wire for the operator's reading of a stored report; the
|
||||
@@ -3695,11 +3718,22 @@ func (h *Handler) noteAppList(customerID string, body []byte) {
|
||||
return
|
||||
}
|
||||
var claimed []string
|
||||
var presses []store.EndClaim
|
||||
if p.Offsite != nil {
|
||||
for _, e := range p.Offsite.EndedApps {
|
||||
claimed = append(claimed, e.App)
|
||||
presses = append(presses, store.EndClaim{App: e.App, Press: e.RemovedAt}) // the press's KEY, never a date
|
||||
}
|
||||
}
|
||||
// The notice lock (`09` §3 decision 315): the hub's own record of who must be told, and the sends (end_notice.go).
|
||||
// After the app record below, whatever it returns — a notice must not wait on another table's write.
|
||||
defer func() {
|
||||
if nerr := h.store.NoteEndNotices(customerID, p.Stacks.Deployed, presses, p.Offsite != nil && p.Offsite.Enabled, time.Now()); nerr != nil {
|
||||
h.logger.Printf("[WARN] [api] report from %s: the hub's own notice record could not be updated: %v", customerID, nerr)
|
||||
return
|
||||
}
|
||||
h.kickEndNotices(customerID)
|
||||
}()
|
||||
unseen, err := h.store.NoteAppListClaims(customerID, p.Stacks.Deployed, claimed, time.Now())
|
||||
if err != nil {
|
||||
h.logger.Printf("[WARN] [api] report from %s: the hub's own app record could not be updated: %v", customerID, err)
|
||||
|
||||
Reference in new issue
Block a user