Asking for a cluster and building it were two clicks on two pages, with the record sitting at "requested" in between. Nobody wants the record; they want the cluster. Creating it now starts the build and opens the log. A portal with no provisioner still just records the request - that is all it can do - and lands on the list instead, and a build that fails to start does the same rather than showing an error page about a cluster that is nonetheless there. The log used to be a text endpoint you reloaded, which is the same information by a worse route: the interesting moment is usually the one you reloaded past. /clusters/watch follows it as it is written and stops on its own when the cluster stops moving. It polls rather than streams. A build is one writer appending to one file, and asking for the bytes after the ones you already have is the whole of what server-sent events would give here, without a long-lived connection to keep alive through Caddy and the proxy. ?from=N is what makes that cheap: a Terraform log reaches a few hundred kilobytes, and re-sending all of it every two seconds to append one line is most of a megabyte a minute for nothing. An offset past the end means a rebuild truncated the file, so the reader starts again rather than waiting for bytes that will never come. X-Cluster-State is read from the record, not guessed from the log's last line: a build that was killed writes no last line at all. The script backs off to five seconds while nothing is happening, and keeps the view pinned to the bottom only while the reader is already there - scrolling up to read something is deliberate, and yanking the view back down two seconds later undoes it. The script is a file rather than an inline block because the control plane's Content-Security-Policy is script-src 'self', and loosening that for a log viewer would be the wrong trade. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
90 lines
4.2 KiB
HTML
90 lines
4.2 KiB
HTML
{{define "clusters.html"}}<!doctype html>
|
|
<html lang="en"><head>{{template "head" .}}<title>Clusters · HPC on Demand</title></head>
|
|
<body>
|
|
{{template "nav" .}}
|
|
<main>
|
|
<h1>Clusters</h1>
|
|
<p class="deck">What has actually been handed out: who holds it, where it runs,
|
|
which hardware it is keeping, and how long it has left.</p>
|
|
|
|
{{if .Err}}<div class="note crit"><p>{{.Err}}</p></div>{{end}}
|
|
|
|
{{if .Clusters}}
|
|
<div class="card">
|
|
<div class="card-h"><span class="card-t">Live</span>
|
|
<span class="age">{{len .Clusters}} cluster(s)</span></div>
|
|
<table>
|
|
<thead><tr>
|
|
<th>Cluster</th><th>Tenant</th><th>Site</th><th>Hypervisor</th>
|
|
<th>Nodes</th><th>Hardware</th><th>State</th><th>Lease</th><th>Actions</th>
|
|
</tr></thead>
|
|
<tbody>
|
|
{{range .Clusters}}
|
|
<tr>
|
|
<td><code>{{.AccountingName}}</code><br>
|
|
{{if .PortalURL}}<a class="portal" href="{{.PortalURL}}" target="_blank" rel="noopener">Open portal ↗</a>
|
|
{{else}}<span class="age">id {{.ClusterID}}</span>{{end}}</td>
|
|
<td>{{.TenantName}}</td>
|
|
<td>{{.Site}}</td>
|
|
<td class="mono">{{.Hosts}}</td>
|
|
<td class="num">{{len .VMs}}</td>
|
|
<td>{{if .Devices}}{{range .Devices}}<code>{{.}}</code><br>{{end}}
|
|
{{else}}<span class="age">—</span>{{end}}</td>
|
|
<td><span class="pill {{if eq .State "ready"}}ok{{else if eq .State "failed"}}crit{{else}}warn{{end}}">{{.State}}</span></td>
|
|
<td>{{if .LeaseIn}}<span class="pill {{if .Expired}}crit{{else if .Expiring}}warn{{else}}muted{{end}}">{{.LeaseIn}}</span>
|
|
{{else}}<span class="age">no expiry</span>{{end}}</td>
|
|
<td>
|
|
{{if .MayAct}}
|
|
{{if .Building}}
|
|
<span class="pill warn">building…</span>
|
|
{{else if and $.CanBuild (or (eq .State "requested") (eq .State "failed"))}}
|
|
<form method="post" action="/clusters" class="inline"
|
|
onsubmit="return confirm('Build {{.AccountingName}}? This creates the machines and takes several minutes.')">
|
|
<input type="hidden" name="cluster" value="{{.SerialID}}">
|
|
<input type="hidden" name="do" value="build">
|
|
<button type="submit" class="small">{{if eq .State "failed"}}Retry build{{else}}Build{{end}}</button>
|
|
</form>
|
|
{{end}}
|
|
{{if .HasLog}}<a class="portal" href="/clusters/watch?cluster={{.SerialID}}">{{if .Building}}watch ↗{{else}}log ↗{{end}}</a>{{end}}
|
|
<form method="post" action="/clusters" class="inline">
|
|
<input type="hidden" name="cluster" value="{{.SerialID}}">
|
|
<input type="hidden" name="do" value="extend">
|
|
<input type="number" name="days" value="7" min="1" max="365" aria-label="days">
|
|
<button type="submit" class="small">Extend</button>
|
|
</form>
|
|
<form method="post" action="/clusters" class="inline"
|
|
onsubmit="return confirm('Release {{.AccountingName}}? The address and any hardware go back. This does not destroy the VMs.')">
|
|
<input type="hidden" name="cluster" value="{{.SerialID}}">
|
|
<input type="hidden" name="do" value="release">
|
|
<button type="submit" class="small danger">Release</button>
|
|
</form>
|
|
{{else}}<span class="age">—</span>{{end}}
|
|
</td>
|
|
</tr>
|
|
{{end}}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
{{if not .CanBuild}}
|
|
<div class="note"><p>This portal can allocate clusters but not build them: no
|
|
environment template is configured, so <code>requested</code> is as far as
|
|
they get here.</p></div>
|
|
{{end}}
|
|
|
|
<div class="note">
|
|
<p><strong>Release frees the record, not the machines.</strong> It returns the
|
|
address and the reserved hardware so the next request can have them, and keeps
|
|
the accounting name forever so two clusters' job records can never merge.
|
|
Destroying the VMs is a separate step.</p>
|
|
</div>
|
|
{{else if not .Err}}
|
|
<div class="card"><div class="card-b">
|
|
<p style="margin:0">No clusters are recorded. One appears here once
|
|
<code>POST /v1/clusters</code> allocates it.</p>
|
|
</div></div>
|
|
{{end}}
|
|
</main>
|
|
</body></html>
|
|
{{end}}
|