Waiting for confirmation
A new system is active and not confirmed yet. Confirm it on the Overview, or the router goes back to the
@@ -99,7 +106,7 @@
Choose a channel to look for upgrades.
{{end}}
-{{if $d.Run.Log}}
+{{if and $d.Run.Log (not $d.Run.Running)}}
Last run{{if $d.Run.Result}} — {{if eq $d.Run.Result "success"}}succeeded{{else}}failed ({{$d.Run.Result}}){{end}}{{end}}
{{$d.Run.Log}}
diff --git a/pkgs/router-webui/upgrade.go b/pkgs/router-webui/upgrade.go
index 18be1c2..9945094 100644
--- a/pkgs/router-webui/upgrade.go
+++ b/pkgs/router-webui/upgrade.go
@@ -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 {
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")
}
+// 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 upgradeData struct {
@@ -146,7 +156,8 @@ type upgradeData struct {
Check *UpgradeCheck
Preview *UpgradePreview
Run UpgradeRun
- Updating bool // router-update is running
+ Title string // what the running step does
+ Updating bool // router-update is running
Pending bool // a system waits for confirmation
}
@@ -178,6 +189,12 @@ func (a *app) upgradeData() upgradeData {
d.Channel = s.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.
if data, err := os.ReadFile(filepath.Join(a.sys.upgradeDir(), "last.log")); err == nil {
d.Run.Log = tail(string(data), 64<<10)
diff --git a/pkgs/router-webui/upgrade_test.go b/pkgs/router-webui/upgrade_test.go
index 27edab3..18ced29 100644
--- a/pkgs/router-webui/upgrade_test.go
+++ b/pkgs/router-webui/upgrade_test.go
@@ -141,6 +141,9 @@ func TestUpgradePage(t *testing.T) {
if r := request(); r["action"] != "preview" || r["force"] != true || r["downgrade"] != true {
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 {
t.Fatalf("unknown step: %d", resp.StatusCode)
}