carlos / platform Public

cli: after a size change, say memory applies at the next start or deploy (ruling 12)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev d8f40315d8a05353ab60c71e4bb439468de734b4 parent 07059d1
2 files changed, +18 −8
  • apps_policy.go +7 −0
  • apps_policy_test.go +11 −8
diff --git a/apps_policy.go b/apps_policy.go
index 93f739e24..75de82cf0 100644
--- a/apps_policy.go
+++ b/apps_policy.go
@@ -109,6 +109,11 @@ type sizeCommittedBox struct {
// review approves it.
const sizeCommittedLine = "%s: %d MiB committed to awake instances, of %d MiB. %d MiB free."
+// sizeTakesEffectLine is plan 3 copy string 7 (ruling 12), a draft until
+// the copy review approves it: printed after every size change, since
+// memory changes only at an instance's next start and CPU and IO at once.
+const sizeTakesEffectLine = "The new memory size applies when an instance next starts or is deployed. CPU and IO apply now."
+
// printSizeCommitted prints one line per box the console checked a size
// change against, in the order the reply gives them.
func printSizeCommitted(w io.Writer, boxes []sizeCommittedBox) {
@@ -280,6 +285,7 @@ func appsSetPolicyRun(ctx context.Context, sess *apiSession, acct apiAcct, app s
fmt.Fprintf(stdout, appsSetSizeDone+"\n", app, got.Policy.DefaultSize)
}
printSizeCommitted(stdout, got.Committed)
+ fmt.Fprintln(stdout, sizeTakesEffectLine)
}
return nil
}
@@ -298,6 +304,7 @@ func instancesSetSizeRun(ctx context.Context, sess *apiSession, acct apiAcct, ap
fmt.Fprintf(stdout, instancesSetSizeDefault+"\n", host)
}
printSizeCommitted(stdout, got.Committed)
+ fmt.Fprintln(stdout, sizeTakesEffectLine)
return nil
}
diff --git a/apps_policy_test.go b/apps_policy_test.go
index cd705cb48..aee1c1261 100644
--- a/apps_policy_test.go
+++ b/apps_policy_test.go
@@ -217,7 +217,7 @@ func TestInstancesSetSizeUsesThePolicyDoor(t *testing.T) {
if c.puts[0] != `{"size":{"host":"shop-a.example.com","value":"xlarge"}}` || c.ifMatch[0] != "e1" {
t.Fatalf("PUT %s If-Match %q", c.puts[0], c.ifMatch[0])
}
- if want := fmt.Sprintf(instancesSetSizeDone+"\n", "shop-a.example.com", "xlarge"); out.String() != want {
+ if want := fmt.Sprintf(instancesSetSizeDone+"\n", "shop-a.example.com", "xlarge") + sizeTakesEffectLine + "\n"; out.String() != want {
t.Fatalf("stdout = %q, want %q", out.String(), want)
}
@@ -230,7 +230,7 @@ func TestInstancesSetSizeUsesThePolicyDoor(t *testing.T) {
if c.puts[0] != `{"size":{"host":"shop-a.example.com","value":"default"}}` {
t.Fatalf("PUT %s", c.puts[0])
}
- if want := fmt.Sprintf(instancesSetSizeDefault+"\n", "shop-a.example.com"); out.String() != want {
+ if want := fmt.Sprintf(instancesSetSizeDefault+"\n", "shop-a.example.com") + sizeTakesEffectLine + "\n"; out.String() != want {
t.Fatalf("stdout = %q, want %q", out.String(), want)
}
@@ -369,7 +369,7 @@ func TestAppsSetRunPolicyChangePrintsWhatTheConsoleStored(t *testing.T) {
if err := appsSetRun(context.Background(), c.session(t), apiAcct{Seg: "bab"}, "shop", nil, nil, change); err != nil {
t.Fatal(err)
}
- want := fmt.Sprintf(appsSetEgressDone+"\n", "shop", "10.0.5.20, fd00:5::20") + fmt.Sprintf(appsSetSizeDone+"\n", "shop", "large")
+ want := fmt.Sprintf(appsSetEgressDone+"\n", "shop", "10.0.5.20, fd00:5::20") + fmt.Sprintf(appsSetSizeDone+"\n", "shop", "large") + sizeTakesEffectLine + "\n"
if out.String() != want {
t.Fatalf("stdout = %q, want %q", out.String(), want)
}
@@ -384,7 +384,7 @@ func TestAppsSetRunPolicyChangePrintsWhatTheConsoleStored(t *testing.T) {
if err := appsSetRun(context.Background(), c.session(t), apiAcct{Seg: "bab"}, "shop", nil, nil, change); err != nil {
t.Fatal(err)
}
- want = fmt.Sprintf(appsSetEgressCleared+"\n", "shop") + fmt.Sprintf(appsSetSizeCleared+"\n", "shop")
+ want = fmt.Sprintf(appsSetEgressCleared+"\n", "shop") + fmt.Sprintf(appsSetSizeCleared+"\n", "shop") + sizeTakesEffectLine + "\n"
if out.String() != want {
t.Fatalf("stdout = %q, want %q", out.String(), want)
}
@@ -463,9 +463,12 @@ func TestPrintSizeCommitted(t *testing.T) {
}
// After a size change, both verbs print the reply's committed lines under
-// the size line; an older console's reply, with no committed key, prints
-// none.
+// the size line, then when the new size takes effect (ruling 12); an older
+// console's reply, with no committed key, prints no committed line.
func TestSizeChangePrintsCommitted(t *testing.T) {
+ if sizeTakesEffectLine != "The new memory size applies when an instance next starts or is deployed. CPU and IO apply now." {
+ t.Fatalf("sizeTakesEffectLine = %q", sizeTakesEffectLine)
+ }
out := captureStdout(t)
committed := `"committed":[{"box":"annie","committed_mib":2304,"total_mib":3884,"free_mib":1200}]`
line := "annie: 2304 MiB committed to awake instances, of 3884 MiB. 1200 MiB free.\n"
@@ -479,7 +482,7 @@ func TestSizeChangePrintsCommitted(t *testing.T) {
if err := appsSetRun(context.Background(), c.session(t), apiAcct{Seg: "bab"}, "shop", nil, nil, change); err != nil {
t.Fatal(err)
}
- if want := fmt.Sprintf(appsSetSizeDone+"\n", "shop", "large") + line; out.String() != want {
+ if want := fmt.Sprintf(appsSetSizeDone+"\n", "shop", "large") + line + sizeTakesEffectLine + "\n"; out.String() != want {
t.Fatalf("apps set: stdout = %q, want %q", out.String(), want)
}
@@ -490,7 +493,7 @@ func TestSizeChangePrintsCommitted(t *testing.T) {
if err := instancesSetRun(context.Background(), c.session(t), apiAcct{Seg: "bab"}, "shop", "shop-a.example.com", nil, nil, &large); err != nil {
t.Fatal(err)
}
- if want := fmt.Sprintf(instancesSetSizeDone+"\n", "shop-a.example.com", "large") + line; out.String() != want {
+ if want := fmt.Sprintf(instancesSetSizeDone+"\n", "shop-a.example.com", "large") + line + sizeTakesEffectLine + "\n"; out.String() != want {
t.Fatalf("instances set: stdout = %q, want %q", out.String(), want)
}
}