carlos / platform Public

offline move: status after an abort from staging says nothing moved

#339 item 2. The status of a move aborted while staging said "Moving
<host> back to <region>" and listed every manifest item as waiting.
The console now sends no items for a move that never went offline,
and the CLI says nothing moved, then that the staged copy is being or
has been removed, ignoring items an older console still sends.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 3a821c7d5a73330f4413d88299ab5b802fc2c909 parent 6020440
4 files changed, +52 −3
  • internal/console/apiinstancemove_offline.go +5 −1
  • internal/console/apiinstancemove_offline_stage_test.go +7 −2
  • move.go +16 −0
  • move_test.go +24 −0
diff --git a/internal/console/apiinstancemove_offline.go b/internal/console/apiinstancemove_offline.go
index a3746bea8..3ccf034a7 100644
--- a/internal/console/apiinstancemove_offline.go
+++ b/internal/console/apiinstancemove_offline.go
@@ -1401,7 +1401,11 @@ func (s *Server) offlineViewOf(ctx context.Context, rec *provision.Record) offli
for _, r := range ev.reports {
v.Reports = append(v.Reports, offlineReportView{OfflineReport: r.OfflineReport, Fresh: offlineFresh(r.OfflineReport, now)})
}
- v.Items = offlineItems(ev, mv)
+ // A move that never went offline (staging, or reverting from it) has
+ // checked nothing of the manifest, so it lists no item as waiting.
+ if !v.NeverOffline {
+ v.Items = offlineItems(ev, mv)
+ }
v.Stage = offlineStageOf(ev)
for _, r := range ev.byRole(moves.OfflineRoleSource) {
for _, p := range r.Retired {
diff --git a/internal/console/apiinstancemove_offline_stage_test.go b/internal/console/apiinstancemove_offline_stage_test.go
index 29a31e63b..47d163778 100644
--- a/internal/console/apiinstancemove_offline_stage_test.go
+++ b/internal/console/apiinstancemove_offline_stage_test.go
@@ -162,8 +162,13 @@ func TestOfflineAbortFromStagingDoor(t *testing.T) {
w := newOfflineWorld(t, oneEach...)
w.stage()
w.staged("ie-box", nil)
- if v := w.ok("/abort", "", provision.OfflineReverting); !v.NeverOffline {
- t.Fatal("an abort from staging does not say the instance was never offline")
+ if v := w.ok("/abort", "", provision.OfflineReverting); !v.NeverOffline || len(v.Items) != 0 {
+ t.Fatalf("an abort from staging: never offline %v, items %v", v.NeverOffline, v.Items)
+ }
+ // Nothing of the manifest was ever checked, so the status lists no
+ // item as waiting (#339, item 2).
+ if st := w.status(); len(st.Items) != 0 {
+ t.Fatalf("the status of an abort from staging lists %d items", len(st.Items))
}
if rec := w.record(); rec.Region != "ie" || rec.Move.State != provision.OfflineReverting {
t.Fatalf("after abort: %q %+v", rec.Region, rec.Move)
diff --git a/move.go b/move.go
index 29d6eb566..a897a2d3f 100644
--- a/move.go
+++ b/move.go
@@ -1498,6 +1498,17 @@ func (w *offlineRun) headline(r offlineReply) {
w.sayWaiting(r)
return
}
+ if v.State == provision.OfflineReverting && v.NeverOffline {
+ // An abort from staging: nothing moved and nothing comes back,
+ // only the staged copy goes (#339).
+ moveSay(w.m.out, fmt.Sprintf("Nothing moved. The stage of %s was abandoned, and %s kept serving in %s.", host, host, v.fromPlace()))
+ if v.Next == "finish" {
+ moveSay(w.m.out, fmt.Sprintf("The staged copy of %s is removed. Run carlos move offline finish --host %s to end the move.", host, host))
+ } else {
+ moveSay(w.m.out, fmt.Sprintf("Removing the staged copy of %s from %s.", host, v.toPlace()))
+ }
+ return
+ }
moveSay(w.m.out, moves.MoveStartingLine(host, v.fromPlace(), v.toPlace()))
if w.sayFailure(v) {
return
@@ -1600,6 +1611,11 @@ func (w *offlineRun) runStatus(ctx context.Context) int {
}
failed := false
for _, it := range v.Items {
+ if v.NeverOffline {
+ // Nothing of the manifest is checked for a move that never
+ // went offline; an older console still sends the items.
+ break
+ }
if it.Diagnostic == "" {
moveSay(w.m.out, fmt.Sprintf("Item %s is %s.", it.Slug, it.Check))
} else {
diff --git a/move_test.go b/move_test.go
index d64b063e4..be2a38120 100644
--- a/move_test.go
+++ b/move_test.go
@@ -1914,6 +1914,30 @@ func TestMoveOfflineAbortStaged(t *testing.T) {
}
}
+// status after an abort from staging (#339, item 2): nothing moved, so it
+// says so, and lists no item as waiting even from a console that still
+// sends the manifest's items.
+func TestMoveOfflineStatusAfterAStagedAbort(t *testing.T) {
+ const nothing = "Nothing moved. The stage of acme.shop.example.com was abandoned, and acme.shop.example.com kept serving in ie."
+ items := []frame{{"id": "db", "owner": "landing", "status": "waiting"}, {"id": "files", "owner": "landing", "status": "waiting"}}
+ c := &fakeOfflineConsole{gets: []frame{offView("offline-reverting", frame{"never_offline": true, "sealer": "", "items": items,
+ "reports": []frame{offReport("ie-box", "source", "reverted", true)}})}}
+ code, out := runOfflineAgainst(t, c, "status")
+ if want := nothing + "\n" + oUnstage + "\nie-box is reverted as the source.\n"; code != 0 || out != want {
+ t.Fatalf("exit %d, output:\n%s\nwant 0:\n%s", code, out, want)
+ }
+ c = &fakeOfflineConsole{gets: []frame{offView("offline-reverting", frame{"never_offline": true, "sealer": "", "next": "finish", "items": items})}}
+ code, out = runOfflineAgainst(t, c, "status")
+ if want := nothing + "\n" + oUnstaged + "\n"; code != 0 || out != want {
+ t.Fatalf("exit %d, output:\n%s\nwant 0:\n%s", code, out, want)
+ }
+ for _, line := range []string{oStarting, oBack, "Item "} {
+ if strings.Contains(out, line) {
+ t.Fatalf("the status of a staged abort says %q:\n%s", line, out)
+ }
+ }
+}
+
// TestMoveLinesNameRegionsByLabel: surface 25. Labels in every sentence,
// the request still sends the code.
func TestMoveLinesNameRegionsByLabel(t *testing.T) {