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
@@ -0,0 +1,42 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"gitea.dooplex.hu/admin/felhom-hub/internal/store"
|
||||
)
|
||||
|
||||
// D83 (R-1398 part 2): the box's page says when the box was accepted on a small system disk — and says NOTHING for a
|
||||
// box the hub was never told about (an older installer, or a disk of 200 GB or more). One render per branch.
|
||||
func TestD83_HostPageShowsTheSmallDiskLine(t *testing.T) {
|
||||
s, st := newTestServer(t)
|
||||
for _, h := range []string{"small-1", "small-2", "plain-1"} {
|
||||
if err := st.UpsertHost(&store.Host{HostID: h, CustomerID: "c1", APIKey: "k-" + h}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
at := time.Date(2026, 11, 16, 9, 0, 0, 0, time.UTC)
|
||||
_ = st.NoteSmallDisk("small-1", 128035676160, at)
|
||||
_ = st.NoteSmallDisk("small-2", 0, at)
|
||||
page := func(id string) string {
|
||||
rr := httptest.NewRecorder()
|
||||
s.handleHostDetail(rr, httptest.NewRequest(http.MethodGet, "/hosts/"+id, nil), id)
|
||||
if rr.Code != http.StatusOK {
|
||||
t.Fatalf("%s: status %d", id, rr.Code)
|
||||
}
|
||||
return rr.Body.String()
|
||||
}
|
||||
if b := page("small-1"); !strings.Contains(b, `id="small-disk"`) || !strings.Contains(b, "accepted below 200 GB (128 GB, noted 2026-11-16)") {
|
||||
t.Fatalf("the page of a box accepted on 128 GB does not say so")
|
||||
}
|
||||
if b := page("small-2"); !strings.Contains(b, "accepted below 200 GB (size not told, noted 2026-11-16)") {
|
||||
t.Fatalf("the page of a box whose installer sent no size does not say „size not told”")
|
||||
}
|
||||
if b := page("plain-1"); strings.Contains(b, `id="small-disk"`) || strings.Contains(b, "accepted below 200 GB") {
|
||||
t.Fatalf("the page of a box the hub was never told about shows the small-disk line")
|
||||
}
|
||||
}
|
||||
@@ -871,6 +871,7 @@ func (s *Server) hostDetailData(host *store.Host, r *http.Request) map[string]in
|
||||
"CustomerID": host.CustomerID,
|
||||
"CustomerName": s.customerName(host.CustomerID),
|
||||
"AgentVersion": host.AgentVersion,
|
||||
"SmallDisk": smallDiskLine(s.store.SmallDiskOf(host.HostID)),
|
||||
"CreatedAt": host.CreatedAt,
|
||||
"Status": status,
|
||||
"StatusLabel": hostStatusLabel(s.hostDisplayStatus(host)),
|
||||
@@ -1169,3 +1170,21 @@ func (s *Server) offsiteIntegrityForHost(customerID string) string {
|
||||
}
|
||||
return offsiteIntegrityLine(rj)
|
||||
}
|
||||
|
||||
// smallDiskLine is the box page's line for a box that was installed with --accept-small-disk (D83, `16` §14.5;
|
||||
// R-1398 part 2). "" = the hub was never told: an older installer, or a disk of 200 GB or more — the page then says
|
||||
// nothing. Pinned by TestD83_HostPageShowsTheSmallDiskLine.
|
||||
func smallDiskLine(sd *store.SmallDisk) string {
|
||||
if sd == nil {
|
||||
return ""
|
||||
}
|
||||
size := "size not told"
|
||||
if sd.Bytes > 0 {
|
||||
size = fmt.Sprintf("%d GB", sd.Bytes/1000000000)
|
||||
}
|
||||
since := ""
|
||||
if !sd.NotedAt.IsZero() {
|
||||
since = ", noted " + sd.NotedAt.UTC().Format("2006-01-02")
|
||||
}
|
||||
return "accepted below 200 GB (" + size + since + ")"
|
||||
}
|
||||
@@ -22,6 +22,12 @@
|
||||
<span class="label">Agent Version</span>
|
||||
<span class="value">{{if .AgentVersion}}<code>{{.AgentVersion}}</code>{{else}}—{{end}}</span>
|
||||
</div>
|
||||
{{if .SmallDisk}}
|
||||
<div class="info-item" id="small-disk" title="The installer was run with --accept-small-disk: the system disk is below the 200 GB that Felhom needs (D83). The guest gets less space than a household is promised, and the box's local copies can stop when the disk fills.">
|
||||
<span class="label">System disk</span>
|
||||
<span class="value"><span class="badge badge-warn">small</span> {{.SmallDisk}}</span>
|
||||
</div>
|
||||
{{end}}
|
||||
{{if .AgentBinaryDrift}}
|
||||
<div class="info-item" id="agent-binary">
|
||||
<span class="label">Agent binary</span>
|
||||
|
||||
Reference in new issue
Block a user