carlos / platform Public

egress: a member sees an egress report only for the tenant it was asserted for (#328, final review F3)

The member join matched box reports to instances by host name alone, so
after a host name passed to another tenant, a fresh box snapshot (or root's
retained report for the stopped host) could show the new owner the previous
tenant's allowed addresses. Root's policy and report now carry the account
and app of the row they were read from; the agent's status probe prunes a
root report asserted for another tenant than the host's row now names, and
stamps the row's tenant only on a report that matches it (or on its own
word about the row); the console shows a member only entries stamped with
the instance's own account and app. A report with nothing to say names no
tenant, so a host with no policy still reports {}.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev 3b07b731600189eaf68e64307e4db67e409b4983 parent 5e4a034
9 files changed, +208 −16
  • internal/console/apiinstances.go +11 −3
  • internal/console/apiinstances_test.go +20 −7
  • internal/host/egress_source.go +13 −5
  • internal/host/egress_source_test.go +41 −0
  • internal/host/egress_status.go +18 −0
  • internal/host/egress_status_test.go +44 −1
  • internal/instancectl/egress.go +17 −0
  • internal/instancectl/egress_test.go +37 −0
  • internal/status/snapshot.go +7 −0
diff --git a/internal/console/apiinstances.go b/internal/console/apiinstances.go
index a164fa9af..844d7bd31 100644
--- a/internal/console/apiinstances.go
+++ b/internal/console/apiinstances.go
@@ -517,9 +517,17 @@ func (j boxJoin) dbSize(host string) *int64 {
}
// egressFor is the join's member view of host's egress, nil when no fresh
-// box reported one (memberEgressView).
-func (j boxJoin) egressFor(host string) *memberEgress {
+// box reported one (memberEgressView), or when the entry is not this
+// account's and this app's (final review F3): a host name can pass to
+// another tenant while a box still reports the last one's allow, so an
+// entry is shown only for the tenant the box stamped on it, and one it
+// could not attribute (no tenant) is never shown to a member. The
+// rollout join's rule (rollout), without its refused-box exception.
+func (j boxJoin) egressFor(host, acct, app string) *memberEgress {
h, ok := j.egress[host]
+ if !ok || h.Account == "" || h.Account != acct || h.App != app {
+ return nil
+ }
return memberEgressView(h, ok)
}
@@ -873,7 +881,7 @@ func (s *Server) handleAPIInstanceList(w http.ResponseWriter, r *http.Request) {
Rollout: join.rollout(rec.Host, acct.Sqid, app),
UpdateReport: join.update(rec.Host, acct.Sqid, app),
SettingsDefault: provision.EffectiveUpdates(rec, policy).Default(),
- Egress: join.egressFor(rec.Host)})
+ Egress: join.egressFor(rec.Host, acct.Sqid, app)})
}
total := len(matched)
// provision.ListRecords returns records host-sorted and nothing above
diff --git a/internal/console/apiinstances_test.go b/internal/console/apiinstances_test.go
index 1946a4423..b431d071a 100644
--- a/internal/console/apiinstances_test.go
+++ b/internal/console/apiinstances_test.go
@@ -2640,6 +2640,11 @@ func TestAPIInstanceListDBBytes(t *testing.T) {
// detail (which can name another tenant's host and unit), its refusals
// (which can name the box's addresses and prefixes) and the fleet-address
// report's conflicts never reach it.
+//
+// An entry is shown only for the tenant the box stamped on it (final
+// review F3): shop-f's entry is another account's, shop-g's this account's
+// other app's, both left from an earlier holder of the host name, and
+// shop-h's could not be attributed; none reaches the member.
func TestAPIInstancesJoinsEgress(t *testing.T) {
t.Parallel()
fx, token := instanceFixture(t, "code-inst-egress")
@@ -2649,7 +2654,8 @@ func TestAPIInstancesJoinsEgress(t *testing.T) {
enableInstances(t, fx, "shop", provision.Manifest{Schema: 1, App: "shop", Domain: "example.com",
Channel: "stable", Regions: []string{"ie"}, Seed: []string{"seed"}})
u := instancesURL(fx, "bab", "shop")
- hosts := []string{"shop-a.example.com", "shop-b.example.com", "shop-c.example.com", "shop-d.example.com", "shop-e.example.com"}
+ hosts := []string{"shop-a.example.com", "shop-b.example.com", "shop-c.example.com", "shop-d.example.com", "shop-e.example.com",
+ "shop-f.example.com", "shop-g.example.com", "shop-h.example.com"}
for _, h := range hosts {
if code, _, out := rawReq(t, http.MethodPost, u, token,
fmt.Sprintf(`{"host":%q,"region":"ie"}`, h)); code != http.StatusCreated {
@@ -2665,17 +2671,21 @@ func TestAPIInstancesJoinsEgress(t *testing.T) {
fresh := status.CollectBox(nil, status.Probes{MachineID: "box1"}, time.Now())
fresh.Metrics = &status.BoxMetrics{Egress: map[string]status.HostEgress{
"shop-a.example.com": {Allowed: []string{"10.0.5.20", "fd00:5::20"}, State: "failing",
- Detail: "restarted to close 10.0.5.21", Refused: []string{localRefusal}},
- "shop-b.example.com": {State: "not_nested", Detail: otherTenant, Refused: []string{localRefusal}},
- "shop-d.example.com": {Allowed: []string{"10.0.5.20"}, Refused: []string{localRefusal}},
- "shop-e.example.com": {Allowed: []string{"10.0.5.20"}},
+ Detail: "restarted to close 10.0.5.21", Refused: []string{localRefusal}, Account: "bab", App: "shop"},
+ "shop-b.example.com": {State: "not_nested", Detail: otherTenant, Refused: []string{localRefusal}, Account: "bab", App: "shop"},
+ "shop-d.example.com": {Allowed: []string{"10.0.5.20"}, Refused: []string{localRefusal}, Account: "bab", App: "shop"},
+ "shop-e.example.com": {Allowed: []string{"10.0.5.20"}, Account: "bab", App: "shop"},
+ // Hostname reuse: what an earlier holder's slice was allowed.
+ "shop-f.example.com": {Allowed: []string{"10.0.7.1"}, Account: "zzz", App: "shop"},
+ "shop-g.example.com": {Allowed: []string{"10.0.7.2"}, Account: "bab", App: "blog"},
+ "shop-h.example.com": {Allowed: []string{"10.0.7.3"}, State: "under_claims"},
}}
if err := status.WriteBox(context.Background(), fx.rel, fresh); err != nil {
t.Fatal(err)
}
stale := status.CollectBox(nil, status.Probes{MachineID: "box2"}, time.Now().Add(-time.Hour))
stale.Metrics = &status.BoxMetrics{Egress: map[string]status.HostEgress{
- "shop-c.example.com": {Allowed: []string{"10.0.5.20"}},
+ "shop-c.example.com": {Allowed: []string{"10.0.5.20"}, Account: "bab", App: "shop"},
}}
if err := status.WriteBox(context.Background(), fx.rel, stale); err != nil {
t.Fatal(err)
@@ -2686,7 +2696,7 @@ func TestAPIInstancesJoinsEgress(t *testing.T) {
if code != http.StatusOK {
t.Fatalf("list = %d %s", code, out)
}
- for _, leak := range []string{"blog-z", "carlos-named", "10.0.9.", "10.0.5.21", "conflicts", "box-b", "refused", "detail"} {
+ for _, leak := range []string{"blog-z", "carlos-named", "10.0.9.", "10.0.5.21", "conflicts", "box-b", "refused", "detail", "10.0.7.", "zzz"} {
if strings.Contains(out, leak) {
t.Fatalf("a member's list carries %q: %s", leak, out)
}
@@ -2707,6 +2717,9 @@ func TestAPIInstancesJoinsEgress(t *testing.T) {
"shop-c.example.com": ``,
"shop-d.example.com": `{"allowed":["10.0.5.20"],` + notAvailable,
"shop-e.example.com": `{"allowed":["10.0.5.20"]}`,
+ "shop-f.example.com": ``,
+ "shop-g.example.com": ``,
+ "shop-h.example.com": ``,
}
if len(list.Instances) != len(want) {
t.Fatalf("instances = %s", out)
diff --git a/internal/host/egress_source.go b/internal/host/egress_source.go
index 6ff7e168d..3488f55e9 100644
--- a/internal/host/egress_source.go
+++ b/internal/host/egress_source.go
@@ -228,9 +228,17 @@ func (s *registrySource) policyFrom(ctx context.Context, snap *egressSnapshot, h
break
}
}
- if row == nil || strings.TrimSpace(row.EgressAllow) == "" {
+ if row == nil {
return instancectl.EgressPolicy{}, time.Time{}
}
+ // The row's tenant goes with every answer about it (final review F3).
+ who := func(p instancectl.EgressPolicy) instancectl.EgressPolicy {
+ p.Account, p.App = row.Account, row.App
+ return p
+ }
+ if strings.TrimSpace(row.EgressAllow) == "" {
+ return who(instancectl.EgressPolicy{}), time.Time{}
+ }
snap.railMu.Lock()
if !snap.railDone {
// The rows first (their reasons name a host), then root's own
@@ -246,19 +254,19 @@ func (s *registrySource) policyFrom(ctx context.Context, snap *egressSnapshot, h
nested, reason := snap.nested, snap.reason
snap.railMu.Unlock()
if !nested {
- return instancectl.EgressPolicy{Closed: instancectl.EgressNotNested, Detail: reason}, time.Time{}
+ return who(instancectl.EgressPolicy{Closed: instancectl.EgressNotNested, Detail: reason}), time.Time{}
}
secs, err := strconv.ParseInt(row.PolicyExpiresAt, 10, 64)
if err != nil || secs <= 0 {
// '' (none recorded), '0' and anything that is not a time: the
// agent writes no allow without an expiry, so none is honoured.
- return instancectl.EgressPolicy{Closed: instancectl.EgressExpired, Detail: "no expiry recorded"}, time.Time{}
+ return who(instancectl.EgressPolicy{Closed: instancectl.EgressExpired, Detail: "no expiry recorded"}), time.Time{}
}
until := time.Unix(secs, 0)
if !until.After(now) {
- return instancectl.EgressPolicy{Closed: instancectl.EgressExpired, Detail: expiredDetail(until)}, time.Time{}
+ return who(instancectl.EgressPolicy{Closed: instancectl.EgressExpired, Detail: expiredDetail(until)}), time.Time{}
}
- return instancectl.EgressPolicy{Allow: strings.Fields(row.EgressAllow)}, until
+ return who(instancectl.EgressPolicy{Allow: strings.Fields(row.EgressAllow)}), until
}
func expiredDetail(until time.Time) string {
diff --git a/internal/host/egress_source_test.go b/internal/host/egress_source_test.go
index b940f50d8..e1b1cc599 100644
--- a/internal/host/egress_source_test.go
+++ b/internal/host/egress_source_test.go
@@ -208,8 +208,12 @@ func readPolicy(t *testing.T, src instancectl.EgressSource, host string) instanc
return p
}
+// wantPolicy compares got with want, all but the row's tenant (Account,
+// App), which TestRegistryEgressSourceCarriesTheRowTenant checks on every
+// branch.
func wantPolicy(t *testing.T, got, want instancectl.EgressPolicy) {
t.Helper()
+ got.Account, got.App = want.Account, want.App
if !reflect.DeepEqual(got, want) {
t.Fatalf("policy = %+v, want %+v", got, want)
}
@@ -813,3 +817,40 @@ func TestEgressAssertersKeepOwedChangesUnderRun(t *testing.T) {
}
}
}
+
+// TestRegistryEgressSourceCarriesTheRowTenant: every answer about a row
+// carries the row's account and app (final review F3), so root's report
+// can be told from one about an earlier holder of the host name; a host
+// with no row carries none, and so does the claims source, which reads no
+// row.
+func TestRegistryEgressSourceCarriesTheRowTenant(t *testing.T) {
+ t.Parallel()
+ reg, dd := egressRegistry(t)
+ clock := &testClock{now: time.Date(2026, 10, 25, 9, 0, 0, 0, time.UTC)}
+ row := func(host string) registry.Route {
+ rt := nestedRow(dd, host)
+ rt.Account, rt.App = "abc", "shop"
+ return rt
+ }
+ upsertRows(t, reg, row("shop-a.example.com"), row("shop-b.example.com"), row("shop-c.example.com"))
+ setAllow(t, reg, "shop-a.example.com", "10.0.5.20", unixText(clock.Now().Add(time.Hour)))
+ setAllow(t, reg, "shop-c.example.com", "10.0.5.20", unixText(clock.Now().Add(-time.Hour)))
+ src := testEgressSource(t, dd, clock.Now)
+ tenant := func(step string, p instancectl.EgressPolicy, account, app string) {
+ t.Helper()
+ if p.Account != account || p.App != app {
+ t.Fatalf("%s: %+v carries tenant %q/%q, want %q/%q", step, p, p.Account, p.App, account, app)
+ }
+ }
+ tenant("an allow", readPolicy(t, src, "shop-a.example.com"), "abc", "shop")
+ tenant("no allow", readPolicy(t, src, "shop-b.example.com"), "abc", "shop")
+ tenant("expired", readPolicy(t, src, "shop-c.example.com"), "abc", "shop")
+ tenant("no row", readPolicy(t, src, "gone.example.com"), "", "")
+ upsertRows(t, reg, flatRow(dd, "old.example.com"))
+ p := readPolicy(t, src, "shop-a.example.com")
+ if p.Closed != instancectl.EgressNotNested {
+ t.Fatalf("fixture: %+v, want not nested", p)
+ }
+ tenant("not nested", p, "abc", "shop")
+ tenant("under claims", readPolicy(t, claimsEgressSource(), "shop-a.example.com"), "", "")
+}
diff --git a/internal/host/egress_status.go b/internal/host/egress_status.go
index b9ad0d673..d2eb37abf 100644
--- a/internal/host/egress_status.go
+++ b/internal/host/egress_status.go
@@ -9,6 +9,7 @@ import (
"github.com/carlosframework/platform/internal/instancectl"
"github.com/carlosframework/platform/internal/registry"
+ "github.com/carlosframework/platform/internal/release"
"github.com/carlosframework/platform/internal/status"
)
@@ -43,6 +44,15 @@ var egressStatusErrs atomic.Int64
// held, none refused, no state) is left out, and so is a host the box no
// longer lists.
//
+// Root keeps a host's last report after the host stops, and a host name can
+// be given to another tenant (final review F3). So a report root asserted
+// from a row of another account or app than the host's row now is dropped
+// here, as if root had none; a report with no tenant (root read no row, or
+// claims are on) is published with no tenant, which operator views show and
+// members never see. Every other entry carries the row's tenant
+// (release.RouteAccount, as the rollout report does) for the console to
+// check against the instance it shows.
+//
// A nil c (no control channel on this box), or a failed read, is nil: not
// reported, which is not the same as nothing allowed. The read is root's
// local socket, with a 5 s timeout: no store request.
@@ -64,16 +74,24 @@ func egressStatusProbe(c egressStatusReader, rows []registry.Route, agentStates
var out map[string]status.HostEgress
for _, rt := range rows {
rep := st.Hosts[rt.Host]
+ attributed := rep.Account != "" || rep.App != ""
+ if attributed && (rep.Account != rt.Account || rep.App != rt.App) {
+ rep = instancectl.EgressReport{} // an earlier holder's: pruned
+ }
h := status.HostEgress{Allowed: rep.Allowed, Refused: rep.Refused, State: rep.State, Detail: rep.Detail}
if h.State == instancectl.EgressUnderClaims && strings.TrimSpace(rt.EgressAllow) == "" {
continue
}
+ rootSaid := h.State != "" || h.Detail != "" || len(h.Allowed) > 0 || len(h.Refused) > 0
if h.State == "" && rt.Kind == "instance" && rt.Account != "" && rt.App != "" {
h.State = agentPolicyState(agentStates[rt.Account+"/"+rt.App])
}
if h.State == "" && h.Detail == "" && len(h.Allowed) == 0 && len(h.Refused) == 0 {
continue
}
+ if !rootSaid || (attributed && rep.Account == rt.Account && rep.App == rt.App) {
+ h.Account, h.App = release.RouteAccount(rt), rt.App
+ }
if out == nil {
out = map[string]status.HostEgress{}
}
diff --git a/internal/host/egress_status_test.go b/internal/host/egress_status_test.go
index 909690cb7..2cdb06fa0 100644
--- a/internal/host/egress_status_test.go
+++ b/internal/host/egress_status_test.go
@@ -11,6 +11,7 @@ import (
"github.com/carlosframework/platform/internal/instancectl"
"github.com/carlosframework/platform/internal/registry"
+ "github.com/carlosframework/platform/internal/release"
"github.com/carlosframework/platform/internal/status"
)
@@ -125,7 +126,8 @@ func TestEgressStatusProbeCarriesTheAgentsPolicyState(t *testing.T) {
{Host: "side.shop.abc.sidecar.internal", Kind: "sidecar", Account: "abc", App: "shop"},
}
got = egressStatusProbe(rootReports(nil), rows, map[string]string{"abc/shop": "policy expired", "bab/odd": "policy mislaid"})
- want := map[string]status.HostEgress{"shop-b.example.com": {State: "expired"}}
+ // The agent's own word is about the row: it carries the row's tenant.
+ want := map[string]status.HostEgress{"shop-b.example.com": {State: "expired", Account: "abc", App: "shop"}}
if !reflect.DeepEqual(got, want) {
t.Fatalf("probe = %+v\nwant %+v", got, want)
}
@@ -179,3 +181,44 @@ func TestEgressStatusProbeShowsUnderClaimsOnlyWhereGranted(t *testing.T) {
t.Fatalf("snapshot carries an egress key: %s", raw)
}
}
+
+// TestEgressStatusProbeHostnameReuse is final review F3 on the agent's
+// side: root keeps a host's last report after it stops, and the host name
+// can pass to another tenant. A report root asserted from another
+// tenant's row is pruned, as if root had none (the agent's own word about
+// the new row still stands); one from this row's tenant carries the
+// tenant (release.RouteAccount, as the rollout report has it); one root
+// could not attribute is published with no tenant.
+func TestEgressStatusProbeHostnameReuse(t *testing.T) {
+ t.Parallel()
+ rows := []registry.Route{
+ egressStatusRow("shop-a.example.com", "zzz", "blog", ""), // reused: root's report is abc/shop's
+ egressStatusRow("shop-b.example.com", "abc", "blog", ""), // reused within the account
+ egressStatusRow("shop-c.example.com", "abc", "shop", "10.0.5.20"), // root's report is this row's
+ egressStatusRow("shop-d.example.com", "zzz", "blog", ""), // reused, and the agent has a word
+ egressStatusRow("shop-e.example.com", "abc", "shop", "10.0.5.20"), // root read no row
+ {Host: "ops.example.com", Kind: "instance", App: "ops", EgressAllow: "10.0.5.20"}, // no account: the ops account
+ }
+ earlier := instancectl.EgressReport{Allowed: []string{"10.0.7.1"}, State: instancectl.EgressFailing, Detail: "x", Account: "abc", App: "shop"}
+ c := rootReports(map[string]instancectl.EgressReport{
+ "shop-a.example.com": earlier,
+ "shop-b.example.com": earlier,
+ "shop-c.example.com": {Allowed: []string{"10.0.5.20"}, Account: "abc", App: "shop"},
+ "shop-d.example.com": earlier,
+ "shop-e.example.com": {Allowed: []string{"10.0.7.3"}, State: instancectl.EgressFailing},
+ "ops.example.com": {Allowed: []string{"10.0.5.20"}, App: "ops"},
+ })
+ got := egressStatusProbe(c, rows, map[string]string{"zzz/blog": "policy expired"})
+ want := map[string]status.HostEgress{
+ "shop-c.example.com": {Allowed: []string{"10.0.5.20"}, Account: "abc", App: "shop"},
+ "shop-d.example.com": {State: "expired", Account: "zzz", App: "blog"},
+ "shop-e.example.com": {Allowed: []string{"10.0.7.3"}, State: "failing"},
+ "ops.example.com": {Allowed: []string{"10.0.5.20"}, Account: release.OpsAccount, App: "ops"},
+ }
+ // shop-a: pruned, and the agent's word for zzz/blog applies (a row of
+ // zzz/blog), so it reads expired like shop-d.
+ want["shop-a.example.com"] = want["shop-d.example.com"]
+ if !reflect.DeepEqual(got, want) {
+ t.Fatalf("probe = %+v\nwant %+v", got, want)
+ }
+}
diff --git a/internal/instancectl/egress.go b/internal/instancectl/egress.go
index 269c8f25e..af2a5586c 100644
--- a/internal/instancectl/egress.go
+++ b/internal/instancectl/egress.go
@@ -66,6 +66,11 @@ type EgressPolicy struct {
Allow []string // entries as stored (the registry column split on spaces)
Closed string // non-empty: write no allow; becomes the report's State
Detail string // why, when Closed is set; becomes the report's Detail (Astra plan R2-4)
+ // Account and App are the tenant of the row the source read for the
+ // host, "" when it read none (no row, or a source that reads no rows,
+ // as under claims). They become the report's, so a report can be told
+ // from one about an earlier holder of the host name (final review F3).
+ Account, App string
}
// EgressSource reads one host's policy. A non-nil error means "could not read
@@ -87,6 +92,12 @@ type EgressReport struct {
Refused []string `json:"refused,omitempty"` // "<entry>: <reason>"
State string `json:"state,omitempty"` // "" when held == desired and the policy was read
Detail string `json:"detail,omitempty"`
+ // Account and App are the policy's (EgressPolicy): the tenant whose
+ // row this report was asserted from, "" when none was read. The
+ // agent's status probe publishes a report only for the row of that
+ // same tenant.
+ Account string `json:"account,omitempty"`
+ App string `json:"app,omitempty"`
}
// EgressAsserter owns each per-host slice's IPAddressAllow (#328): it
@@ -217,6 +228,7 @@ func (e *EgressAsserter) assert(ctx context.Context, host string, start bool) er
} else {
e.remember(host, pol)
}
+ rep.Account, rep.App = pol.Account, pol.App
// Under host claims every write is a reset, and a claim unit's start
// refuses drop-ins it did not write, so its revokes restart (reach).
@@ -813,6 +825,11 @@ func (e *EgressAsserter) remember(host string, p EgressPolicy) {
}
func (e *EgressAsserter) record(host string, r EgressReport) {
+ if len(r.Allowed) == 0 && len(r.Refused) == 0 && r.State == "" && r.Detail == "" {
+ // Nothing to say names no tenant either: a host with no policy
+ // reports {} as on main.
+ r.Account, r.App = "", ""
+ }
e.mu.Lock()
defer e.mu.Unlock()
if e.reports == nil {
diff --git a/internal/instancectl/egress_test.go b/internal/instancectl/egress_test.go
index c070230c8..47b1005a4 100644
--- a/internal/instancectl/egress_test.go
+++ b/internal/instancectl/egress_test.go
@@ -678,3 +678,40 @@ func TestEgressRoutesServedWithClaimsOn(t *testing.T) {
func nudgeCalls(unit string) []string {
return []string{"show -p IPAddressAllow --value " + unit, "set-property --runtime " + unit + " IPAddressAllow="}
}
+
+// TestEgressReportCarriesThePolicysTenant (final review F3): the report
+// names the tenant of the row its policy was read from, the cached one's
+// when the source cannot be read, and none when no row was ever read.
+func TestEgressReportCarriesThePolicysTenant(t *testing.T) {
+ ctl := newEgressCtl()
+ var p EgressPolicy
+ var readErr error
+ e := newEgressAsserter(ctl, func(context.Context, string) (EgressPolicy, error) { return p, readErr })
+
+ readErr = errors.New("registry: locked")
+ if rep := mustAssert(t, e, egressHost); rep.Account != "" || rep.App != "" {
+ t.Fatalf("no policy ever read: report %+v names a tenant", rep)
+ }
+ p, readErr = EgressPolicy{Allow: []string{"10.0.5.20"}, Account: "abc", App: "shop"}, nil
+ if rep := mustAssert(t, e, egressHost); rep.Account != "abc" || rep.App != "shop" {
+ t.Fatalf("report %+v, want tenant abc/shop", rep)
+ }
+ readErr = errors.New("registry: locked")
+ if rep := mustAssert(t, e, egressHost); rep.Account != "abc" || rep.App != "shop" || rep.State != EgressUnreadable {
+ t.Fatalf("source unreadable: report %+v, want the cached tenant abc/shop and unreadable", rep)
+ }
+ // Nothing to say (no policy, nothing held) names no tenant: {} as on main.
+ p, readErr = EgressPolicy{Account: "abc", App: "shop"}, nil
+ if rep := mustAssert(t, e, egressHost); !reflect.DeepEqual(rep, EgressReport{}) {
+ t.Fatalf("no policy, nothing held: report %+v, want {}", rep)
+ }
+ p = EgressPolicy{Allow: []string{"10.0.5.20"}, Account: "abc", App: "shop"}
+ mustAssert(t, e, egressHost)
+ raw, err := json.Marshal(e.Reports()[egressHost])
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !strings.Contains(string(raw), `"account":"abc","app":"shop"`) {
+ t.Fatalf("GET /egress's JSON %s does not carry the tenant", raw)
+ }
+}
diff --git a/internal/status/snapshot.go b/internal/status/snapshot.go
index 4881ecb38..a52db4d09 100644
--- a/internal/status/snapshot.go
+++ b/internal/status/snapshot.go
@@ -204,6 +204,13 @@ type HostEgress struct {
Refused []string `json:"refused,omitempty"`
State string `json:"state,omitempty"`
Detail string `json:"detail,omitempty"`
+ // Account and App are the tenant this entry is about: the host's row,
+ // stamped by the agent only when root's report was asserted from a row
+ // of that same tenant, or when the entry is the agent's own word about
+ // the row (final review F3). Both "" means it could not be attributed:
+ // operator views show it, a member never sees it.
+ Account string `json:"account,omitempty"`
+ App string `json:"app,omitempty"`
}
// HostUpdates is root's last update decision for one instance, for the