Show the log in the page over the site while updating or upgrading
The Update page's overlay carries the update's log; the Packages page gets an overlay too, named after the step that runs. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -60,6 +60,8 @@ section { margin: 0 0 1.5rem; }
|
|||||||
section.busy, section.pending { padding: .75rem 1rem; border-radius: var(--radius); background: var(--warn); }
|
section.busy, section.pending { padding: .75rem 1rem; border-radius: var(--radius); background: var(--warn); }
|
||||||
.upload-overlay { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, .55); padding: 1rem; }
|
.upload-overlay { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, .55); padding: 1rem; }
|
||||||
.upload-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 32px rgba(0, 0, 0, .35); padding: 1.25rem 1.5rem; width: min(30rem, 100%); }
|
.upload-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 32px rgba(0, 0, 0, .35); padding: 1.25rem 1.5rem; width: min(30rem, 100%); }
|
||||||
|
.upload-card.wide { width: min(48rem, 100%); }
|
||||||
|
.upload-card pre.log { margin: .75rem 0 0; max-height: min(18rem, 40vh); }
|
||||||
.upload-card h2 { margin: 0 0 .75rem; }
|
.upload-card h2 { margin: 0 0 .75rem; }
|
||||||
.upload-card progress { width: 100%; height: 1rem; accent-color: var(--accent); }
|
.upload-card progress { width: 100%; height: 1rem; accent-color: var(--accent); }
|
||||||
.upload-card p { margin: .6rem 0 0; font-size: .9rem; }
|
.upload-card p { margin: .6rem 0 0; font-size: .9rem; }
|
||||||
|
|||||||
@@ -11,10 +11,11 @@
|
|||||||
|
|
||||||
{{if $d.Status.Running}}
|
{{if $d.Status.Running}}
|
||||||
<div class="upload-overlay" role="dialog" aria-modal="true">
|
<div class="upload-overlay" role="dialog" aria-modal="true">
|
||||||
<div class="upload-card">
|
<div class="upload-card wide">
|
||||||
<h2>Updating…</h2>
|
<h2>Updating…</h2>
|
||||||
<progress max="100" value="{{$d.Progress}}"></progress>
|
<progress max="100" value="{{$d.Progress}}"></progress>
|
||||||
<p>{{$d.Step}}</p>
|
<p>{{$d.Step}}</p>
|
||||||
|
{{if $d.Status.Log}}<pre class="log">{{$d.Status.Log}}</pre>{{end}}
|
||||||
<p class="muted">This takes a few minutes. The page reloads when it is done; the web UI restarts when the new
|
<p class="muted">This takes a few minutes. The page reloads when it is done; the web UI restarts when the new
|
||||||
version is switched on, and you log in again.</p>
|
version is switched on, and you log in again.</p>
|
||||||
</div>
|
</div>
|
||||||
@@ -62,7 +63,7 @@
|
|||||||
<code>nix run .#release</code> writes. The data is signed, so plain HTTP works too.</p>
|
<code>nix run .#release</code> writes. The data is signed, so plain HTTP works too.</p>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
{{if $d.Status.Log}}
|
{{if and $d.Status.Log (not $d.Status.Running)}}
|
||||||
<section>
|
<section>
|
||||||
<h2>Last update{{if $d.Status.Result}} — {{if eq $d.Status.Result "success"}}succeeded{{else}}failed ({{$d.Status.Result}}){{end}}{{end}}</h2>
|
<h2>Last update{{if $d.Status.Result}} — {{if eq $d.Status.Result "success"}}succeeded{{else}}failed ({{$d.Status.Result}}){{end}}{{end}}</h2>
|
||||||
<pre class="log">{{$d.Status.Log}}</pre>
|
<pre class="log">{{$d.Status.Log}}</pre>
|
||||||
|
|||||||
@@ -26,7 +26,14 @@
|
|||||||
{{if $d.Updating}}
|
{{if $d.Updating}}
|
||||||
<section class="busy"><h2>Updating…</h2><p>The router is installing a new version of nixos-router.</p></section>
|
<section class="busy"><h2>Updating…</h2><p>The router is installing a new version of nixos-router.</p></section>
|
||||||
{{else if $d.Run.Running}}
|
{{else if $d.Run.Running}}
|
||||||
<section class="busy"><h2>Working…</h2><p>This page updates on its own. The web UI restarts when an upgrade is switched on.</p></section>
|
<div class="upload-overlay" role="dialog" aria-modal="true">
|
||||||
|
<div class="upload-card wide">
|
||||||
|
<h2>{{$d.Title}}</h2>
|
||||||
|
<progress max="100"></progress>
|
||||||
|
{{if $d.Run.Log}}<pre class="log">{{$d.Run.Log}}</pre>{{end}}
|
||||||
|
<p class="muted">The page reloads when it is done. The web UI restarts when an upgrade is switched on, and you log in again.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{{else if $d.Pending}}
|
{{else if $d.Pending}}
|
||||||
<section class="pending"><h2>Waiting for confirmation</h2>
|
<section class="pending"><h2>Waiting for confirmation</h2>
|
||||||
<p>A new system is active and not confirmed yet. Confirm it on the <a href="/">Overview</a>, or the router goes back to the
|
<p>A new system is active and not confirmed yet. Confirm it on the <a href="/">Overview</a>, or the router goes back to the
|
||||||
@@ -99,7 +106,7 @@
|
|||||||
<section><p>Choose a channel to look for upgrades.</p></section>
|
<section><p>Choose a channel to look for upgrades.</p></section>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{if $d.Run.Log}}
|
{{if and $d.Run.Log (not $d.Run.Running)}}
|
||||||
<section>
|
<section>
|
||||||
<h2>Last run{{if $d.Run.Result}} — {{if eq $d.Run.Result "success"}}succeeded{{else}}failed ({{$d.Run.Result}}){{end}}{{end}}</h2>
|
<h2>Last run{{if $d.Run.Result}} — {{if eq $d.Run.Result "success"}}succeeded{{else}}failed ({{$d.Run.Result}}){{end}}{{end}}</h2>
|
||||||
<pre class="log">{{$d.Run.Log}}</pre>
|
<pre class="log">{{$d.Run.Log}}</pre>
|
||||||
|
|||||||
@@ -134,9 +134,19 @@ func (s System) requestUpgrade(action string, force, downgrade bool, timeout str
|
|||||||
if err := writeFileAtomic(filepath.Join(s.upgradeDir(), "request.json"), data, 0o600); err != nil {
|
if err := writeFileAtomic(filepath.Join(s.upgradeDir(), "request.json"), data, 0o600); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
// The unit removes the request when it starts; the page says what runs.
|
||||||
|
writeFileAtomic(filepath.Join(s.upgradeDir(), "action"), []byte(action), 0o600)
|
||||||
return startUnit("router-upgrade.service")
|
return startUnit("router-upgrade.service")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// upgradeTitles say what a running step does, for the page over the site.
|
||||||
|
var upgradeTitles = map[string]string{
|
||||||
|
"check": "Checking for a newer revision…",
|
||||||
|
"preview": "Working out what would change…",
|
||||||
|
"download": "Downloading and building…",
|
||||||
|
"apply": "Upgrading…",
|
||||||
|
}
|
||||||
|
|
||||||
type channelChoice struct{ Value, Label string }
|
type channelChoice struct{ Value, Label string }
|
||||||
|
|
||||||
type upgradeData struct {
|
type upgradeData struct {
|
||||||
@@ -146,6 +156,7 @@ type upgradeData struct {
|
|||||||
Check *UpgradeCheck
|
Check *UpgradeCheck
|
||||||
Preview *UpgradePreview
|
Preview *UpgradePreview
|
||||||
Run UpgradeRun
|
Run UpgradeRun
|
||||||
|
Title string // what the running step does
|
||||||
Updating bool // router-update is running
|
Updating bool // router-update is running
|
||||||
Pending bool // a system waits for confirmation
|
Pending bool // a system waits for confirmation
|
||||||
}
|
}
|
||||||
@@ -178,6 +189,12 @@ func (a *app) upgradeData() upgradeData {
|
|||||||
d.Channel = s.channel()
|
d.Channel = s.channel()
|
||||||
}
|
}
|
||||||
d.Choices = channelChoices(d.Channel)
|
d.Choices = channelChoices(d.Channel)
|
||||||
|
if d.Run.Running {
|
||||||
|
data, _ := os.ReadFile(filepath.Join(a.sys.upgradeDir(), "action"))
|
||||||
|
if d.Title = upgradeTitles[strings.TrimSpace(string(data))]; d.Title == "" {
|
||||||
|
d.Title = "Working…"
|
||||||
|
}
|
||||||
|
}
|
||||||
// What router-upgrade printed: a finished one-shot unit has no journal to find.
|
// What router-upgrade printed: a finished one-shot unit has no journal to find.
|
||||||
if data, err := os.ReadFile(filepath.Join(a.sys.upgradeDir(), "last.log")); err == nil {
|
if data, err := os.ReadFile(filepath.Join(a.sys.upgradeDir(), "last.log")); err == nil {
|
||||||
d.Run.Log = tail(string(data), 64<<10)
|
d.Run.Log = tail(string(data), 64<<10)
|
||||||
|
|||||||
@@ -141,6 +141,9 @@ func TestUpgradePage(t *testing.T) {
|
|||||||
if r := request(); r["action"] != "preview" || r["force"] != true || r["downgrade"] != true {
|
if r := request(); r["action"] != "preview" || r["force"] != true || r["downgrade"] != true {
|
||||||
t.Fatalf("%v", r)
|
t.Fatalf("%v", r)
|
||||||
}
|
}
|
||||||
|
if data, _ := os.ReadFile(filepath.Join(a.sys.upgradeDir(), "action")); string(data) != "preview" {
|
||||||
|
t.Fatalf("the running step is not recorded: %q", data)
|
||||||
|
}
|
||||||
if resp := post("/upgrade/format-disk", url.Values{}); resp.StatusCode != http.StatusNotFound {
|
if resp := post("/upgrade/format-disk", url.Values{}); resp.StatusCode != http.StatusNotFound {
|
||||||
t.Fatalf("unknown step: %d", resp.StatusCode)
|
t.Fatalf("unknown step: %d", resp.StatusCode)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user