fix: keep demo claim capabilities dormant unless configured
demo-claim-seed-v1 is advertised only with CARLOS_DEMO_CLAIM=1 on the box; demo-moved-v1 needs a configured demo domain. The snapshot state directory is added only for demo boxes. Dormant boxes publish as main.
12 files changed,
+144
−39
internal/host/agent.go+9 −8internal/host/claimunit.go+4 −0internal/host/claimunit_test.go+22 −0internal/host/demo_moved_test.go+13 −0internal/host/demo_snapshot_test.go+8 −0internal/host/edgesfile.go+6 −2internal/host/edgesfile_test.go+25 −5internal/host/group_names_test.go+19 −11internal/host/units/carlos-instance-control.service+0 −2internal/status/contract_test.go+11 −8internal/status/snapshot.go+6 −2internal/status/snapshot_test.go+21 −1
diff --git a/internal/host/agent.go b/internal/host/agent.go| index 7e2de4995..f7ae05cbd 100644 |
| --- a/internal/host/agent.go |
| +++ b/internal/host/agent.go |
| @@ -4715,14 +4715,15 @@ func statusLoop(reg *registry.Registry, svc *activator.Service, buildStates func |
| memTotal, memAvail := readMemBytes() |
| p := status.Probes{ |
| - DemoMovedReady: movedReady(), |
| - MachineID: readMachineID(), |
| - InstanceID: cachedInstanceID(), |
| - Region: boxRegion, |
| - NameRegion: nameRegion, |
| - MemFrac: readMemFrac(), |
| - DiskFrac: readDiskFrac(), |
| - Listening: wrapListeningProbe(unitBackedSockets(routes), statusSocketProbe(routes, svc)), |
| + DemoMovedReady: movedReady(), |
| + DemoClaimSeedReady: os.Getenv("CARLOS_DEMO_CLAIM") == "1", |
| + MachineID: readMachineID(), |
| + InstanceID: cachedInstanceID(), |
| + Region: boxRegion, |
| + NameRegion: nameRegion, |
| + MemFrac: readMemFrac(), |
| + DiskFrac: readDiskFrac(), |
| + Listening: wrapListeningProbe(unitBackedSockets(routes), statusSocketProbe(routes, svc)), |
| // One systemctl call per 5-minute tick, asking the only question |
| // that catches an enabled-but-never-armed adoption timer — the |
| // flagship's silent no-adopt state, which nothing on any page |
diff --git a/internal/host/claimunit.go b/internal/host/claimunit.go| index 6fdd08d9d..3454c189a 100644 |
| --- a/internal/host/claimunit.go |
| +++ b/internal/host/claimunit.go |
| @@ -118,6 +118,10 @@ func claimUnitContent(name string, content []byte, cfg claimUnitSettings) []byte |
| if name != claimControlUnit { |
| return content |
| } |
| + if cfg.demo.BoxMode() { |
| + // Retain snapshot recovery on demo boxes even with admission off. |
| + content = bytes.Replace(content, []byte("[Service]\n"), []byte("[Service]\nStateDirectory=carlos-demo-snapshots\nStateDirectoryMode=0700\n"), 1) |
| + } |
| if !cfg.enabled { |
| if cfg.demo.BoxMode() { |
| // systemd creates this root-owned directory before mounting writable |
diff --git a/internal/host/claimunit_test.go b/internal/host/claimunit_test.go| index 9a2190b5f..5fc758bf7 100644 |
| --- a/internal/host/claimunit_test.go |
| +++ b/internal/host/claimunit_test.go |
| @@ -8,6 +8,8 @@ import ( |
| "reflect" |
| "strings" |
| "testing" |
| + |
| + "github.com/carlosframework/platform/internal/demo" |
| ) |
| func TestClaimStagingBootstrapIgnoresUnreadableLiveEnvironment(t *testing.T) { |
| @@ -305,3 +307,23 @@ func TestPlan14RootRetryUnitDirectoryScope(t *testing.T) { |
| t.Fatal("disabled claims changed the unit") |
| } |
| } |
| + |
| +func TestDemoSnapshotDirectoryOnlyOnDemoBoxes(t *testing.T) { |
| + base, err := unitsFS.ReadFile("units/" + claimControlUnit) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + for _, claims := range []bool{false, true} { |
| + for _, demoBox := range []bool{false, true} { |
| + cfg := claimUnitSettings{enabled: claims, data: "/data", opt: "/opt/carlos"} |
| + if demoBox { |
| + cfg.demo = demo.Config{Account: "demo", Fleet: "demo", Domain: "demo.example.com"} |
| + } |
| + body := claimUnitContent(claimControlUnit, base, cfg) |
| + count := bytes.Count(body, []byte("StateDirectory=carlos-demo-snapshots\n")) |
| + if (count == 1) != demoBox || count > 1 { |
| + t.Fatalf("claims=%v demo=%v snapshot directories=%d", claims, demoBox, count) |
| + } |
| + } |
| + } |
| +} |
diff --git a/internal/host/demo_moved_test.go b/internal/host/demo_moved_test.go| index 3a3046aca..12089ed1d 100644 |
| --- a/internal/host/demo_moved_test.go |
| +++ b/internal/host/demo_moved_test.go |
| @@ -100,6 +100,9 @@ func TestDemoMovedRequiresWatch(t *testing.T) { |
| defer armedChangeWatch.Store(oldWatch) |
| defer armedDemoMovedReader.Store(oldReady) |
| env := func(k string) string { |
| + if k == "CARLOS_DEMO_DOMAIN" { |
| + return "demo.example.com" |
| + } |
| if k == "CARLOS_CHANGE_INDEX" { |
| return "read" |
| } |
| @@ -124,6 +127,16 @@ func TestDemoMovedRequiresWatch(t *testing.T) { |
| if !has() { |
| t.Fatal("armed capability absent") |
| } |
| + for _, c := range edgesFileCapabilities(func(k string) string { |
| + if k == "CARLOS_DEMO_DOMAIN" { |
| + return "" |
| + } |
| + return env(k) |
| + }) { |
| + if c == democlaim.MovedCapability { |
| + t.Fatal("unconfigured demo domain advertised moved capability") |
| + } |
| + } |
| } |
| func TestDemoMovedDeliveryStream(t *testing.T) { |
diff --git a/internal/host/demo_snapshot_test.go b/internal/host/demo_snapshot_test.go| index 115927621..db431ab2f 100644 |
| --- a/internal/host/demo_snapshot_test.go |
| +++ b/internal/host/demo_snapshot_test.go |
| @@ -104,6 +104,14 @@ func TestDemoClaimSnapshotUnitContract(t *testing.T) { |
| func TestDemoClaimSnapshotBootstrap(t *testing.T) { |
| root := t.TempDir() |
| + // Snapshot scratch is installed only for a configured source demo box. |
| + etc := filepath.Join(root, "etc/carlos") |
| + if err := os.MkdirAll(etc, 0755); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := os.WriteFile(filepath.Join(etc, "host.env"), []byte("CARLOS_DEMO_BOX=1\nCARLOS_DEMO_ACCOUNT=shop\nCARLOS_DEMO_FLEET=demo\nCARLOS_DEMO_DOMAIN=example.com\n"), 0600); err != nil { |
| + t.Fatal(err) |
| + } |
| if err := bootstrap(root, nil); err != nil { |
| t.Fatal(err) |
| } |
diff --git a/internal/host/edgesfile.go b/internal/host/edgesfile.go| index e08c7deb5..b931057bd 100644 |
| --- a/internal/host/edgesfile.go |
| +++ b/internal/host/edgesfile.go |
| @@ -17,6 +17,7 @@ import ( |
| "github.com/carlosframework/platform/internal/appconfig" |
| "github.com/carlosframework/platform/internal/boxroles" |
| + "github.com/carlosframework/platform/internal/demo" |
| "github.com/carlosframework/platform/internal/democlaim" |
| "github.com/carlosframework/platform/internal/domains" |
| "github.com/carlosframework/platform/internal/edge" |
| @@ -203,8 +204,11 @@ func edgesFileCapabilities(getenv func(string) string) []string { |
| if regionHAEnabled(getenv) { |
| caps = append(caps, capRegionHA1) |
| } |
| - caps = append(caps, edgesfile.NamesCapability, seeds.DemoClaimCapability) |
| - if changeIndexArmed(getenv) && armedChangeWatch.Load() != nil && armedDemoMovedReader.Load() { |
| + caps = append(caps, edgesfile.NamesCapability) |
| + if getenv("CARLOS_DEMO_CLAIM") == "1" { |
| + caps = append(caps, seeds.DemoClaimCapability) |
| + } |
| + if demo.ValidDomain(getenv("CARLOS_DEMO_DOMAIN")) && changeIndexArmed(getenv) && armedChangeWatch.Load() != nil && armedDemoMovedReader.Load() { |
| caps = append(caps, democlaim.MovedCapability) |
| } |
| return caps |
diff --git a/internal/host/edgesfile_test.go b/internal/host/edgesfile_test.go| index 631809823..3e42af6f9 100644 |
| --- a/internal/host/edgesfile_test.go |
| +++ b/internal/host/edgesfile_test.go |
| @@ -1356,13 +1356,13 @@ func TestEdgesFileCapabilityFollowsTheFlag(t *testing.T) { |
| } |
| } |
| // lifetimes-1 is the lifetimes cutover's box floor, published always. |
| - if got := edgesFileCapabilities(env("")); !slices.Equal(got, []string{"lifetimes-1", "names-2", "demo-claim-seed-v1"}) { |
| + if got := edgesFileCapabilities(env("")); !slices.Equal(got, []string{"lifetimes-1", "names-2"}) { |
| t.Fatalf("unset: %v", got) |
| } |
| - if got := edgesFileCapabilities(env("1")); !slices.Equal(got, []string{"lifetimes-1", "region-ha-1", "names-2", "demo-claim-seed-v1"}) { |
| + if got := edgesFileCapabilities(env("1")); !slices.Equal(got, []string{"lifetimes-1", "region-ha-1", "names-2"}) { |
| t.Fatalf("set: %v", got) |
| } |
| - if got := edgesFileCapabilities(env("0")); !slices.Equal(got, []string{"lifetimes-1", "names-2", "demo-claim-seed-v1"}) { |
| + if got := edgesFileCapabilities(env("0")); !slices.Equal(got, []string{"lifetimes-1", "names-2"}) { |
| t.Fatalf("\"0\" is off: %v", got) |
| } |
| } |
| @@ -1386,8 +1386,8 @@ func TestEdgesFilePublishesTheLifetimesFloor(t *testing.T) { |
| t.Fatal(err) |
| } |
| var f edgesfile.PlacementView |
| - if err := json.Unmarshal(b1, &f); err != nil || !slices.Equal(f.Capabilities, []string{capLifetimes1, edgesfile.NamesCapability, "demo-claim-seed-v1"}) { |
| - t.Fatalf("capabilities = %v (%v), want [lifetimes-1 names-2 demo-claim-seed-v1]", f.Capabilities, err) |
| + if err := json.Unmarshal(b1, &f); err != nil || !slices.Equal(f.Capabilities, []string{capLifetimes1, edgesfile.NamesCapability}) { |
| + t.Fatalf("capabilities = %v (%v), want [lifetimes-1 names-2]", f.Capabilities, err) |
| } |
| if err := edgesFileWrite(context.Background(), s, reg, ident, "203.0.113.10", &last, false); err != nil { |
| t.Fatal(err) |
| @@ -2545,3 +2545,23 @@ func TestEdgesFileNeverPublishesRegionalNames(t *testing.T) { |
| } |
| }) |
| } |
| + |
| +func TestDemoClaimSeedCapabilityRequiresConfiguration(t *testing.T) { |
| + for _, flag := range []string{"", "0", "invalid", "1"} { |
| + caps := edgesFileCapabilities(func(k string) string { |
| + if k == "CARLOS_DEMO_CLAIM" { |
| + return flag |
| + } |
| + return "" |
| + }) |
| + found := false |
| + for _, c := range caps { |
| + if c == "demo-claim-seed-v1" { |
| + found = true |
| + } |
| + } |
| + if found != (flag == "1") { |
| + t.Fatalf("flag %q: %v", flag, caps) |
| + } |
| + } |
| +} |
diff --git a/internal/host/group_names_test.go b/internal/host/group_names_test.go| index 63aa467fc..d95069248 100644 |
| --- a/internal/host/group_names_test.go |
| +++ b/internal/host/group_names_test.go |
| @@ -254,7 +254,7 @@ func TestGroupNameClassCensus(t *testing.T) { |
| fields string |
| }{ |
| {registry.Route{}, "DemoID DemoHost DemoLifetime DemoExpiresAt ClaimOwnership WakeIncarnation Host Slug Kind Socket Addr Addrs Health Status HoldOp Incarnation ServingSeq SeedSource ImportGate AssetsOff AssetGen LastError Stateless FleetBoxes Copies ReplicaRevision ReplicaIncarnation DBPath Version PrevVersion GoodVersion GoodDigest GoodDemand ServingVersion App Pool Region Channel Environment Tunnel FleetBox FleetLabel Assigned Moved Caps Hibernate HA Runtime Gate RateLimit Canary Replication NextDue StatusNamed Backing Unit Platform Provisioned Seed Args IdleSeconds MaxRunSeconds DNSStatus DNSCheckedAt CertExpiresAt Account Steering UpdateSettings EgressAllow Size PolicyExpiresAt BuildState Replicas Replica CreatedAt"}, |
| - {provision.Record{}, "Demo ReplicaAssignment Coordinator ReplicaDeploy RecordSeq Acquisition Maintenance Schema Host Slug App Account Pool Region Channel CreatedAt CreatedBy FleetBox FleetBoxAt FleetBoxMoved HA Move LastMove ActiveRun Interactive RunKeys Seed Kind Addr Unit Hibernate Runtime Environment StatusNamed Addrs Health Steering Assets AssetGen Gate Incarnation IncarnationMigrating MoveSeq Retired RateLimit Role Replicas Updates Major Pin InstallRequest"}, |
| + {provision.Record{}, "DemoClaim Demo ReplicaAssignment Coordinator ReplicaDeploy RecordSeq Acquisition Maintenance Schema Host Slug App Account Pool Region Channel CreatedAt CreatedBy FleetBox FleetBoxAt FleetBoxMoved HA Move LastMove ActiveRun Interactive RunKeys Seed Kind Addr Unit Hibernate Runtime Environment StatusNamed Addrs Health Steering Assets AssetGen Gate Incarnation IncarnationMigrating MoveSeq Retired RateLimit Role Replicas Updates Major Pin InstallRequest"}, |
| {edgeHost{}, "Role Platform Alias Replica Wildcard Account App Stamp Incarnation ServingSeq TargetHost Assets"}, |
| {domains.Claim{}, "Acquisition RecordIncarnation OwnershipState Schema Host Account App Route CreatedAt CreatedBy Wildcard Catchall Paths Instances Placements Pending PendingUntil"}, |
| {registry.RouteAlias{}, "Alias Host Account App DNSStatus DNSCheckedAt CertExpiresAt CreatedAt"}, |
| @@ -356,22 +356,30 @@ func unrelated() { println("before") } |
| } |
| } |
| +// Demo claims retain exact-route names. RouteFor changes only hold/seed gate |
| +// columns; Reconcile creates that exact destination atomically with its gate. |
| +// abortDemoClaimSeed uses rec.Host for fenced cleanup, never an alias or a new |
| +// name. DemoClaim on Record is a hold descriptor, not a naming input. Reload |
| +// preserves held source names as refusal-only entries. Existing exact-route |
| +// and alias cases remain the name classes; claim gate witnesses live alongside |
| +// the seed and moved implementations. |
| var groupNameProducerInventory = map[string]string{ |
| - "../domains/aliases.go:ReconcileAliasesReport": "c022beb479d23f0be5f0cb1c591daf9f479507bb7acd2fb9262c1392357c0c61", |
| - "../domains/aliases.go:deriveInstanceAliases": "47b40b392927d9c50cab6c350083af24565e4e148cd1b5ddc257e9803153c0c2", |
| - "../domains/aliases.go:deriveRegional": "79fd7c432e6b0a9ffd945312851e52af2c450769416ef44ff9a4bea681b44cde", |
| - "../domains/reconcile.go:Reconcile": "8b2848535d0a15117d578ac28c7486997c6ad8960b58b6dca5d4b35cde14eed0", |
| - "../domains/reconcile.go:mintedRoute": "dbd2211f62fc606661c6d8258ecfbf18f0b3c865e775522c5b363d01c442fca9", |
| - "../edge/assetcatch.go:*Edge.AssetOwners": "2b9ce5620a6defa16f12cb38d389ac59aa594049d37d84746f0a76419ab05b5f", |
| - "../edge/assetcatch.go:*Edge.serveAssetFar": "7d358ec272ae74c05764504550bad461096a09d0bfcc108dcbe5485f8f68d643", |
| + "../provision/demo_claim_seed.go:abortDemoClaimSeed": "e010b4e6b026a0744b7eacf6ffdb09647de6e1541e33ce73e71e7c99964a9f7a", |
| + "../domains/aliases.go:ReconcileAliasesReport": "c022beb479d23f0be5f0cb1c591daf9f479507bb7acd2fb9262c1392357c0c61", |
| + "../domains/aliases.go:deriveInstanceAliases": "47b40b392927d9c50cab6c350083af24565e4e148cd1b5ddc257e9803153c0c2", |
| + "../domains/aliases.go:deriveRegional": "79fd7c432e6b0a9ffd945312851e52af2c450769416ef44ff9a4bea681b44cde", |
| + "../domains/reconcile.go:Reconcile": "8b2848535d0a15117d578ac28c7486997c6ad8960b58b6dca5d4b35cde14eed0", |
| + "../domains/reconcile.go:mintedRoute": "dbd2211f62fc606661c6d8258ecfbf18f0b3c865e775522c5b363d01c442fca9", |
| + "../edge/assetcatch.go:*Edge.AssetOwners": "2b9ce5620a6defa16f12cb38d389ac59aa594049d37d84746f0a76419ab05b5f", |
| + "../edge/assetcatch.go:*Edge.serveAssetFar": "7d358ec272ae74c05764504550bad461096a09d0bfcc108dcbe5485f8f68d643", |
| // Demo protections wrap existing proxies and retain refusal-only names. |
| // They do not derive or publish a new group-name class. |
| - "../edge/edge.go:*Edge.Reload": "1030be6dfba6a0737bc47a41d465376a03e5b3cd552dbbdb9026a1c60151d1b2", |
| + "../edge/edge.go:*Edge.Reload": "5668e946875f86390c1e7354a7ac76310e91bbe69e96402765c007b97c83ea67", |
| "../edge/platformalias.go:PlatformAliasFold": "a18e4963cf88320ef3fb94b666b02838dc12cc3e9b2df3f2cbe2576ca682735f", |
| "../edge/regional.go:*Edge.foldRegional": "b413fad6a8e17530ce0e99c79c521e0a6782b82c04d61d256442b8defe6a427b", |
| "../provision/forward.go:forwardRowFor": "e7294d6a3c96e51646257200f5cedb26aaf491afea23be3d943b3e3f742c4db4", |
| - "../provision/reconcile.go:Reconcile": "d4b6447577c170d4d0999caced11931cdf13fef135da2c9a3331a5dda275c030", |
| - "../provision/reconcile.go:RouteFor": "cc7d8bccdf858e21d39f9b1275f7cf673a4ce8015b62bb7885d5cf52e28cb770", |
| + "../provision/reconcile.go:Reconcile": "cda911d2c5634ea58aafa86e9469a0412ebe70a87588d045b73d67d55f347042", |
| + "../provision/reconcile.go:RouteFor": "304e92d9123c1cc7d756319756c4311ee235266cd6b2290f058c91e45fbe0cc1", |
| "../provision/reconcile.go:mintHeld": "9fe4ad876c727af36cc06bd0105baf344748c61e6f21ced48e5288a323851344", |
| "../provision/seedreconcile.go:purgeAbortedFromLocal": "889e93e6fbd74adf614ba184bcd2f554196eccc4506829c65326a3502e98d89a", |
| "../provision/seedrollback.go:removeOrphanedLocal": "6dd05836ac1d346de23ad555d50bb6c8fcd574cf05b6dfbf916eb0b220d88586", |
diff --git a/internal/host/units/carlos-instance-control.service b/internal/host/units/carlos-instance-control.service| index 45a8bdc0d..59b2d2b55 100644 |
| --- a/internal/host/units/carlos-instance-control.service |
| +++ b/internal/host/units/carlos-instance-control.service |
| @@ -33,8 +33,6 @@ ProtectSystem=strict |
| # /run/systemd/system: the per-generation runtime drop-in (zero-downtime |
| # deploys, plan 2 D1); nothing else is written there. |
| ReadWritePaths=/run/carlos-control /run/systemd/system |
| -StateDirectory=carlos-demo-snapshots |
| -StateDirectoryMode=0700 |
| ProtectHome=yes |
| PrivateTmp=yes |
| PrivateDevices=yes |
diff --git a/internal/status/contract_test.go b/internal/status/contract_test.go| index e2686bfc9..8c672eab7 100644 |
| --- a/internal/status/contract_test.go |
| +++ b/internal/status/contract_test.go |
| @@ -79,10 +79,11 @@ var allowedBoxKeys = map[string][]string{ |
| // Safe on the identical structural ground: BuildFleet's field-by-field |
| // copy never names "metrics", so no hostname here can reach FleetBox or |
| // fleet.json regardless of what this map holds. |
| - "": {"generated_at", "label", "name", "region", "routes", "load", "capacity", "replication", "adoption_running", "config_path_running", "restart_path_running", "expired_canaries", "metrics"}, |
| - "routes": {"static", "resident", "hibernating", "awake", "asleep"}, |
| - "replication": {"healthy", "lag_seconds"}, |
| - "metrics": {"mem_total_bytes", "mem_avail_bytes", "load1", "disk_free_bytes", "release", "tunnel", "route_versions", "upstreams", "layout", "config_refusals", "config_refusals_total", "release_refusals", "proof_waits", "config_guard", "build_states", "build_states_err", "update_settings", "updates", "egress", "size_committed_mib"}, |
| + "": {"generated_at", "label", "name", "region", "routes", "load", "capacity", "replication", "adoption_running", "config_path_running", "restart_path_running", "expired_canaries", "metrics"}, |
| + "routes": {"static", "resident", "hibernating", "awake", "asleep"}, |
| + "replication": {"healthy", "lag_seconds"}, |
| + // capabilities names supported protocols only, in the bucket-private metrics. |
| + "metrics": {"capabilities", "mem_total_bytes", "mem_avail_bytes", "load1", "disk_free_bytes", "release", "tunnel", "route_versions", "upstreams", "layout", "config_refusals", "config_refusals_total", "release_refusals", "proof_waits", "config_guard", "build_states", "build_states_err", "update_settings", "updates", "egress", "size_committed_mib"}, |
| "metrics.route_versions": {wildcardAnyKey}, |
| "metrics.upstreams": {wildcardAnyKey}, |
| "metrics.upstreams.*[]": {"addr", "up", "since", "fails", "last_error"}, |
| @@ -342,10 +343,12 @@ func fixtureProbes() status.Probes { |
| } |
| return status.Probes{ |
| - MachineID: "test-machine-id", |
| - Region: "us-west-1", |
| - Upstreams: upstreams, |
| - Layout: layoutReport, |
| + DemoClaimSeedReady: true, |
| + DemoMovedReady: true, |
| + MachineID: "test-machine-id", |
| + Region: "us-west-1", |
| + Upstreams: upstreams, |
| + Layout: layoutReport, |
| // One refusal so metrics.config_refusals is exercised by the |
| // allowlist walk and not merely permitted by it. |
| ConfigRefusals: []status.ConfigRefusal{ |
diff --git a/internal/status/snapshot.go b/internal/status/snapshot.go| index dd48259a7..6ab43d54a 100644 |
| --- a/internal/status/snapshot.go |
| +++ b/internal/status/snapshot.go |
| @@ -42,6 +42,7 @@ import ( |
| // Probes carries everything CollectBox may not read from the registry — |
| // each nil means "unknown", and unknown publishes as null, never a guess. |
| type Probes struct { |
| + DemoClaimSeedReady bool |
| DemoMovedReady bool |
| ConsoleProcesses []ConsoleProcess |
| ActivationID string |
| @@ -1173,8 +1174,11 @@ func CollectBox(routes []registry.Route, p Probes, now time.Time) Box { |
| len(routeVersions) > 0 || len(routeServing) > 0 || len(aliasReadings) > 0 || p.AliasesRead || len(p.Upstreams) > 0 || len(p.ReplicaCopies) > 0 || |
| len(routeDBBytes) > 0 || p.Layout != nil || len(p.ConfigRefusals) > 0 || len(p.ReleaseRefusals) > 0 || len(p.ProofWaits) > 0 || p.Rollout != nil || p.ConfigGuard != "" || |
| p.Alerts != nil || p.GeoIP != nil || p.HeldStreams != nil || len(p.BuildStates) > 0 || p.BuildStatesErr != "" || |
| - p.UpdateSettings != 0 || len(p.Updates) > 0 || len(p.Egress) > 0 || p.SizeCommittedMiB != nil { |
| - capabilities := []string{seeds.DemoClaimCapability} |
| + p.DemoClaimSeedReady || p.DemoMovedReady || p.UpdateSettings != 0 || len(p.Updates) > 0 || len(p.Egress) > 0 || p.SizeCommittedMiB != nil { |
| + var capabilities []string |
| + if p.DemoClaimSeedReady { |
| + capabilities = append(capabilities, seeds.DemoClaimCapability) |
| + } |
| if p.DemoMovedReady { |
| capabilities = append(capabilities, democlaim.MovedCapability) |
| } |
diff --git a/internal/status/snapshot_test.go b/internal/status/snapshot_test.go| index bac4a728c..95aafe5a3 100644 |
| --- a/internal/status/snapshot_test.go |
| +++ b/internal/status/snapshot_test.go |
| @@ -381,7 +381,7 @@ func TestCollectBoxCarriesAliasesRead(t *testing.T) { |
| if err != nil { |
| t.Fatal(err) |
| } |
| - if !strings.Contains(string(out), `"metrics":{"capabilities":["demo-claim-seed-v1"],"aliases_read":true}`) { |
| + if !strings.Contains(string(out), `"metrics":{"aliases_read":true}`) { |
| t.Fatalf("json lacks the aliases_read-only metrics block: %s", out) |
| } |
| off := CollectBox(nil, Probes{Release: "v1"}, at) |
| @@ -427,3 +427,23 @@ func TestDemoMovedCapabilityConfigured(t *testing.T) { |
| } |
| } |
| } |
| + |
| +func TestDemoClaimSeedCapabilityConfigured(t *testing.T) { |
| + for _, ready := range []bool{false, true} { |
| + b := CollectBox(nil, Probes{DemoClaimSeedReady: ready}, time.Now()) |
| + if !ready { |
| + if b.Metrics != nil { |
| + t.Fatal("dormant claim added metrics") |
| + } |
| + continue |
| + } |
| + if b.Metrics == nil || !reflect.DeepEqual(b.Metrics.Capabilities, []string{"demo-claim-seed-v1"}) { |
| + t.Fatalf("configured claim missing capability: %+v", b.Metrics) |
| + } |
| + } |
| + b := CollectBox(nil, Probes{Release: "test"}, time.Now()) |
| + raw, _ := json.Marshal(b) |
| + if strings.Contains(string(raw), `"capabilities"`) { |
| + t.Fatal("dormant claim changed status JSON") |
| + } |
| +} |