Show a progress bar and live log while Hammerhead, edges and sites update
The updater reports each step (checking, downloading with percent, verifying, installing, restarting). Edges and sites send that progress and their log with their reports; Hammerhead serves it to a dialog that opens when an update starts, and keeps its own last update log on disk across the restart. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9bd48917c7
commit
2b7cb5dd35
11 files changed
+306
-13
No files matched your search
+28
-2
@@ -58,12 +58,23 @@ func TestEdgesAndSitesReportVersionsAndUpdateOnRequest(t *testing.T) {
|
||||
var edgeCalls, siteCalls atomic.Int32
|
||||
siteCfgHook = func(c *bamboo.Config) {
|
||||
c.Version, c.AutoUpdate = "v0.1.0", true
|
||||
c.UpdateNow = func(ctx context.Context) (string, error) { siteCalls.Add(1); return "", nil }
|
||||
c.UpdateNow = func(ctx context.Context, progress func(string, int, string)) (string, error) {
|
||||
siteCalls.Add(1)
|
||||
progress("checking", 10, "Checking for the newest release")
|
||||
progress("done", 100, "Already on the newest release")
|
||||
return "", nil
|
||||
}
|
||||
}
|
||||
defer func() { siteCfgHook = nil }()
|
||||
w := setup(t, blacktip.TraefikConfig{}, func(c *blacktip.Config) {
|
||||
c.Version, c.AutoUpdate = "v0.1.0", true
|
||||
c.UpdateNow = func(ctx context.Context) (string, error) { edgeCalls.Add(1); return "v0.2.0", nil }
|
||||
c.UpdateNow = func(ctx context.Context, progress func(string, int, string)) (string, error) {
|
||||
edgeCalls.Add(1)
|
||||
progress("downloading", 40, "Downloading blacktip_v0.2.0_linux_amd64.tar.gz")
|
||||
progress("downloading", 70, "Downloaded 28.0 of 40.0 MB (70%)")
|
||||
progress("restarting", 100, "Installed v0.2.0; restarting into it")
|
||||
return "v0.2.0", nil
|
||||
}
|
||||
})
|
||||
|
||||
waitFor(t, "the edge to report its version", func() bool { e := w.edgeRow(); return e.Version == "v0.1.0" && e.AutoUpdate })
|
||||
@@ -77,6 +88,17 @@ func TestEdgesAndSitesReportVersionsAndUpdateOnRequest(t *testing.T) {
|
||||
if edgeCalls.Load() != 1 {
|
||||
t.Fatalf("the edge ran its update %d times, want 1", edgeCalls.Load())
|
||||
}
|
||||
var log struct {
|
||||
Running bool
|
||||
Stage string
|
||||
Pct int
|
||||
Lines []string
|
||||
}
|
||||
w.admin.must("GET", "/api/edges/"+w.edge+"/update/log", nil, &log)
|
||||
text := strings.Join(log.Lines, "; ")
|
||||
if log.Running || log.Stage != "restarting" || log.Pct != 100 || !strings.Contains(text, "Update requested") || !strings.Contains(text, "Downloaded 28.0 of 40.0 MB") || !strings.Contains(text, "restarting into it") {
|
||||
t.Fatalf("edge update log: %+v (%s)", log, text)
|
||||
}
|
||||
|
||||
w.admin.must("POST", "/api/orgs/"+w.org+"/sites/"+w.site+"/update", nil, nil)
|
||||
waitFor(t, "the site to answer the update request", func() bool {
|
||||
@@ -86,6 +108,10 @@ func TestEdgesAndSitesReportVersionsAndUpdateOnRequest(t *testing.T) {
|
||||
if siteCalls.Load() != 1 {
|
||||
t.Fatalf("the site ran its update %d times, want 1", siteCalls.Load())
|
||||
}
|
||||
w.admin.must("GET", "/api/orgs/"+w.org+"/sites/"+w.site+"/update/log", nil, &log)
|
||||
if log.Running || log.Stage != "done" || !strings.Contains(strings.Join(log.Lines, "; "), "Already on the newest release") {
|
||||
t.Fatalf("site update log: %+v", log)
|
||||
}
|
||||
|
||||
// asking again works and is a fresh request, not a leftover answer
|
||||
w.admin.must("POST", "/api/edges/"+w.edge+"/update", nil, nil)
|
||||
|
||||
Reference in new issue
Block a user