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>
34 lines
1.4 KiB
HTML
34 lines
1.4 KiB
HTML
{{define "buildlog.html"}}<!doctype html>
|
|
<html lang="en"><head>{{template "head" .}}<title>{{.Cluster.AccountingName}} · build log</title>
|
|
<style>
|
|
#logbox{background:var(--code-bg);border:1px solid var(--rule);border-radius:4px;
|
|
height:62vh;min-height:320px;overflow:auto;padding:12px 14px}
|
|
#log{font-family:var(--mono);font-size:12px;line-height:1.5;white-space:pre-wrap;
|
|
word-break:break-word;margin:0}
|
|
.crumbs{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin:0 0 6px}
|
|
.crumbs a{color:var(--accent);text-decoration:none;font-size:13px}
|
|
.crumbs a:hover{text-decoration:underline}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
{{template "nav" .}}
|
|
<main>
|
|
<div class="crumbs">
|
|
<h1 style="margin:0">{{.Cluster.AccountingName}}</h1>
|
|
<span id="status" class="pill muted">{{.Cluster.State}}</span>
|
|
<span class="spacer" style="flex:1"></span>
|
|
<a href="/clusters">← Clusters</a>
|
|
<a href="/clusters/log?cluster={{.Cluster.SerialID}}">raw</a>
|
|
</div>
|
|
<p class="deck">Tenant {{.Cluster.TenantName}} · site {{.Cluster.Site}}. The log is
|
|
followed as it is written; it stops on its own when the build does.</p>
|
|
|
|
<div id="logbox"><pre id="log" data-cluster="{{.Cluster.SerialID}}"></pre></div>
|
|
|
|
<p class="age" style="margin-top:10px">Provisioning takes a few minutes. Closing this
|
|
page does not stop it — the build runs on the control plane, not in the browser.</p>
|
|
</main>
|
|
<script src="/static/buildlog.js"></script>
|
|
</body></html>
|
|
{{end}}
|