system: refuse binaries without ingress-proxy-v2 on armed boxes
carlos version --json prints the build and its features. A box whose host.env (or process env) sets CARLOS_INGRESS_PROXY_SOURCES refuses to activate a binary that does not report ingress-proxy-v2: in stageCandidate (apply, adoption, install-channel), operator rollback before groupTarget and the journal, apply's rollback before its drain and quiesce, recovery before the restore, and the restore copy before its rename. The recovery unit gates carlos.prev on the new carlos system proxy-allows-prev verb.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
13 files changed,
+859
−8
commands.go+26 −4commands_test.go+36 −0internal/host/execsandboxfloor_test.go+3 −2internal/host/group_maintenance_prepare.go+9 −0internal/host/installchannel.go+1 −1internal/host/proxyfeature.go+178 −0internal/host/proxyfeature_linux_test.go+89 −0internal/host/proxyfeature_test.go+461 −0internal/host/systemapply.go+32 −0internal/host/units/carlos-system-recover.service+8 −1internal/version/features.go+11 −0system.go+3 −0testdata/clireg-golden.jsonl+2 −0
Intent
diff --git a/commands.go b/commands.go| index 75cb03339..27fe1d7a6 100644 |
| --- a/commands.go |
| +++ b/commands.go |
| @@ -2,7 +2,9 @@ package main |
| import ( |
| "context" |
| + "encoding/json" |
| "fmt" |
| + "io" |
| "log" |
| "os" |
| "sort" |
| @@ -207,8 +209,10 @@ func shimNodes() []*clireg.Node { |
| // existence types it. `carlos version target ...` is the only string that |
| // dispatches anywhere new (release versioning spec, 2026-08-08): a sub-verb |
| // rather than a top-level `carlos target`, because what it sets IS the |
| -// app's version, and it reads that way at the terminal. Any other word or |
| -// flag after `version` still prints the build id. |
| +// app's version, and it reads that way at the terminal. `carlos version |
| +// --json`, the flag alone, is the build and its features as one JSON line |
| +// (edge PPv2 spec §7.3), which a box reads before it activates a binary. |
| +// Any other word or flag after `version` still prints the build id. |
| func versionCommand() *clireg.Node { |
| return noHint(&clireg.Node{ |
| Name: "version", |
| @@ -216,8 +220,8 @@ func versionCommand() *clireg.Node { |
| Children: []*clireg.Node{raw("target", clireg.Customer, runVersionTarget)}, |
| DefaultLeaf: &clireg.Node{ |
| Audience: clireg.Customer, |
| - Run: func(*clireg.Invocation) error { |
| - fmt.Printf("carlos %s\n", version.Build) |
| + Run: func(inv *clireg.Invocation) error { |
| + writeVersion(stdout, inv.Raw) |
| return nil |
| }, |
| }, |
| @@ -225,6 +229,24 @@ func versionCommand() *clireg.Node { |
| }) |
| } |
| +// writeVersion prints `carlos version`: "carlos <build>" exactly as ever, |
| +// or, for the one argument --json, {"version":"<build>","features":[...]}. |
| +// A binary from before the features list prints its bare line for --json |
| +// too, which is how a box tells it has none. Write errors are ignored, as |
| +// fmt.Printf's always were here. |
| +func writeVersion(w io.Writer, args []string) { |
| + if len(args) == 1 && (args[0] == "--json" || args[0] == "-json") { |
| + // Marshal of two strings and a string slice cannot fail. |
| + b, _ := json.Marshal(struct { |
| + Version string `json:"version"` |
| + Features []string `json:"features"` |
| + }{version.Build, version.Features}) |
| + fmt.Fprintf(w, "%s\n", b) |
| + return |
| + } |
| + fmt.Fprintf(w, "carlos %s\n", version.Build) |
| +} |
| + |
| func runDemoSnapshot(args []string) { |
| if len(args) != 0 { |
| log.Fatal(democlaim.ErrSnapshot) |
diff --git a/commands_test.go b/commands_test.go| index b915c3a06..009ecb229 100644 |
| --- a/commands_test.go |
| +++ b/commands_test.go |
| @@ -1,11 +1,14 @@ |
| package main |
| import ( |
| + "encoding/json" |
| + "slices" |
| "sort" |
| "strings" |
| "testing" |
| "github.com/carlosframework/platform/internal/clireg" |
| + "github.com/carlosframework/platform/internal/version" |
| ) |
| // TestCommandTreeIsValid is spec A8: Validate runs here, never at init |
| @@ -111,3 +114,36 @@ func TestUpdateHintSkippedPerPath(t *testing.T) { |
| } |
| } |
| } |
| + |
| +// TestVersionJSONHasFeatures pins `carlos version --json` (edge PPv2 spec |
| +// §7.3): one JSON line with the build and its features, which a box armed |
| +// for PROXY protocol reads before it activates a binary. Bare `carlos |
| +// version`, and every other argument, still prints the build id line that |
| +// install scripts parse, byte for byte. |
| +func TestVersionJSONHasFeatures(t *testing.T) { |
| + run := func(args ...string) string { |
| + out := captureStdout(t) |
| + clireg.Dispatch(commandRoot(), append([]string{"version"}, args...)) |
| + return out.String() |
| + } |
| + bare := "carlos " + version.Build + "\n" |
| + for _, args := range [][]string{nil, {"foo"}, {"-h"}, {"--json", "x"}, {"--zz"}} { |
| + if got := run(args...); got != bare { |
| + t.Errorf("carlos version %v printed %q, want %q", args, got, bare) |
| + } |
| + } |
| + want := `{"version":"` + version.Build + `","features":["ingress-proxy-v2"]}` + "\n" |
| + for _, flag := range []string{"--json", "-json"} { |
| + got := run(flag) |
| + if got != want { |
| + t.Fatalf("carlos version %s printed %q, want %q", flag, got, want) |
| + } |
| + var v struct { |
| + Version string `json:"version"` |
| + Features []string `json:"features"` |
| + } |
| + if err := json.Unmarshal([]byte(got), &v); err != nil || v.Version != version.Build || !slices.Contains(v.Features, version.FeatureIngressProxyV2) { |
| + t.Fatalf("carlos version %s: %+v %v", flag, v, err) |
| + } |
| + } |
| +} |
diff --git a/internal/host/execsandboxfloor_test.go b/internal/host/execsandboxfloor_test.go| index e7763fe25..d34c627f0 100644 |
| --- a/internal/host/execsandboxfloor_test.go |
| +++ b/internal/host/execsandboxfloor_test.go |
| @@ -149,9 +149,10 @@ func TestExecSandboxRecoveryUnit(t *testing.T) { |
| if strings.Count(command, gate) != 1 || strings.ContainsAny(command, "%$") { |
| t.Fatalf("bad recovery command %s", command) |
| } |
| - // Preserve the old expression byte for byte except for the one gate. |
| + // Preserve the old expression byte for byte except for the one gate |
| + // and, after it, the PROXY protocol gate (TestRecoverUnitGatesPrev). |
| original := `if [ -x /opt/carlos/system/guard/carlos ] && { [ -e /var/lib/carlos-claims/authority/exec/census.json ] || [ -L /var/lib/carlos-claims/authority/exec/census.json ] || [ -e /opt/carlos/system/guard/moves ] || [ -L /opt/carlos/system/guard/moves ]; }; then exec /opt/carlos/system/guard/carlos system guard-exec recover; fi; if [ -f /opt/carlos/system/router/journal.json ] && [ -x /opt/carlos/carlos.prev ] && [ ! -L /data/.moves/floor.min-release ] && { [ ! -e /data/.moves/floor.min-release ] || [ -f /data/.moves/floor.min-release ]; } && { ! [ -s /data/.moves/floor.min-release ] || /opt/carlos/carlos.prev system floor-allows-prev /data/.moves/floor.min-release /opt/carlos/carlos.prev.allowed; } && [ ! -L /data/.moves/seeds-floor.min-release ] && { [ ! -e /data/.moves/seeds-floor.min-release ] || [ -f /data/.moves/seeds-floor.min-release ]; } && { ! [ -s /data/.moves/seeds-floor.min-release ] || /opt/carlos/carlos.prev system floor-allows-prev /data/.moves/seeds-floor.min-release /opt/carlos/carlos.prev.seeds-allowed; }; then exec /opt/carlos/carlos.prev system apply --recover; fi; exec /opt/carlos/carlos system apply --recover` |
| - if strings.Replace(command, gate, "", 1) != original { |
| + if strings.Replace(strings.Replace(command, gate+proxyRecoveryGate, gate, 1), gate, "", 1) != original { |
| t.Fatal("recovery changed outside gate") |
| } |
| for _, gateBody := range []string{"exit 1\n", "missing"} { |
diff --git a/internal/host/group_maintenance_prepare.go b/internal/host/group_maintenance_prepare.go| index 5a2f70bb2..d6ebd2139 100644 |
| --- a/internal/host/group_maintenance_prepare.go |
| +++ b/internal/host/group_maintenance_prepare.go |
| @@ -299,6 +299,15 @@ func (cmd *groupMaintenanceCommand) rollback(ctx context.Context, c *hostenv.Gro |
| } |
| func (a *systemApplier) rollbackCompletedApply(ctx context.Context) error { |
| + // The activation guard (edge PPv2 spec §7.3) first, before groupTarget |
| + // consumes the permit and clears the hairpin, and before anything is |
| + // staged, begun or journaled: on a box armed for PROXY protocol, a |
| + // carlos.prev without ingress-proxy-v2 is refused with no journal |
| + // written and nothing drained or quiesced. rollback checked both slots' |
| + // digests before taking the lock, so the binary asked is the permit's. |
| + if err := a.requireFeatures(ctx, systemPrevPath(a.optDir)); err != nil { |
| + return err |
| + } |
| if err := a.groupTarget(systemPrevPath(a.optDir), true); err != nil { |
| return err |
| } |
diff --git a/internal/host/installchannel.go b/internal/host/installchannel.go| index f8a34d87f..1714d0d0f 100644 |
| --- a/internal/host/installchannel.go |
| +++ b/internal/host/installchannel.go |
| @@ -183,7 +183,7 @@ var errChannelIdentity = errors.New("the --identity file is not a release identi |
| func newChannelInstall(channel string, policy, identity []byte) channelInstall { |
| in := channelInstall{ |
| a: &systemApplier{ops: productionSysOps(), openStore: openSystemStore, channel: channel, optDir: release.OptDir(), |
| - dataDir: dataDir(), etcDir: "/etc", build: version.Build, platform: runtime.GOOS + "-" + runtime.GOARCH}, |
| + dataDir: dataDir(), etcDir: "/etc", build: version.Build, platform: runtime.GOOS + "-" + runtime.GOARCH, proxyEnv: os.Getenv}, |
| bucket: os.Getenv("CARLOS_DEPLOYMENT_BUCKET"), |
| fetchTo: func(ctx context.Context, s release.Store, key, dst, sha string) error { |
| return release.FetchToFile(ctx, s, key, dst, systemArtifactLimit, sha) |
diff --git a/internal/host/proxyfeature.go b/internal/host/proxyfeature.go| new file mode 100644 |
| index 000000000..4a95078fd |
| --- /dev/null |
| +++ b/internal/host/proxyfeature.go |
| @@ -0,0 +1,178 @@ |
| +package host |
| + |
| +import ( |
| + "bytes" |
| + "context" |
| + "encoding/json" |
| + "errors" |
| + "fmt" |
| + "io" |
| + "log" |
| + "os" |
| + "path/filepath" |
| + "slices" |
| + |
| + "github.com/carlosframework/platform/internal/version" |
| +) |
| + |
| +// The activation guard (edge PPv2 spec §7.3). A box whose host.env carries |
| +// CARLOS_INGRESS_PROXY_SOURCES has an edge that parses PROXY protocol from |
| +// its load balancer; once the load balancer sends the header, a build whose |
| +// edge cannot parse it answers every connection with a 400 or a TLS error |
| +// and fails its health checks. So such a box activates no binary that does |
| +// not report the ingress-proxy-v2 feature in `carlos version --json`, on |
| +// every activation path, before that path changes anything: apply and |
| +// install-channel (stageCandidate), the operator's rollback |
| +// (rollbackCompletedApply), apply's own rollback (rollback), boot and |
| +// failure recovery (recoverIfNeeded, and the recovery unit's |
| +// proxy-allows-prev gate), and the restore copy just before its rename |
| +// (restoreFiles). A box without the key never runs the check. |
| + |
| +// ingressProxyFeature is the feature the guard asks a binary for. |
| +const ingressProxyFeature = version.FeatureIngressProxyV2 |
| + |
| +// proxyHostEnvLimit bounds the host.env read, as the exec-sandbox reader's. |
| +const proxyHostEnvLimit = 1 << 20 |
| + |
| +// proxyFeatureRefusal is the guard's refusal of binary. |
| +type proxyFeatureRefusal struct{ binary string } |
| + |
| +func (e *proxyFeatureRefusal) Error() string { |
| + return "this box parses PROXY protocol from its load balancer (CARLOS_INGRESS_PROXY_SOURCES is set); " + e.binary + |
| + " does not, so it cannot run here. Roll forward, or to a build at or above the first one with ingress-proxy-v2." |
| +} |
| + |
| +// binaryHasFeature runs `<binary> version --json` and reports whether its |
| +// output is one JSON object whose features list names feature. A binary |
| +// older than the list prints its bare `carlos <build>` line for any flag |
| +// (versionCommand's DefaultOn), which is not JSON, so it has no feature; a |
| +// run that fails has none either. |
| +func binaryHasFeature(ctx context.Context, run func(ctx context.Context, binary string, args ...string) ([]byte, error), binary, feature string) bool { |
| + out, err := run(ctx, binary, "version", "--json") |
| + if err != nil { |
| + return false |
| + } |
| + var v struct { |
| + Features []string `json:"features"` |
| + } |
| + if err := json.Unmarshal(bytes.TrimSpace(out), &v); err != nil { |
| + return false |
| + } |
| + return slices.Contains(v.Features, feature) |
| +} |
| + |
| +// proxyGuardArmed is whether the guard applies: proxySourcesSet on the |
| +// process environment (the system units load host.env; group maintenance |
| +// and member boot pass its values in), or on host.env itself, read from |
| +// disk so that a run without the file in its environment (a recovery run |
| +// by hand) is guarded too. A host.env that exists but cannot be read |
| +// arms the guard: not knowing restricts activation (a binary with the |
| +// feature still passes); it does not lift the guard. No file is no key. |
| +func proxyGuardArmed(getenv func(string) string, readHostEnv func() (func(string) string, error)) bool { |
| + if getenv != nil && proxySourcesSet(getenv) { |
| + return true |
| + } |
| + if readHostEnv == nil { |
| + return false |
| + } |
| + fileEnv, err := readHostEnv() |
| + if err != nil { |
| + return true |
| + } |
| + return proxySourcesSet(fileEnv) |
| +} |
| + |
| +// readProxyHostEnv reads host.env at path into a getenv, with the |
| +// EnvironmentFile parser the exec-sandbox reader uses. A missing file is an |
| +// empty environment. |
| +func readProxyHostEnv(path string) (func(string) string, error) { |
| + f, err := os.Open(path) |
| + if errors.Is(err, os.ErrNotExist) { |
| + return func(string) string { return "" }, nil |
| + } |
| + if err != nil { |
| + return nil, err |
| + } |
| + defer f.Close() |
| + raw, err := io.ReadAll(io.LimitReader(f, proxyHostEnvLimit+1)) |
| + if err != nil { |
| + return nil, err |
| + } |
| + if len(raw) > proxyHostEnvLimit { |
| + return nil, fmt.Errorf("%s: larger than %d bytes", path, proxyHostEnvLimit) |
| + } |
| + return sandboxEnvironmentValues(raw), nil |
| +} |
| + |
| +// proxyArmedHere is proxyGuardArmed for this applier: its process |
| +// environment seam (os.Getenv in production, nil in tests) and the host.env |
| +// under its etcDir. |
| +func (a *systemApplier) proxyArmedHere() bool { |
| + var read func() (func(string) string, error) |
| + if a.etcDir != "" { |
| + read = func() (func(string) string, error) { |
| + return readProxyHostEnv(filepath.Join(a.etcDir, "carlos", "host.env")) |
| + } |
| + } |
| + return proxyGuardArmed(a.proxyEnv, read) |
| +} |
| + |
| +// requireFeatures is the activation guard for binary: nil on a box not |
| +// armed for PROXY protocol, without running anything; otherwise nil only |
| +// when binary reports ingress-proxy-v2, asked the way the box runs every |
| +// binary it activates (guardRun, bounded by systemVersionWait). The |
| +// exec-sandbox rule comes first, so a binary it refuses is never run. |
| +func (a *systemApplier) requireFeatures(ctx context.Context, binary string) error { |
| + if !a.proxyArmedHere() { |
| + return nil |
| + } |
| + if err := a.sandboxAllows(binary); err != nil { |
| + return err |
| + } |
| + run := func(ctx context.Context, name string, args ...string) ([]byte, error) { |
| + out, err := a.guardRun(ctx, systemVersionWait, name, args...) |
| + return []byte(out), err |
| + } |
| + if binaryHasFeature(ctx, run, binary, ingressProxyFeature) { |
| + return nil |
| + } |
| + return &proxyFeatureRefusal{binary: binary} |
| +} |
| + |
| +// RunSystemProxyAllowsPrev is `carlos system proxy-allows-prev |
| +// /opt/carlos/carlos.prev`: the recovery unit's gate on running |
| +// carlos.prev, the same shape as exec-sandbox-allows-prev. Exit 0 when the |
| +// box is not armed for PROXY protocol or carlos.prev reports |
| +// ingress-proxy-v2; 1 when it is armed and carlos.prev does not; 2 for |
| +// any other arguments. Any non-zero exit makes the unit run the current |
| +// binary's recovery, which refuses the same carlos.prev itself. |
| +func RunSystemProxyAllowsPrev(args []string) { |
| + run := func(ctx context.Context, name string, args ...string) ([]byte, error) { |
| + out, err := productionSysOps().run(ctx, systemVersionWait, name, args...) |
| + return []byte(out), err |
| + } |
| + armed := func() bool { |
| + return proxyGuardArmed(os.Getenv, func() (func(string) string, error) { |
| + return readProxyHostEnv("/etc/carlos/host.env") |
| + }) |
| + } |
| + os.Exit(proxyAllowsPrev(context.Background(), args, "/opt/carlos/carlos.prev", armed, run, log.Printf)) |
| +} |
| + |
| +// proxyAllowsPrev is the verb with its seams: the one path it accepts, |
| +// whether the box is armed, how a binary is run, and where a refusal is |
| +// logged. |
| +func proxyAllowsPrev(ctx context.Context, args []string, prev string, armed func() bool, run func(ctx context.Context, binary string, args ...string) ([]byte, error), logf func(string, ...any)) int { |
| + if len(args) != 1 || args[0] != prev { |
| + logf("usage: carlos system proxy-allows-prev %s", prev) |
| + return 2 |
| + } |
| + if !armed() { |
| + return 0 |
| + } |
| + if binaryHasFeature(ctx, run, prev, ingressProxyFeature) { |
| + return 0 |
| + } |
| + logf("%v", &proxyFeatureRefusal{binary: prev}) |
| + return 1 |
| +} |
diff --git a/internal/host/proxyfeature_linux_test.go b/internal/host/proxyfeature_linux_test.go| new file mode 100644 |
| index 000000000..6a7ea61e1 |
| --- /dev/null |
| +++ b/internal/host/proxyfeature_linux_test.go |
| @@ -0,0 +1,89 @@ |
| +//go:build linux |
| + |
| +package host |
| + |
| +import ( |
| + "context" |
| + "encoding/json" |
| + "errors" |
| + "os" |
| + "path/filepath" |
| + "testing" |
| +) |
| + |
| +// TestRollbackRefusedBeforeDisruption: the operator's rollback of a |
| +// completed apply, on a box armed for PROXY protocol, is refused when |
| +// carlos.prev lacks ingress-proxy-v2, before anything is staged, begun or |
| +// journaled: no journal, no ingress drain, no quiesce, the binary as it |
| +// was and the permit unconsumed, so the same rollback goes through once the |
| +// box is no longer armed. |
| +func TestRollbackRefusedBeforeDisruption(t *testing.T) { |
| + f, p, cmd := maintenancePrepareFixture(t) |
| + if _, err := runMaintenanceVerb(cmd, "prepare", nil); err != nil { |
| + t.Fatal(err) |
| + } |
| + b, _ := json.Marshal(p) |
| + if _, err := runMaintenanceVerb(cmd, "permit", b); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := f.a.Run(t.Context(), false); err != nil { |
| + t.Fatal(err) |
| + } |
| + if !groupArtifactHolds(systemBinaryPath(f.a.optDir), p.NewSHA256) { |
| + t.Fatal("apply did not install") |
| + } |
| + if _, err := runMaintenanceVerb(cmd, "revoke", nil); err != nil { |
| + t.Fatal(err) |
| + } |
| + p.Action = "rollback" |
| + b, _ = json.Marshal(p) |
| + if _, err := runMaintenanceVerb(cmd, "permit", b); err != nil { |
| + t.Fatal(err) |
| + } |
| + // Arm the box: the region's parameters now carry the key. |
| + hostEnv := filepath.Join(f.a.etcDir, "carlos", "host.env") |
| + original, err := os.ReadFile(hostEnv) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := os.WriteFile(hostEnv, append(append([]byte{}, original...), "CARLOS_INGRESS_PROXY_SOURCES=10.0.1.5\n"...), 0o600); err != nil { |
| + t.Fatal(err) |
| + } |
| + answerVersionJSON(f, noFeatures) |
| + drained := false |
| + f.a.askIngressDrain = func(context.Context) (drainCallResult, error) { |
| + drained = true |
| + return drainCallResult{}, nil |
| + } |
| + f.calls = nil |
| + _, err = runMaintenanceVerb(cmd, "rollback", nil) |
| + var refusal *proxyFeatureRefusal |
| + if !errors.As(err, &refusal) || refusal.binary != systemPrevPath(f.a.optDir) { |
| + t.Fatalf("rollback: %v", err) |
| + } |
| + if _, err := os.Lstat(filepath.Join(systemRootDir(f.a.optDir), "journal.json")); !os.IsNotExist(err) { |
| + t.Fatalf("a journal was written: %v", err) |
| + } |
| + if drained || f.called("systemctl") { |
| + t.Fatalf("the refusal drained (%v) or touched systemd: %v", drained, f.calls) |
| + } |
| + if !f.called("run carlos.prev version --json") { |
| + t.Fatalf("carlos.prev was not asked: %v", f.calls) |
| + } |
| + if !groupArtifactHolds(systemBinaryPath(f.a.optDir), p.NewSHA256) { |
| + t.Fatal("the binary changed") |
| + } |
| + if _, err := os.Lstat(filepath.Join(f.a.maintenance().dir, "used-"+p.Transaction+"-rollback")); !os.IsNotExist(err) { |
| + t.Fatalf("the refused rollback consumed its permit: %v", err) |
| + } |
| + // Unarmed, the same permit rolls back. |
| + if err := os.WriteFile(hostEnv, original, 0o600); err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, err := runMaintenanceVerb(cmd, "rollback", nil); err != nil { |
| + t.Fatal(err) |
| + } |
| + if !groupArtifactHolds(systemBinaryPath(f.a.optDir), p.OldSHA256) { |
| + t.Fatal("the rollback did not complete once unarmed") |
| + } |
| +} |
diff --git a/internal/host/proxyfeature_test.go b/internal/host/proxyfeature_test.go| new file mode 100644 |
| index 000000000..9fe4ac1ed |
| --- /dev/null |
| +++ b/internal/host/proxyfeature_test.go |
| @@ -0,0 +1,461 @@ |
| +package host |
| + |
| +import ( |
| + "context" |
| + "errors" |
| + "fmt" |
| + "os" |
| + "os/exec" |
| + "path/filepath" |
| + "strings" |
| + "testing" |
| + "time" |
| +) |
| + |
| +// proxyFeatureLine is what a build with the feature prints for |
| +// `version --json`. |
| +const proxyFeatureLine = `{"version":"v9","features":["ingress-proxy-v2"]}` + "\n" |
| + |
| +// armProxy writes a host.env under etcDir that arms the box for PROXY |
| +// protocol, as the region's parameters put it there. |
| +func armProxy(t *testing.T, etcDir string) { |
| + t.Helper() |
| + if err := os.MkdirAll(filepath.Join(etcDir, "carlos"), 0o755); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := os.WriteFile(filepath.Join(etcDir, "carlos", "host.env"), []byte("CARLOS_REGION=ie\nCARLOS_INGRESS_PROXY_SOURCES=10.0.1.5,10.0.2.6\n"), 0o600); err != nil { |
| + t.Fatal(err) |
| + } |
| +} |
| + |
| +// answerVersionJSON makes the fixture's fake binaries answer `version |
| +// --json`: with features(name)'s line when it gives one, otherwise as a |
| +// binary from before the features list does, with its bare `version` |
| +// line. Every such run is recorded as "run <base> version --json". |
| +func answerVersionJSON(f *applyFixture, features func(name string) (string, bool)) { |
| + run := f.a.ops.run |
| + f.a.ops.run = func(ctx context.Context, timeout time.Duration, name string, args ...string) (string, error) { |
| + if len(args) == 2 && args[0] == "version" && args[1] == "--json" { |
| + f.calls = append(f.calls, "run "+filepath.Base(name)+" version --json") |
| + if out, ok := features(name); ok { |
| + return out, nil |
| + } |
| + return run(ctx, timeout, name, "version") |
| + } |
| + return run(ctx, timeout, name, args...) |
| + } |
| +} |
| + |
| +// noFeatures: every binary is from before the features list. |
| +func noFeatures(string) (string, bool) { return "", false } |
| + |
| +func TestBinaryHasFeature(t *testing.T) { |
| + for _, tc := range []struct { |
| + name string |
| + out string |
| + err error |
| + want bool |
| + }{ |
| + {"json with the feature", proxyFeatureLine, nil, true}, |
| + {"json with the feature among others", `{"version":"v9","features":["x","ingress-proxy-v2","y"]}`, nil, true}, |
| + {"json without the feature", `{"version":"v9","features":["x"]}` + "\n", nil, false}, |
| + {"json with no features", `{"version":"v9"}` + "\n", nil, false}, |
| + {"json null", "null\n", nil, false}, |
| + {"an old binary's bare line", "carlos v0.34.49\n", nil, false}, |
| + {"json then more", proxyFeatureLine + "carlos v9\n", nil, false}, |
| + {"a feature only by prefix", `{"features":["ingress-proxy-v2x"]}`, nil, false}, |
| + {"run error", proxyFeatureLine, errors.New("exit status 1"), false}, |
| + } { |
| + t.Run(tc.name, func(t *testing.T) { |
| + var asked []string |
| + run := func(_ context.Context, binary string, args ...string) ([]byte, error) { |
| + asked = append([]string{binary}, args...) |
| + return []byte(tc.out), tc.err |
| + } |
| + if got := binaryHasFeature(context.Background(), run, "/opt/carlos/carlos.prev", "ingress-proxy-v2"); got != tc.want { |
| + t.Fatalf("binaryHasFeature = %v, want %v", got, tc.want) |
| + } |
| + if strings.Join(asked, " ") != "/opt/carlos/carlos.prev version --json" { |
| + t.Fatalf("ran %q", asked) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +func TestProxyGuardArmed(t *testing.T) { |
| + env := func(v string) func(string) string { |
| + return func(k string) string { |
| + if k == "CARLOS_INGRESS_PROXY_SOURCES" { |
| + return v |
| + } |
| + return "" |
| + } |
| + } |
| + file := func(v string, err error) func() (func(string) string, error) { |
| + return func() (func(string) string, error) { return env(v), err } |
| + } |
| + for _, tc := range []struct { |
| + name string |
| + getenv func(string) string |
| + read func() (func(string) string, error) |
| + want bool |
| + }{ |
| + {"nothing", nil, nil, false}, |
| + {"neither sets the key", env(""), file("", nil), false}, |
| + {"process environment", env("10.0.1.5"), file("", nil), true}, |
| + {"host.env on disk", env(""), file("10.0.1.5", nil), true}, |
| + {"host.env unreadable", env(""), file("", errors.New("permission denied")), true}, |
| + {"a value the edge refuses", env("8.8.8.8"), file("", nil), false}, |
| + } { |
| + t.Run(tc.name, func(t *testing.T) { |
| + if got := proxyGuardArmed(tc.getenv, tc.read); got != tc.want { |
| + t.Fatalf("armed = %v, want %v", got, tc.want) |
| + } |
| + }) |
| + } |
| + dir := t.TempDir() |
| + if getenv, err := readProxyHostEnv(filepath.Join(dir, "absent")); err != nil || getenv("CARLOS_INGRESS_PROXY_SOURCES") != "" { |
| + t.Fatalf("a missing host.env: %v", err) |
| + } |
| + armProxy(t, dir) |
| + getenv, err := readProxyHostEnv(filepath.Join(dir, "carlos", "host.env")) |
| + if err != nil || getenv("CARLOS_INGRESS_PROXY_SOURCES") != "10.0.1.5,10.0.2.6" { |
| + t.Fatalf("host.env read: %v", err) |
| + } |
| + a := &systemApplier{etcDir: dir} |
| + if !a.proxyArmedHere() { |
| + t.Fatal("an applier over an armed host.env is not armed") |
| + } |
| + if (&systemApplier{etcDir: t.TempDir()}).proxyArmedHere() { |
| + t.Fatal("an applier over no host.env is armed") |
| + } |
| +} |
| + |
| +// TestStageRefusesBinaryWithoutFeature: on an armed box, apply refuses a |
| +// candidate that does not report ingress-proxy-v2 once it is staged, and |
| +// the box is as it was. |
| +func TestStageRefusesBinaryWithoutFeature(t *testing.T) { |
| + f, req := applyHappy(t) |
| + armProxy(t, f.a.etcDir) |
| + answerVersionJSON(f, noFeatures) |
| + before, err := os.ReadFile(systemBinaryPath(f.a.optDir)) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := f.a.Run(context.Background(), false); err != nil { |
| + t.Fatal(err) |
| + } |
| + staged := filepath.Join(f.a.stagingDir(), "carlos") |
| + want := (&proxyFeatureRefusal{binary: staged}).Error() |
| + r := f.result() |
| + if r == nil || r.Outcome != systemOutcomeRefused || !r.matches("stable", "v2", req.PromotedAt) || !strings.Contains(r.Reason, want) { |
| + t.Fatalf("result = %+v, want refused with %q", r, want) |
| + } |
| + if !strings.HasPrefix(want, "this box parses PROXY protocol from its load balancer (CARLOS_INGRESS_PROXY_SOURCES is set); "+staged+" does not, so it cannot run here. Roll forward, or to a build at or above the first one with ingress-proxy-v2.") { |
| + t.Fatalf("message %q", want) |
| + } |
| + after, _ := os.ReadFile(systemBinaryPath(f.a.optDir)) |
| + if string(after) != string(before) { |
| + t.Fatal("the running binary changed") |
| + } |
| + if _, err := os.Stat(systemPrevPath(f.a.optDir)); !os.IsNotExist(err) { |
| + t.Fatalf("carlos.prev written: %v", err) |
| + } |
| + if j, _ := readSystemJournal(f.a.optDir); j != nil { |
| + t.Fatalf("journal written: %+v", j) |
| + } |
| + if !f.called("run carlos version --json") { |
| + t.Fatalf("the candidate was not asked: %v", f.calls) |
| + } |
| + if f.called("systemctl") { |
| + t.Fatalf("the refusal touched systemd: %v", f.calls) |
| + } |
| +} |
| + |
| +// TestStageAllowsWithoutKey: the same candidate on a box without the key |
| +// installs as it always has, and nothing is asked for --json. |
| +func TestStageAllowsWithoutKey(t *testing.T) { |
| + f, req := applyHappy(t) |
| + answerVersionJSON(f, noFeatures) |
| + if err := f.a.Run(context.Background(), false); err != nil { |
| + t.Fatal(err) |
| + } |
| + if r := f.result(); r == nil || r.Outcome != systemOutcomeApplied || !r.matches("stable", "v2", req.PromotedAt) { |
| + t.Fatalf("result = %+v", r) |
| + } |
| + if strings.Contains(strings.Join(f.calls, "\n"), "--json") { |
| + t.Fatalf("a box without the key asked for features: %v", f.calls) |
| + } |
| +} |
| + |
| +// TestStageAllowsBinaryWithFeature: on an armed box a candidate that |
| +// reports the feature installs. |
| +func TestStageAllowsBinaryWithFeature(t *testing.T) { |
| + f, req := applyHappy(t) |
| + armProxy(t, f.a.etcDir) |
| + staged := filepath.Join(f.a.stagingDir(), "carlos") |
| + answerVersionJSON(f, func(name string) (string, bool) { return proxyFeatureLine, name == staged }) |
| + if err := f.a.Run(context.Background(), false); err != nil { |
| + t.Fatal(err) |
| + } |
| + if r := f.result(); r == nil || r.Outcome != systemOutcomeApplied || !r.matches("stable", "v2", req.PromotedAt) { |
| + t.Fatalf("result = %+v", r) |
| + } |
| +} |
| + |
| +// TestInstallChannelRefusesBinaryWithoutFeature: install-channel (member |
| +// boot's install) stages through the same guard: nothing reaches either |
| +// slot. |
| +func TestInstallChannelRefusesBinaryWithoutFeature(t *testing.T) { |
| + f := newChannelFixture(t, "v1.2.0") |
| + armProxy(t, f.a.etcDir) |
| + answerVersionJSON(f.applyFixture, noFeatures) |
| + _, err := f.in.run(context.Background()) |
| + var refusal *proxyFeatureRefusal |
| + if !errors.As(err, &refusal) { |
| + t.Fatalf("install result: %v", err) |
| + } |
| + current, prev := f.slots(t) |
| + if len(current) != 0 || len(prev) != 0 { |
| + t.Fatal("install-channel populated executable slots") |
| + } |
| + if applied, _ := readSystemApplied(f.a.optDir); applied != nil { |
| + t.Fatalf("applied.json written: %+v", applied) |
| + } |
| +} |
| + |
| +// TestApplyRollbackRefusedBeforeDisruption: apply's own rollback, after a |
| +// candidate with the feature fails its gate, is refused at its start when |
| +// carlos.prev lacks the feature: no second drain, quiesce, copy or |
| +// restart; the candidate stays, the journal stays open, and the result |
| +// says why. |
| +func TestApplyRollbackRefusedBeforeDisruption(t *testing.T) { |
| + f, req := applyHappy(t) |
| + armProxy(t, f.a.etcDir) |
| + staged := filepath.Join(f.a.stagingDir(), "carlos") |
| + answerVersionJSON(f, func(name string) (string, bool) { return proxyFeatureLine, name == staged }) |
| + drains := 0 |
| + f.a.askIngressDrain = func(context.Context) (drainCallResult, error) { |
| + drains++ |
| + return drainCallResult{}, nil |
| + } |
| + f.edgeUp = false |
| + if err := f.a.Run(context.Background(), false); err == nil { |
| + t.Fatal("a refused rollback must exit non-zero") |
| + } |
| + want := (&proxyFeatureRefusal{binary: systemPrevPath(f.a.optDir)}).Error() |
| + r := f.result() |
| + if r == nil || r.Outcome != systemOutcomeRollbackFailed || !r.matches("stable", "v2", req.PromotedAt) || !strings.Contains(r.Reason, want) { |
| + t.Fatalf("result = %+v, want rollback-failed with %q", r, want) |
| + } |
| + bin, _ := os.ReadFile(systemBinaryPath(f.a.optDir)) |
| + if !strings.Contains(string(bin), "carlos v2") { |
| + t.Fatal("the candidate was replaced") |
| + } |
| + if j, _ := readSystemJournal(f.a.optDir); j == nil { |
| + t.Fatal("the journal was closed") |
| + } |
| + if _, err := os.Stat(systemBinaryPath(f.a.optDir) + ".restore"); !os.IsNotExist(err) { |
| + t.Fatalf("a restore copy was made: %v", err) |
| + } |
| + joined := strings.Join(f.calls, "\n") |
| + if drains != 1 || strings.Count(joined, "systemctl stop carlos-adopt.timer") != 1 || strings.Count(joined, "systemctl restart carlos-edge") != 1 { |
| + t.Fatalf("the rollback disrupted the box (drains %d):\n%s", drains, joined) |
| + } |
| +} |
| + |
| +// recoveryOnArmedBox is a box rebooted with an apply of v2 interrupted |
| +// after the install: v2 on disk, carlos.prev v1, the journal open, and |
| +// host.env armed for PROXY protocol. |
| +func recoveryOnArmedBox(t *testing.T) *applyFixture { |
| + t.Helper() |
| + f, _ := applyHappy(t) |
| + os.WriteFile(systemPrevPath(f.a.optDir), []byte("#!/bin/sh\necho carlos v1\n"), 0o755) |
| + os.WriteFile(systemBinaryPath(f.a.optDir), []byte("#!/bin/sh\necho carlos v2\n"), 0o755) |
| + writeJSONDurable(filepath.Join(systemRootDir(f.a.optDir), "journal.json"), |
| + systemJournal{Phase: systemPhaseInstalled, Target: "v2", PrevBuild: "v1", StartedAt: f.now}, 0o600) |
| + f.edgeStartedThisBoot = false |
| + armProxy(t, f.a.etcDir) |
| + return f |
| +} |
| + |
| +// TestRecoveryRefusesPrevWithoutFeature: `apply --recover` by the current |
| +// binary (the unit's gate refused carlos.prev) refuses to restore a |
| +// carlos.prev without the feature, exits non-zero, and leaves the current |
| +// binary and the journal. |
| +func TestRecoveryRefusesPrevWithoutFeature(t *testing.T) { |
| + f := recoveryOnArmedBox(t) |
| + answerVersionJSON(f, noFeatures) |
| + journal, _ := os.ReadFile(filepath.Join(systemRootDir(f.a.optDir), "journal.json")) |
| + err := f.a.Run(context.Background(), true) |
| + var refusal *proxyFeatureRefusal |
| + if !errors.As(err, &refusal) || refusal.binary != systemPrevPath(f.a.optDir) { |
| + t.Fatalf("recovery: %v", err) |
| + } |
| + bin, _ := os.ReadFile(systemBinaryPath(f.a.optDir)) |
| + if !strings.Contains(string(bin), "carlos v2") { |
| + t.Fatal("the current binary was replaced") |
| + } |
| + if after, _ := os.ReadFile(filepath.Join(systemRootDir(f.a.optDir), "journal.json")); string(after) != string(journal) { |
| + t.Fatal("the journal changed") |
| + } |
| + if f.called("systemctl") { |
| + t.Fatalf("the refusal touched systemd: %v", f.calls) |
| + } |
| + if r := f.result(); r != nil { |
| + t.Fatalf("a result was written: %+v", r) |
| + } |
| +} |
| + |
| +// TestRecoveryRestoresPrevWithFeature: on the same armed box, a |
| +// carlos.prev with the feature is restored as before. |
| +func TestRecoveryRestoresPrevWithFeature(t *testing.T) { |
| + f := recoveryOnArmedBox(t) |
| + answerVersionJSON(f, func(string) (string, bool) { return proxyFeatureLine, true }) |
| + if err := f.a.Run(context.Background(), true); err != nil { |
| + t.Fatal(err) |
| + } |
| + bin, _ := os.ReadFile(systemBinaryPath(f.a.optDir)) |
| + if !strings.Contains(string(bin), "carlos v1") { |
| + t.Fatal("carlos.prev not restored") |
| + } |
| + for _, want := range []string{"run carlos.prev version --json", "run carlos.restore version --json"} { |
| + if !f.called(want) { |
| + t.Fatalf("%q not asked: %v", want, f.calls) |
| + } |
| + } |
| +} |
| + |
| +// TestRestoreRefusesACopyWithoutFeature: the restore copy is asked again |
| +// under the activation guard, just before its rename; a copy that does |
| +// not report the feature is not renamed in, is removed, and the journal |
| +// stays. |
| +func TestRestoreRefusesACopyWithoutFeature(t *testing.T) { |
| + f := recoveryOnArmedBox(t) |
| + answerVersionJSON(f, func(name string) (string, bool) { |
| + return proxyFeatureLine, filepath.Base(name) == "carlos.prev" |
| + }) |
| + err := f.a.Run(context.Background(), true) |
| + var refusal *proxyFeatureRefusal |
| + if !errors.As(err, &refusal) || refusal.binary != systemBinaryPath(f.a.optDir)+".restore" { |
| + t.Fatalf("recovery: %v", err) |
| + } |
| + bin, _ := os.ReadFile(systemBinaryPath(f.a.optDir)) |
| + if !strings.Contains(string(bin), "carlos v2") { |
| + t.Fatal("the copy was renamed in") |
| + } |
| + if _, err := os.Stat(systemBinaryPath(f.a.optDir) + ".restore"); !os.IsNotExist(err) { |
| + t.Fatalf("the restore copy was left behind: %v", err) |
| + } |
| + if j, _ := readSystemJournal(f.a.optDir); j == nil { |
| + t.Fatal("the journal was closed") |
| + } |
| +} |
| + |
| +func TestProxyAllowsPrevVerb(t *testing.T) { |
| + prev := "/opt/carlos/carlos.prev" |
| + for _, tc := range []struct { |
| + name string |
| + args []string |
| + armed bool |
| + out string |
| + err error |
| + want int |
| + ran bool |
| + }{ |
| + {"not armed", []string{prev}, false, "carlos v0.34.49\n", nil, 0, false}, |
| + {"armed, feature", []string{prev}, true, proxyFeatureLine, nil, 0, true}, |
| + {"armed, no feature", []string{prev}, true, "carlos v0.34.49\n", nil, 1, true}, |
| + {"armed, run fails", []string{prev}, true, "", errors.New("exit status 2"), 1, true}, |
| + {"no path", nil, true, proxyFeatureLine, nil, 2, false}, |
| + {"another path", []string{"/tmp/carlos"}, false, proxyFeatureLine, nil, 2, false}, |
| + {"two paths", []string{prev, prev}, false, proxyFeatureLine, nil, 2, false}, |
| + } { |
| + t.Run(tc.name, func(t *testing.T) { |
| + ran := false |
| + run := func(_ context.Context, binary string, args ...string) ([]byte, error) { |
| + ran = true |
| + if binary != prev || strings.Join(args, " ") != "version --json" { |
| + t.Fatalf("ran %s %v", binary, args) |
| + } |
| + return []byte(tc.out), tc.err |
| + } |
| + var logged []string |
| + logf := func(format string, args ...any) { logged = append(logged, fmt.Sprintf(format, args...)) } |
| + if got := proxyAllowsPrev(context.Background(), tc.args, prev, func() bool { return tc.armed }, run, logf); got != tc.want { |
| + t.Fatalf("exit %d, want %d", got, tc.want) |
| + } |
| + if ran != tc.ran { |
| + t.Fatalf("ran %v, want %v", ran, tc.ran) |
| + } |
| + if tc.want == 1 && (len(logged) != 1 || logged[0] != (&proxyFeatureRefusal{binary: prev}).Error()) { |
| + t.Fatalf("logged %q", logged) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +// recoverUnitCommand is the recovery unit's ExecStart shell body. |
| +func recoverUnitCommand(t *testing.T) string { |
| + t.Helper() |
| + raw, err := unitsFS.ReadFile("units/" + systemRecoverUnit) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + var command string |
| + for _, line := range strings.Split(string(raw), "\n") { |
| + if strings.HasPrefix(line, "ExecStart=") { |
| + command = strings.TrimSuffix(strings.TrimPrefix(line, "ExecStart=/bin/sh -c '"), "'") |
| + } |
| + } |
| + return command |
| +} |
| + |
| +// proxyRecoveryGate is the recovery unit's PROXY protocol gate. |
| +const proxyRecoveryGate = " && /opt/carlos/carlos system proxy-allows-prev /opt/carlos/carlos.prev" |
| + |
| +// TestRecoverUnitGatesPrev: the recovery unit runs carlos.prev only when |
| +// the current binary's proxy-allows-prev passes it, inside the .prev |
| +// condition chain, and runs the current binary's recovery when it fails. |
| +func TestRecoverUnitGatesPrev(t *testing.T) { |
| + command := recoverUnitCommand(t) |
| + chain := strings.Index(command, "if [ -f /opt/carlos/system/router/journal.json ] && [ -x /opt/carlos/carlos.prev ]") |
| + gate := strings.Index(command, proxyRecoveryGate) |
| + then := strings.Index(command, "; then exec /opt/carlos/carlos.prev system apply --recover; fi;") |
| + if strings.Count(command, proxyRecoveryGate) != 1 || chain < 0 || !(chain < gate && gate < then) || strings.ContainsAny(command, "%$") { |
| + t.Fatalf("the recovery unit does not gate carlos.prev on proxy-allows-prev: %s", command) |
| + } |
| + for _, tc := range []struct { |
| + gate string // the stub's answer to proxy-allows-prev |
| + want string |
| + }{ |
| + {"exit 0", "prev"}, |
| + {"exit 1", "current"}, |
| + {"exit 2", "current"}, |
| + } { |
| + t.Run(tc.gate, func(t *testing.T) { |
| + root := t.TempDir() |
| + current, prev := filepath.Join(root, "current"), filepath.Join(root, "prev") |
| + receipt := filepath.Join(root, "receipt") |
| + // The current stub passes every other gate and answers the |
| + // proxy gate as told; asked to recover, it records itself. |
| + body := "#!/bin/sh\ncase \"$1 $2\" in\n'system proxy-allows-prev') " + tc.gate + ";;\n'system apply') echo current > '" + receipt + "';;\n*) exit 0;;\nesac\n" |
| + os.WriteFile(current, []byte(body), 0o755) |
| + os.WriteFile(prev, []byte("#!/bin/sh\ncase \"$1 $2\" in\n'system apply') echo prev > '"+receipt+"';;\n*) exit 0;;\nesac\n"), 0o755) |
| + cmd := strings.ReplaceAll(command, "/opt/carlos/carlos.prev", prev) |
| + cmd = strings.ReplaceAll(cmd, "/opt/carlos/carlos", current) |
| + for _, p := range []string{"/opt/carlos/system/guard/carlos", "/var/lib/carlos-claims/authority/exec/census.json", "/opt/carlos/system/guard/moves", "/data/.moves/floor.min-release", "/data/.moves/seeds-floor.min-release"} { |
| + cmd = strings.ReplaceAll(cmd, p, filepath.Join(root, "absent", filepath.Base(p))) |
| + } |
| + journal := filepath.Join(root, "journal") |
| + os.WriteFile(journal, nil, 0o600) |
| + cmd = strings.ReplaceAll(cmd, "/opt/carlos/system/router/journal.json", journal) |
| + if out, err := exec.Command("/bin/sh", "-c", cmd).CombinedOutput(); err != nil { |
| + t.Fatalf("recovery: %v %s", err, out) |
| + } |
| + if b, _ := os.ReadFile(receipt); string(b) != tc.want+"\n" { |
| + t.Fatalf("recovery ran %q, want %s", b, tc.want) |
| + } |
| + }) |
| + } |
| +} |
diff --git a/internal/host/systemapply.go b/internal/host/systemapply.go| index a3db9bb0e..987b10301 100644 |
| --- a/internal/host/systemapply.go |
| +++ b/internal/host/systemapply.go |
| @@ -147,6 +147,7 @@ func productionSystemApplier(channel string) *systemApplier { |
| handRun: systemApplyHandRun(os.Getenv), |
| askIngressDrain: execIngressDrain, |
| ingressArmed: func() bool { return ingressDrainConfigured(os.Getenv) }, |
| + proxyEnv: os.Getenv, |
| } |
| a.readEnvironment(os.Getenv) |
| a.floorHook = installFloorHook // decided under the apply lock, in Run |
| @@ -304,6 +305,10 @@ type systemApplier struct { |
| // dry-check the guard before its ask (refusalsBeforeDrain). Nil is a |
| // box with no drain, whose refusals stay where they were. |
| ingressArmed func() bool |
| + // proxyEnv is the process environment the activation guard reads |
| + // CARLOS_INGRESS_PROXY_SOURCES from, besides host.env under etcDir |
| + // (proxyArmedHere): os.Getenv in production. Nil reads host.env only. |
| + proxyEnv func(string) string |
| } |
| // ingressDrainConfigured is host.env's half of the drain's arming (spec |
| @@ -2048,6 +2053,13 @@ func (a *systemApplier) rollback(ctx context.Context, req systemRequest, reason |
| _ = a.writeResult(req, systemOutcomeRollbackFailed, reason+"; "+what+": "+err.Error()) |
| return fmt.Errorf("system apply: rollback of %s failed: %s: %v", j.Target, what, err) |
| } |
| + // The activation guard (edge PPv2 spec §7.3) before the restore's |
| + // drain, quiesce or copy: on a box armed for PROXY protocol, a |
| + // carlos.prev without ingress-proxy-v2 is not rolled back to. The |
| + // journal stays, as for any refused restore. |
| + if err := a.requireFeatures(ctx, systemPrevPath(a.optDir)); err != nil { |
| + return failed("restore", err) |
| + } |
| // The rollback restarts the edge, so it asks for the ingress drain, |
| // after the restore's refusals and before its quiesce (W6 spec §5.3). |
| plan, err := a.restoreFiles(ctx, j, true) |
| @@ -2185,6 +2197,12 @@ func (a *systemApplier) restoreFiles(ctx context.Context, j *systemJournal, drai |
| if err := a.rootProtocolAllowsBinary(restore); err != nil { |
| return err |
| } |
| + // The activation guard once more, on the copy that is renamed in |
| + // (edge PPv2 spec §7.3): rollback and recovery checked carlos.prev |
| + // before anything moved; this is the bytes about to run. |
| + if err := a.requireFeatures(ctx, restore); err != nil { |
| + return err |
| + } |
| renamed = true |
| if err := os.Rename(restore, systemBinaryPath(a.optDir)); err != nil { |
| return err |
| @@ -2365,6 +2383,14 @@ func (a *systemApplier) recoverIfNeeded(ctx context.Context) (bool, error) { |
| a.ops.logf("system apply: recovery: %s passed its gate but %v; rolling back instead", j.Target, err) |
| } |
| } |
| + // The activation guard (edge PPv2 spec §7.3) before the restore |
| + // touches anything: on a box armed for PROXY protocol, a carlos.prev |
| + // without ingress-proxy-v2 is not restored. The current binary and the |
| + // journal stay, and the run fails with the reason (the recovery unit's |
| + // own gate, proxy-allows-prev, sent it here rather than to carlos.prev). |
| + if err := a.requireFeatures(ctx, systemPrevPath(a.optDir)); err != nil { |
| + return false, fmt.Errorf("system apply: recovery: %w", err) // journal kept |
| + } |
| plan, err := a.restoreFiles(ctx, j, false) |
| if err != nil { |
| return false, fmt.Errorf("system apply: recovery: %w", err) // journal kept: the next run recovers again |
| @@ -2581,6 +2607,12 @@ func (a *systemApplier) stageCandidate(ctx context.Context, p *release.SystemPoi |
| if carlosVersionOf(out) != p.Current.Version { |
| return "", fmt.Errorf("candidate reports %q, not %s", strings.TrimSpace(out), p.Current.Version) |
| } |
| + // The activation guard (edge PPv2 spec §7.3), for apply, system-update |
| + // adoption and install-channel alike: on a box armed for PROXY |
| + // protocol, a candidate without ingress-proxy-v2 goes no further. |
| + if err := a.requireFeatures(ctx, staged); err != nil { |
| + return "", err |
| + } |
| return staged, nil |
| } |
diff --git a/internal/host/units/carlos-system-recover.service b/internal/host/units/carlos-system-recover.service| index 3c26307ef..927a775c2 100644 |
| --- a/internal/host/units/carlos-system-recover.service |
| +++ b/internal/host/units/carlos-system-recover.service |
| @@ -29,6 +29,13 @@ |
| # own files: once /data/.moves/seeds-floor.min-release is there and not |
| # empty, carlos.prev runs only when /opt/carlos/carlos.prev.seeds-allowed |
| # names that same floor, byte for byte. |
| +# |
| +# The PROXY protocol gate (edge PPv2 spec §7.3) comes last: on a box whose |
| +# host.env sets CARLOS_INGRESS_PROXY_SOURCES, carlos.prev runs only when |
| +# the current binary's carlos system proxy-allows-prev finds that it |
| +# reports the ingress-proxy-v2 feature. Otherwise the current binary runs, |
| +# and its own recovery refuses to restore that carlos.prev: the journal |
| +# and the current binary stay, and the unit fails with the reason. |
| [Unit] |
| Description=carlos platform self-update recovery |
| Before=carlos-edge.service |
| @@ -41,7 +48,7 @@ Type=oneshot |
| # runs first. |
| TimeoutStartSec=13min |
| EnvironmentFile=-/etc/carlos/host.env |
| -ExecStart=/bin/sh -c 'if [ -x /opt/carlos/system/guard/carlos ] && { [ -e /var/lib/carlos-claims/authority/exec/census.json ] || [ -L /var/lib/carlos-claims/authority/exec/census.json ] || [ -e /opt/carlos/system/guard/moves ] || [ -L /opt/carlos/system/guard/moves ]; }; then exec /opt/carlos/system/guard/carlos system guard-exec recover; fi; if [ -f /opt/carlos/system/router/journal.json ] && [ -x /opt/carlos/carlos.prev ] && [ ! -L /data/.moves/floor.min-release ] && { [ ! -e /data/.moves/floor.min-release ] || [ -f /data/.moves/floor.min-release ]; } && { ! [ -s /data/.moves/floor.min-release ] || /opt/carlos/carlos.prev system floor-allows-prev /data/.moves/floor.min-release /opt/carlos/carlos.prev.allowed; } && [ ! -L /data/.moves/seeds-floor.min-release ] && { [ ! -e /data/.moves/seeds-floor.min-release ] || [ -f /data/.moves/seeds-floor.min-release ]; } && { ! [ -s /data/.moves/seeds-floor.min-release ] || /opt/carlos/carlos.prev system floor-allows-prev /data/.moves/seeds-floor.min-release /opt/carlos/carlos.prev.seeds-allowed; } && /opt/carlos/carlos system exec-sandbox-allows-prev /opt/carlos/carlos.prev; then exec /opt/carlos/carlos.prev system apply --recover; fi; exec /opt/carlos/carlos system apply --recover' |
| +ExecStart=/bin/sh -c 'if [ -x /opt/carlos/system/guard/carlos ] && { [ -e /var/lib/carlos-claims/authority/exec/census.json ] || [ -L /var/lib/carlos-claims/authority/exec/census.json ] || [ -e /opt/carlos/system/guard/moves ] || [ -L /opt/carlos/system/guard/moves ]; }; then exec /opt/carlos/system/guard/carlos system guard-exec recover; fi; if [ -f /opt/carlos/system/router/journal.json ] && [ -x /opt/carlos/carlos.prev ] && [ ! -L /data/.moves/floor.min-release ] && { [ ! -e /data/.moves/floor.min-release ] || [ -f /data/.moves/floor.min-release ]; } && { ! [ -s /data/.moves/floor.min-release ] || /opt/carlos/carlos.prev system floor-allows-prev /data/.moves/floor.min-release /opt/carlos/carlos.prev.allowed; } && [ ! -L /data/.moves/seeds-floor.min-release ] && { [ ! -e /data/.moves/seeds-floor.min-release ] || [ -f /data/.moves/seeds-floor.min-release ]; } && { ! [ -s /data/.moves/seeds-floor.min-release ] || /opt/carlos/carlos.prev system floor-allows-prev /data/.moves/seeds-floor.min-release /opt/carlos/carlos.prev.seeds-allowed; } && /opt/carlos/carlos system exec-sandbox-allows-prev /opt/carlos/carlos.prev && /opt/carlos/carlos system proxy-allows-prev /opt/carlos/carlos.prev; then exec /opt/carlos/carlos.prev system apply --recover; fi; exec /opt/carlos/carlos system apply --recover' |
| ProtectHome=yes |
| PrivateTmp=yes |
diff --git a/internal/version/features.go b/internal/version/features.go| new file mode 100644 |
| index 000000000..52c8ac559 |
| --- /dev/null |
| +++ b/internal/version/features.go |
| @@ -0,0 +1,11 @@ |
| +package version |
| + |
| +// FeatureIngressProxyV2 is the feature a build reports once its edge parses |
| +// PROXY protocol v2 from a load balancer (edge PPv2 spec §7.3). A box armed |
| +// for PROXY protocol refuses to activate a build that does not report it. |
| +const FeatureIngressProxyV2 = "ingress-proxy-v2" |
| + |
| +// Features is what `carlos version --json` reports this build can do, for a |
| +// box deciding whether it may activate the build. A feature, once listed, |
| +// stays listed in every later build. |
| +var Features = []string{FeatureIngressProxyV2} |
diff --git a/system.go b/system.go| index 432372106..3dc87b9c9 100644 |
| --- a/system.go |
| +++ b/system.go |
| @@ -59,6 +59,9 @@ func systemCommand() *clireg.Node { |
| {Name: systemComponentRouter, Transparent: true}, |
| raw("runsc-ensure", box, host.RunSystemRunscEnsure), |
| raw("exec-sandbox-allows-prev", box, host.RunSystemExecSandboxAllowsPrev), |
| + // The recovery unit's PROXY protocol gate on carlos.prev (edge |
| + // PPv2 spec §7.3); root's, not for operators. |
| + raw("proxy-allows-prev", box, host.RunSystemProxyAllowsPrev), |
| raw("group-maintenance", box, func(args []string) { |
| os.Exit(host.RunGroupMaintenance(args, os.Stdin, os.Stdout, os.Stderr)) |
| }), |
diff --git a/testdata/clireg-golden.jsonl b/testdata/clireg-golden.jsonl| index 5d0a369d7..346039349 100644 |
| --- a/testdata/clireg-golden.jsonl |
| +++ b/testdata/clireg-golden.jsonl |
| @@ -950,6 +950,8 @@ |
| {"case":"system pdf | bare","argv":["system","pdf"],"exit":2,"stdout":"","stderr":"usage: carlos system <verb> [flags]\n carlos system router <verb> [flags]\n carlos system demos <status|serving on|serving off|takedown|takedown-status>\n carlos system managed-fleets <show|set --file f.json>\n carlos system antivirus <status|enable|disable|rotate-webhook-key> [flags]\n carlos system pdf status\n carlos system geoip <publish|status|off> [flags]\n carlos system seeds-floor publish --min-release <release>\n carlos system legacy-routes assign --name <name> --to <account>/<app>\n carlos system lifetimes cutover [--no-wait]\n carlos system hosts-used status\n carlos system named-units install <file>\n carlos system box role <box> <default|legacy|platform>\n carlos system box publish-record\n carlos system group role <region> <default|legacy>\n carlos system host-env <write|seed> --deployment <name> --region <code> [flags]\n\nThe platform's own binary (ops account owners and CARLOS_SYSTEM_OPERATORS):\n\n update promote a platform release to a channel; every box on it rolls itself\n status every box: platform, channel, running build, channel target, last apply outcome\n rollback point a channel back at the release before this one\n cancel-activation\n release a channel's activation reservation that was never\n published, so promote and rollback work again\n apply (root oneshot behind carlos-system-update.service; not for operators)\n layout migrate|revert|status: move every instance into its own directory\n and namespace, or back; see carlos system layout help\n seeds-floor publish --min-release <release>\n the first release whose boxes can place a seed, such as v0.27.0\n legacy-routes assign --name <name> --to <account>/<app>\n say which account and app the routes an operator filed by hand belong to\n lifetimes cutover [--no-wait]\n switch a console without host claims onto instance lifetimes,\n once, after the old console has stopped. Waits until they are on\n hosts-used status\n the hostname history: its mode, how many hostnames it has\n recorded, its closed fleets and its floor\n box role <box> <default|legacy|platform>\n whether new instances may be placed on a box. A legacy or\n platform box keeps the instances it has and takes no new ones\n group role <region> <default|legacy>\n the same for every box a region's group has enrolled, and for\n every box it enrolls later\n box publish-record\n run on a box as the agent user, with systemd-run -p User=carlos:\n publish its AWS-signed identity record to the deployment\n bucket, once. It never replaces or deletes a record\n\nA box a region's group launches (region HA):\n\n host-env write build host.env from the deployment's parameters (root)\n host-env seed copy a box's host.env into the deployment's parameters\n install-channel install the release this box's channel names (root)\n\nDeployment-wide settings (CARLOS_STORE_OPERATORS):\n\n pdf status\n\n antivirus status is object scanning wired, switched on, and answering?\n Reports wiring and policy separately, because they fail\n separately.\n antivirus enable turn object scanning on for this deployment. Refused if\n no engine is wired: a record claiming enabled with\n nothing behind it would report health where no scan can\n run.\n antivirus disable turn it off. Takes effect on the next tick — no restart,\n which is the point of the switch living in a record\n rather than in the unit file.\n antivirus rotate-webhook-key\n deliver the current master-derived callback secret to\n every scanning-enabled app, one bounded batch at a\n time. Skips apps already on that key, restarts the\n rest, and is safe to run again.\n\nPlatform GeoIP (ops account owners and CARLOS_SYSTEM_OPERATORS):\n\n geoip publish <file.mmdb> publish a MaxMind-format database (DB-IP Lite or\n GeoLite2) to every edge. -force skips the shrink check\n geoip status the published database, and whether every box\n strips forged headers and has it\n geoip off stop: edges drop the database and send no geo headers\n\nEnabling antivirus scans nothing by itself: a member still requests scanning\nfor their app, and an operator still grants it per store.\n\nThe platform is not an app: the console is updated with carlos deploy --app console.\n"} |
| {"case":"system pdf | help","argv":["system","pdf","help"],"exit":0,"stdout":"","stderr":"usage: carlos system <verb> [flags]\n carlos system router <verb> [flags]\n carlos system demos <status|serving on|serving off|takedown|takedown-status>\n carlos system managed-fleets <show|set --file f.json>\n carlos system antivirus <status|enable|disable|rotate-webhook-key> [flags]\n carlos system pdf status\n carlos system geoip <publish|status|off> [flags]\n carlos system seeds-floor publish --min-release <release>\n carlos system legacy-routes assign --name <name> --to <account>/<app>\n carlos system lifetimes cutover [--no-wait]\n carlos system hosts-used status\n carlos system named-units install <file>\n carlos system box role <box> <default|legacy|platform>\n carlos system box publish-record\n carlos system group role <region> <default|legacy>\n carlos system host-env <write|seed> --deployment <name> --region <code> [flags]\n\nThe platform's own binary (ops account owners and CARLOS_SYSTEM_OPERATORS):\n\n update promote a platform release to a channel; every box on it rolls itself\n status every box: platform, channel, running build, channel target, last apply outcome\n rollback point a channel back at the release before this one\n cancel-activation\n release a channel's activation reservation that was never\n published, so promote and rollback work again\n apply (root oneshot behind carlos-system-update.service; not for operators)\n layout migrate|revert|status: move every instance into its own directory\n and namespace, or back; see carlos system layout help\n seeds-floor publish --min-release <release>\n the first release whose boxes can place a seed, such as v0.27.0\n legacy-routes assign --name <name> --to <account>/<app>\n say which account and app the routes an operator filed by hand belong to\n lifetimes cutover [--no-wait]\n switch a console without host claims onto instance lifetimes,\n once, after the old console has stopped. Waits until they are on\n hosts-used status\n the hostname history: its mode, how many hostnames it has\n recorded, its closed fleets and its floor\n box role <box> <default|legacy|platform>\n whether new instances may be placed on a box. A legacy or\n platform box keeps the instances it has and takes no new ones\n group role <region> <default|legacy>\n the same for every box a region's group has enrolled, and for\n every box it enrolls later\n box publish-record\n run on a box as the agent user, with systemd-run -p User=carlos:\n publish its AWS-signed identity record to the deployment\n bucket, once. It never replaces or deletes a record\n\nA box a region's group launches (region HA):\n\n host-env write build host.env from the deployment's parameters (root)\n host-env seed copy a box's host.env into the deployment's parameters\n install-channel install the release this box's channel names (root)\n\nDeployment-wide settings (CARLOS_STORE_OPERATORS):\n\n pdf status\n\n antivirus status is object scanning wired, switched on, and answering?\n Reports wiring and policy separately, because they fail\n separately.\n antivirus enable turn object scanning on for this deployment. Refused if\n no engine is wired: a record claiming enabled with\n nothing behind it would report health where no scan can\n run.\n antivirus disable turn it off. Takes effect on the next tick — no restart,\n which is the point of the switch living in a record\n rather than in the unit file.\n antivirus rotate-webhook-key\n deliver the current master-derived callback secret to\n every scanning-enabled app, one bounded batch at a\n time. Skips apps already on that key, restarts the\n rest, and is safe to run again.\n\nPlatform GeoIP (ops account owners and CARLOS_SYSTEM_OPERATORS):\n\n geoip publish <file.mmdb> publish a MaxMind-format database (DB-IP Lite or\n GeoLite2) to every edge. -force skips the shrink check\n geoip status the published database, and whether every box\n strips forged headers and has it\n geoip off stop: edges drop the database and send no geo headers\n\nEnabling antivirus scans nothing by itself: a member still requests scanning\nfor their app, and an operator still grants it per store.\n\nThe platform is not an app: the console is updated with carlos deploy --app console.\n"} |
| {"case":"system pdf | zz-unknown","argv":["system","pdf","zz-unknown"],"exit":2,"stdout":"","stderr":"usage: carlos system <verb> [flags]\n carlos system router <verb> [flags]\n carlos system demos <status|serving on|serving off|takedown|takedown-status>\n carlos system managed-fleets <show|set --file f.json>\n carlos system antivirus <status|enable|disable|rotate-webhook-key> [flags]\n carlos system pdf status\n carlos system geoip <publish|status|off> [flags]\n carlos system seeds-floor publish --min-release <release>\n carlos system legacy-routes assign --name <name> --to <account>/<app>\n carlos system lifetimes cutover [--no-wait]\n carlos system hosts-used status\n carlos system named-units install <file>\n carlos system box role <box> <default|legacy|platform>\n carlos system box publish-record\n carlos system group role <region> <default|legacy>\n carlos system host-env <write|seed> --deployment <name> --region <code> [flags]\n\nThe platform's own binary (ops account owners and CARLOS_SYSTEM_OPERATORS):\n\n update promote a platform release to a channel; every box on it rolls itself\n status every box: platform, channel, running build, channel target, last apply outcome\n rollback point a channel back at the release before this one\n cancel-activation\n release a channel's activation reservation that was never\n published, so promote and rollback work again\n apply (root oneshot behind carlos-system-update.service; not for operators)\n layout migrate|revert|status: move every instance into its own directory\n and namespace, or back; see carlos system layout help\n seeds-floor publish --min-release <release>\n the first release whose boxes can place a seed, such as v0.27.0\n legacy-routes assign --name <name> --to <account>/<app>\n say which account and app the routes an operator filed by hand belong to\n lifetimes cutover [--no-wait]\n switch a console without host claims onto instance lifetimes,\n once, after the old console has stopped. Waits until they are on\n hosts-used status\n the hostname history: its mode, how many hostnames it has\n recorded, its closed fleets and its floor\n box role <box> <default|legacy|platform>\n whether new instances may be placed on a box. A legacy or\n platform box keeps the instances it has and takes no new ones\n group role <region> <default|legacy>\n the same for every box a region's group has enrolled, and for\n every box it enrolls later\n box publish-record\n run on a box as the agent user, with systemd-run -p User=carlos:\n publish its AWS-signed identity record to the deployment\n bucket, once. It never replaces or deletes a record\n\nA box a region's group launches (region HA):\n\n host-env write build host.env from the deployment's parameters (root)\n host-env seed copy a box's host.env into the deployment's parameters\n install-channel install the release this box's channel names (root)\n\nDeployment-wide settings (CARLOS_STORE_OPERATORS):\n\n pdf status\n\n antivirus status is object scanning wired, switched on, and answering?\n Reports wiring and policy separately, because they fail\n separately.\n antivirus enable turn object scanning on for this deployment. Refused if\n no engine is wired: a record claiming enabled with\n nothing behind it would report health where no scan can\n run.\n antivirus disable turn it off. Takes effect on the next tick — no restart,\n which is the point of the switch living in a record\n rather than in the unit file.\n antivirus rotate-webhook-key\n deliver the current master-derived callback secret to\n every scanning-enabled app, one bounded batch at a\n time. Skips apps already on that key, restarts the\n rest, and is safe to run again.\n\nPlatform GeoIP (ops account owners and CARLOS_SYSTEM_OPERATORS):\n\n geoip publish <file.mmdb> publish a MaxMind-format database (DB-IP Lite or\n GeoLite2) to every edge. -force skips the shrink check\n geoip status the published database, and whether every box\n strips forged headers and has it\n geoip off stop: edges drop the database and send no geo headers\n\nEnabling antivirus scans nothing by itself: a member still requests scanning\nfor their app, and an operator still grants it per store.\n\nThe platform is not an app: the console is updated with carlos deploy --app console.\n"} |
| +{"case":"system proxy-allows-prev | --zz-unknown-flag","argv":["system","proxy-allows-prev","--zz-unknown-flag"],"exit":2,"stdout":"","stderr":"usage: carlos system proxy-allows-prev /opt/carlos/carlos.prev\n"} |
| +{"case":"system proxy-allows-prev | -h","argv":["system","proxy-allows-prev","-h"],"exit":2,"stdout":"","stderr":"usage: carlos system proxy-allows-prev /opt/carlos/carlos.prev\n"} |
| {"case":"system rollback | --zz-unknown-flag","argv":["system","rollback","--zz-unknown-flag"],"exit":2,"stdout":"","stderr":"flag provided but not defined: -zz-unknown-flag\nusage: carlos system rollback [flags]\nflags:\n --allow-below-fleet-forward-floor allow a release below v0.32.0 while customer fleets exist. a hub on that release keeps serving fleet apps it can no longer retire\n --allow-below-regional-floor allow a release below v0.31.0 while regional domains exist. servers running that release stop serving them\n --allow-below-rootfs-floor allow a release below v0.29.0 where v0.29.0 or later runs now. boxes may have rootfs instances that release cannot run\n --channel <string> canary or stable (required)\n --console <string> console origin (default: the only logged-in one)\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n --yes do not ask\n"} |
| {"case":"system rollback | -h","argv":["system","rollback","-h"],"exit":0,"stdout":"","stderr":"usage: carlos system rollback [flags]\nflags:\n --allow-below-fleet-forward-floor allow a release below v0.32.0 while customer fleets exist. a hub on that release keeps serving fleet apps it can no longer retire\n --allow-below-regional-floor allow a release below v0.31.0 while regional domains exist. servers running that release stop serving them\n --allow-below-rootfs-floor allow a release below v0.29.0 where v0.29.0 or later runs now. boxes may have rootfs instances that release cannot run\n --channel <string> canary or stable (required)\n --console <string> console origin (default: the only logged-in one)\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n --yes do not ask\n"} |
| {"case":"system router help | extra","argv":["system","router","help"],"exit":0,"stdout":"","stderr":"usage: carlos system <verb> [flags]\n carlos system router <verb> [flags]\n carlos system demos <status|serving on|serving off|takedown|takedown-status>\n carlos system managed-fleets <show|set --file f.json>\n carlos system antivirus <status|enable|disable|rotate-webhook-key> [flags]\n carlos system pdf status\n carlos system geoip <publish|status|off> [flags]\n carlos system seeds-floor publish --min-release <release>\n carlos system legacy-routes assign --name <name> --to <account>/<app>\n carlos system lifetimes cutover [--no-wait]\n carlos system hosts-used status\n carlos system named-units install <file>\n carlos system box role <box> <default|legacy|platform>\n carlos system box publish-record\n carlos system group role <region> <default|legacy>\n carlos system host-env <write|seed> --deployment <name> --region <code> [flags]\n\nThe platform's own binary (ops account owners and CARLOS_SYSTEM_OPERATORS):\n\n update promote a platform release to a channel; every box on it rolls itself\n status every box: platform, channel, running build, channel target, last apply outcome\n rollback point a channel back at the release before this one\n cancel-activation\n release a channel's activation reservation that was never\n published, so promote and rollback work again\n apply (root oneshot behind carlos-system-update.service; not for operators)\n layout migrate|revert|status: move every instance into its own directory\n and namespace, or back; see carlos system layout help\n seeds-floor publish --min-release <release>\n the first release whose boxes can place a seed, such as v0.27.0\n legacy-routes assign --name <name> --to <account>/<app>\n say which account and app the routes an operator filed by hand belong to\n lifetimes cutover [--no-wait]\n switch a console without host claims onto instance lifetimes,\n once, after the old console has stopped. Waits until they are on\n hosts-used status\n the hostname history: its mode, how many hostnames it has\n recorded, its closed fleets and its floor\n box role <box> <default|legacy|platform>\n whether new instances may be placed on a box. A legacy or\n platform box keeps the instances it has and takes no new ones\n group role <region> <default|legacy>\n the same for every box a region's group has enrolled, and for\n every box it enrolls later\n box publish-record\n run on a box as the agent user, with systemd-run -p User=carlos:\n publish its AWS-signed identity record to the deployment\n bucket, once. It never replaces or deletes a record\n\nA box a region's group launches (region HA):\n\n host-env write build host.env from the deployment's parameters (root)\n host-env seed copy a box's host.env into the deployment's parameters\n install-channel install the release this box's channel names (root)\n\nDeployment-wide settings (CARLOS_STORE_OPERATORS):\n\n pdf status\n\n antivirus status is object scanning wired, switched on, and answering?\n Reports wiring and policy separately, because they fail\n separately.\n antivirus enable turn object scanning on for this deployment. Refused if\n no engine is wired: a record claiming enabled with\n nothing behind it would report health where no scan can\n run.\n antivirus disable turn it off. Takes effect on the next tick — no restart,\n which is the point of the switch living in a record\n rather than in the unit file.\n antivirus rotate-webhook-key\n deliver the current master-derived callback secret to\n every scanning-enabled app, one bounded batch at a\n time. Skips apps already on that key, restarts the\n rest, and is safe to run again.\n\nPlatform GeoIP (ops account owners and CARLOS_SYSTEM_OPERATORS):\n\n geoip publish <file.mmdb> publish a MaxMind-format database (DB-IP Lite or\n GeoLite2) to every edge. -force skips the shrink check\n geoip status the published database, and whether every box\n strips forged headers and has it\n geoip off stop: edges drop the database and send no geo headers\n\nEnabling antivirus scans nothing by itself: a member still requests scanning\nfor their app, and an operator still grants it per store.\n\nThe platform is not an app: the console is updated with carlos deploy --app console.\n"} |