hub v0.137.0 source + burn-down round 2 in felhom.eu: R-277 R-581 R-600 R-544 R-855 R-134 R-92 R-292 R-599 R-725 R-728 (hub), R-819 R-857 R-555 R-364 R-587 (gates/tools), R-571 R-129 R-124-runbook (docs); 28 rows closed incl. catalog + agent v0.147.0 rows, R-350 merged into R-132, R-888 opened, R-887 mechanism (249 -> 222)
gates / gates (push) Successful in 2m3s
gates / gates (push) Successful in 2m3s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
This commit is contained in:
1 parent
e0d884565f
commit
557629d2bf
65 files changed
+2680
-122
No files matched your search
@@ -15,7 +15,7 @@ import (
|
||||
const drHostHalf = `{
|
||||
"recipe_version": 1,
|
||||
"guests": [ { "vmid": 9201, "cores": 4, "memory_bytes": 12884901888, "disk_bytes": 34359738368 } ],
|
||||
"pbs": { "repo_id": "felhom-pbs", "namespace": "root", "namespace_state": "resolved", "latest_snapshot_id": "9201" },
|
||||
"pbs": { "repo_id": "felhom-pbs", "namespace": "", "namespace_state": "resolved", "latest_snapshot_id": "9201" },
|
||||
"drives": [ { "durable_id": "uuid:da9e7089-cf8e-4617-adcb-a377743fae00", "mount_path": "/mnt/felhom-usb", "intent": "enrolled", "total_bytes": 1000000000000 } ],
|
||||
"pve_storage": [ { "name": "local-lvm", "type": "lvmthin", "content": "rootdir,images" }, { "name": "felhom-usb", "type": "usb", "content": "backup" } ],
|
||||
"backup_target": { "state": "resolved", "storage_id": "felhom-usb", "mount_path": "/mnt/felhom-usb" }
|
||||
@@ -147,7 +147,7 @@ func TestAssembleDRRecipe_V1DriveShape(t *testing.T) {
|
||||
const v1Host = `{
|
||||
"recipe_version": 1,
|
||||
"guests": [ { "vmid": 9201, "cores": 4, "memory_bytes": 12884901888, "disk_bytes": 34359738368 } ],
|
||||
"pbs": { "repo_id": "felhom-pbs", "namespace": "root", "latest_snapshot_id": "9201" },
|
||||
"pbs": { "repo_id": "felhom-pbs", "namespace": "", "latest_snapshot_id": "9201" },
|
||||
"drives": [ { "durable_id": "uuid:da9e7089", "mount_path": "/mnt/felhom-usb", "intent": "enrolled", "total_bytes": 1000000000000 } ],
|
||||
"pve_storage": [ { "name": "felhom-usb", "type": "usb", "content": "backup" } ]
|
||||
}`
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package store
|
||||
|
||||
import "testing"
|
||||
|
||||
// R-581: two reports for one customer inside the same second. received_at has second granularity, so
|
||||
// the dashboard's newest-report read must tie-break on insertion order — one row per customer, and it
|
||||
// is the SECOND report's health and version. The received_at values are forced equal so the tie is
|
||||
// certain rather than depending on the test's timing.
|
||||
func TestGetCustomers_SameSecondReportsOneRowNewestWins(t *testing.T) {
|
||||
s := langStore(t)
|
||||
if err := s.SaveReport("tie", []byte(`{"controller_version":"0.1.0","health":{"status":"fail"}}`)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := s.SaveReport("tie", []byte(`{"controller_version":"0.2.0","health":{"status":"ok"}}`)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := s.db.Exec(`UPDATE reports SET received_at = '2026-10-05 12:00:00' WHERE customer_id = 'tie'`); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
custs, err := s.GetCustomers()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var got []CustomerSummary
|
||||
for _, c := range custs {
|
||||
if c.CustomerID == "tie" {
|
||||
got = append(got, c)
|
||||
}
|
||||
}
|
||||
if len(got) != 1 {
|
||||
t.Fatalf("GetCustomers returned %d rows for one customer, want exactly 1", len(got))
|
||||
}
|
||||
if got[0].ControllerVersion != "0.2.0" || got[0].HealthStatus != "ok" {
|
||||
t.Fatalf("newest report lost the tie: version=%q health=%q, want 0.2.0/ok", got[0].ControllerVersion, got[0].HealthStatus)
|
||||
}
|
||||
|
||||
one, err := s.GetCustomer("tie")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if one.ControllerVersion != "0.2.0" {
|
||||
t.Fatalf("GetCustomer newest = %q, want 0.2.0", one.ControllerVersion)
|
||||
}
|
||||
}
|
||||
@@ -1317,7 +1317,10 @@ func (s *Store) LastEventAt(customerID, eventType string) (time.Time, error) {
|
||||
return parseSQLiteTime(createdAt), nil
|
||||
}
|
||||
|
||||
// GetCustomers returns the latest report summary for each customer.
|
||||
// GetCustomers returns the latest report summary for each customer. "Latest" is the highest
|
||||
// autoincrement id, NOT MAX(received_at): received_at has second granularity, and two reports in one
|
||||
// second joined on it returned BOTH rows (a duplicate customer) — R-581, pinned by
|
||||
// TestGetCustomers_SameSecondReportsOneRowNewestWins.
|
||||
func (s *Store) GetCustomers() ([]CustomerSummary, error) {
|
||||
rows, err := s.db.Query(`
|
||||
SELECT r.customer_id, r.received_at, r.report_json,
|
||||
@@ -1326,11 +1329,10 @@ func (s *Store) GetCustomers() ([]CustomerSummary, error) {
|
||||
r.backup_last_snapshot, r.controller_version, r.controller_url
|
||||
FROM reports r
|
||||
INNER JOIN (
|
||||
SELECT customer_id, MAX(received_at) as max_time
|
||||
SELECT customer_id, MAX(id) as max_id
|
||||
FROM reports
|
||||
GROUP BY customer_id
|
||||
) latest ON r.customer_id = latest.customer_id
|
||||
AND r.received_at = latest.max_time
|
||||
) latest ON r.id = latest.max_id
|
||||
ORDER BY r.customer_id`)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -1390,7 +1392,7 @@ func (s *Store) GetCustomer(customerID string) (*CustomerSummary, error) {
|
||||
backup_last_snapshot, controller_version, controller_url
|
||||
FROM reports
|
||||
WHERE customer_id = ?
|
||||
ORDER BY received_at DESC
|
||||
ORDER BY received_at DESC, id DESC
|
||||
LIMIT 1`, customerID)
|
||||
|
||||
var c CustomerSummary
|
||||
@@ -1443,7 +1445,7 @@ func (s *Store) GetCustomerHistory(customerID string, since time.Duration) ([]Cu
|
||||
backup_last_snapshot, controller_version, controller_url
|
||||
FROM reports
|
||||
WHERE customer_id = ? AND received_at >= ?
|
||||
ORDER BY received_at DESC`, customerID, cutoff)
|
||||
ORDER BY received_at DESC, id DESC`, customerID, cutoff)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
"guests": [
|
||||
{ "vmid": 9201, "cores": 4, "memory_bytes": 12884901888, "disk_bytes": 34359738368 }
|
||||
],
|
||||
"pbs": { "repo_id": "felhom-pbs", "namespace": "root", "namespace_state": "resolved", "latest_snapshot_id": "9201" },
|
||||
"pbs": { "repo_id": "felhom-pbs", "namespace": "", "namespace_state": "resolved", "latest_snapshot_id": "9201" },
|
||||
"drives": [
|
||||
{
|
||||
"durable_id": "uuid:da9e7089-cf8e-4617-adcb-a377743fae00",
|
||||
|
||||
Reference in new issue
Block a user