Give the mirror a page, so managing it is not a curl command
/admin/mirror, behind the same admin session as the other admin pages. What is held, what is arriving with its byte count, what failed and why; start a fetch, retry a failed one, remove a version. Not mounted at all without a mirror configured. The right page for a deployment with no mirror is no page, rather than an empty one pointing at nothing. It reloads itself only while something is downloading. A reload at any other moment takes with it whatever is half-typed into the fetch form, and there is nothing to watch when nothing is moving. A failed row offers Retry, not Remove. A fetch that failed left nothing on disk, so the remove could only answer "the mirror holds nothing for this" — a button whose single outcome is a confusing error. Starting the same download again is what somebody looking at that row wants, and the mirror allows it: only a download still running is refused. An unreachable mirror is said outright instead of rendering as an empty table. The two look nearly identical and mean opposite things: one is a mirror waiting to be filled, the other is a machine to go and look at. Dashboard takes NavExtras rather than a second bool. Two adjacent booleans at a call site get swapped silently and are discovered by somebody clicking the wrong link. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
744a283cf1
commit
cd7eedf09e
17 files changed
+889
-24
No files matched your search
+14
-14
@@ -187,7 +187,7 @@ func (f fakeUsage) UsageSince(context.Context, time.Time) ([]store.KeyUsage, err
|
||||
}
|
||||
|
||||
func TestDashboardShowsTheCluster(t *testing.T) {
|
||||
h := Dashboard(fakeSource{}, fakeUsage{}, "v1", time.Second, true, nil)
|
||||
h := Dashboard(fakeSource{}, fakeUsage{}, "v1", time.Second, true, NavExtras{}, nil)
|
||||
code, body := get(t, h, "http://127.0.0.1:9090/", nil)
|
||||
if code != http.StatusOK {
|
||||
t.Fatalf("status %d", code)
|
||||
@@ -205,7 +205,7 @@ func TestDashboardShowsTheCluster(t *testing.T) {
|
||||
func TestDashboardExplainsOnlyWhatIsUnplaced(t *testing.T) {
|
||||
// Asking why a satisfied model was not placed gives an empty answer, and a
|
||||
// page full of empty answers hides the one that matters.
|
||||
h := Dashboard(fakeSource{}, nil, "v1", time.Second, true, nil)
|
||||
h := Dashboard(fakeSource{}, nil, "v1", time.Second, true, NavExtras{}, nil)
|
||||
_, body := get(t, h, "http://127.0.0.1:9090/", nil)
|
||||
|
||||
if !strings.Contains(body, "needs 8") {
|
||||
@@ -219,7 +219,7 @@ func TestDashboardExplainsOnlyWhatIsUnplaced(t *testing.T) {
|
||||
func TestDashboardSurvivesAFailingUsageQuery(t *testing.T) {
|
||||
// A reporting query failing must not take the page with it: the cluster
|
||||
// state is what someone is most likely here for.
|
||||
h := Dashboard(fakeSource{}, fakeUsage{err: context.DeadlineExceeded}, "v1", time.Second, true, nil)
|
||||
h := Dashboard(fakeSource{}, fakeUsage{err: context.DeadlineExceeded}, "v1", time.Second, true, NavExtras{}, nil)
|
||||
code, body := get(t, h, "http://127.0.0.1:9090/", nil)
|
||||
if code != http.StatusOK {
|
||||
t.Fatalf("status %d", code)
|
||||
@@ -230,7 +230,7 @@ func TestDashboardSurvivesAFailingUsageQuery(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDashboardSaysWhenThereIsNothingToAccount(t *testing.T) {
|
||||
h := Dashboard(fakeSource{}, nil, "v1", time.Second, true, nil)
|
||||
h := Dashboard(fakeSource{}, nil, "v1", time.Second, true, NavExtras{}, nil)
|
||||
_, body := get(t, h, "http://127.0.0.1:9090/", nil)
|
||||
if !strings.Contains(body, "Authentication is off") {
|
||||
t.Error("the page does not explain the empty usage section")
|
||||
@@ -240,7 +240,7 @@ func TestDashboardSaysWhenThereIsNothingToAccount(t *testing.T) {
|
||||
func TestDashboardRendersAnEmptyCluster(t *testing.T) {
|
||||
// The state a fresh install is in, and the one most likely to be looked at
|
||||
// with a template that has never seen it.
|
||||
h := Dashboard(emptySource{}, nil, "v1", time.Second, true, nil)
|
||||
h := Dashboard(emptySource{}, nil, "v1", time.Second, true, NavExtras{}, nil)
|
||||
code, body := get(t, h, "http://127.0.0.1:9090/", nil)
|
||||
if code != http.StatusOK {
|
||||
t.Fatalf("status %d", code)
|
||||
@@ -381,7 +381,7 @@ func TestTheDashboardDrawsTrafficWhenThereIsSome(t *testing.T) {
|
||||
{Start: now.Add(-time.Hour)},
|
||||
{Start: now, Requests: 95, Prompt: 9000, Completion: 2100, LatencyMs: 310},
|
||||
}}
|
||||
h := Dashboard(fakeSource{}, usage, "v1", time.Second, true, nil)
|
||||
h := Dashboard(fakeSource{}, usage, "v1", time.Second, true, NavExtras{}, nil)
|
||||
_, body := get(t, h, "http://127.0.0.1:9090/", nil)
|
||||
|
||||
if !strings.Contains(body, "<svg") {
|
||||
@@ -398,7 +398,7 @@ func TestTheDashboardDrawsTrafficWhenThereIsSome(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestTheDashboardSaysWhenThereIsNoTrafficYet(t *testing.T) {
|
||||
h := Dashboard(fakeSource{}, fakeUsage{}, "v1", time.Second, true, nil)
|
||||
h := Dashboard(fakeSource{}, fakeUsage{}, "v1", time.Second, true, NavExtras{}, nil)
|
||||
_, body := get(t, h, "http://127.0.0.1:9090/", nil)
|
||||
if !strings.Contains(body, "No traffic recorded yet") {
|
||||
t.Error("an empty history renders nothing at all")
|
||||
@@ -414,7 +414,7 @@ func TestTheDashboardOffersOnlyLinksThatExistWhereItIsServed(t *testing.T) {
|
||||
// through to the API-key middleware, so a visitor clicking "metrics" was
|
||||
// told "no api key was provided", which is a far more confusing way to say
|
||||
// the link does not belong there.
|
||||
_, admin := get(t, Dashboard(fakeSource{}, nil, "v1", time.Second, true, nil),
|
||||
_, admin := get(t, Dashboard(fakeSource{}, nil, "v1", time.Second, true, NavExtras{}, nil),
|
||||
"http://127.0.0.1:9090/", nil)
|
||||
for _, want := range []string{`href="/metrics"`, `href="/debug/pprof/"`, `href="/api/v1/nodes"`} {
|
||||
if !strings.Contains(admin, want) {
|
||||
@@ -425,7 +425,7 @@ func TestTheDashboardOffersOnlyLinksThatExistWhereItIsServed(t *testing.T) {
|
||||
t.Error("the admin listener's page links to a page only the public port serves")
|
||||
}
|
||||
|
||||
_, public := get(t, Dashboard(fakeSource{}, nil, "v1", time.Second, false, nil),
|
||||
_, public := get(t, Dashboard(fakeSource{}, nil, "v1", time.Second, false, NavExtras{}, nil),
|
||||
"https://llmgw.example/admin", nil)
|
||||
for _, unwanted := range []string{`href="/metrics"`, `href="/debug/pprof/"`, `href="/api/v1/nodes"`} {
|
||||
if strings.Contains(public, unwanted) {
|
||||
@@ -447,7 +447,7 @@ func TestTheDashboardShowsCapacityWithoutPrometheus(t *testing.T) {
|
||||
// is should not require standing up a monitoring stack beside it. The
|
||||
// tables say what exists; this says how much of it is in use, which is the
|
||||
// question asked first.
|
||||
h := Dashboard(fakeSource{}, fakeUsage{}, "v1", time.Second, true, nil)
|
||||
h := Dashboard(fakeSource{}, fakeUsage{}, "v1", time.Second, true, NavExtras{}, nil)
|
||||
code, page := get(t, h, "http://127.0.0.1:9090/", nil)
|
||||
if code != http.StatusOK {
|
||||
t.Fatalf("status %d", code)
|
||||
@@ -466,7 +466,7 @@ func TestTheDashboardShowsCapacityWithoutPrometheus(t *testing.T) {
|
||||
func TestAFaultyCardIsShownAsNeitherUsedNorFree(t *testing.T) {
|
||||
// Counting a faulty card as free is how a cluster looks like it has room it
|
||||
// does not, and the page must not disagree with the scheduler about that.
|
||||
h := Dashboard(fakeSource{}, fakeUsage{}, "v1", time.Second, true, nil)
|
||||
h := Dashboard(fakeSource{}, fakeUsage{}, "v1", time.Second, true, NavExtras{}, nil)
|
||||
code, page := get(t, h, "http://127.0.0.1:9090/", nil)
|
||||
if code != http.StatusOK {
|
||||
t.Fatalf("status %d", code)
|
||||
@@ -499,7 +499,7 @@ func TestTheDashboardShowsWhoIsUsingTheCluster(t *testing.T) {
|
||||
// Per key is the right unit for revoking something and the wrong one for
|
||||
// answering who is using this cluster: one person holds a laptop key, a CI
|
||||
// key and a notebook key, and adding three rows up by eye gets skipped.
|
||||
h := Dashboard(fakeSource{}, fakeUsage{}, "v1", time.Second, true, nil)
|
||||
h := Dashboard(fakeSource{}, fakeUsage{}, "v1", time.Second, true, NavExtras{}, nil)
|
||||
code, page := get(t, h, "http://127.0.0.1:9090/", nil)
|
||||
if code != http.StatusOK {
|
||||
t.Fatalf("status %d", code)
|
||||
@@ -517,7 +517,7 @@ func TestTheDashboardShowsWhoIsUsingTheCluster(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestTheDashboardShowsWhatIsActuallyRunning(t *testing.T) {
|
||||
h := Dashboard(fakeSource{}, fakeUsage{}, "v1", time.Second, true, nil)
|
||||
h := Dashboard(fakeSource{}, fakeUsage{}, "v1", time.Second, true, NavExtras{}, nil)
|
||||
_, page := get(t, h, "http://127.0.0.1:9090/", nil)
|
||||
for _, want := range []string{"What is being run", "qwen-coder", "240 ms"} {
|
||||
if !strings.Contains(page, want) {
|
||||
@@ -529,7 +529,7 @@ func TestTheDashboardShowsWhatIsActuallyRunning(t *testing.T) {
|
||||
func TestAReportingFailureDoesNotTakeThePageWithIt(t *testing.T) {
|
||||
// The cluster state is what someone is most likely here for, and a usage
|
||||
// query is the part most likely to be slow or broken.
|
||||
h := Dashboard(fakeSource{}, brokenUsage{}, "v1", time.Second, true, nil)
|
||||
h := Dashboard(fakeSource{}, brokenUsage{}, "v1", time.Second, true, NavExtras{}, nil)
|
||||
code, page := get(t, h, "http://127.0.0.1:9090/", nil)
|
||||
if code != http.StatusOK {
|
||||
t.Fatalf("status %d; a reporting failure took the page down", code)
|
||||
|
||||
Reference in new issue
Block a user