console: the member-visible instance list carries no fleet-address conflicts (#328)
That an allowed address belongs to a fleet box is fleet topology a member does not learn. The list keeps the egress read-back; the conflict marks stay in the operator views (status --layout, the policy GET behind apps show).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4 files changed,
+26
−18
apimode.go+4 −3instances_cli_test.go+4 −3internal/console/apiinstances.go+10 −9internal/console/apiinstances_test.go+8 −3
diff --git a/apimode.go b/apimode.go| index 143cec3c1..412d1a67a 100644 |
| --- a/apimode.go |
| +++ b/apimode.go |
| @@ -3365,9 +3365,10 @@ type apiInstanceRecord struct { |
| Updates *apiUpdatesJoin `json:"update_report"` |
| UpdatesSetting string `json:"updates"` |
| SettingsDefault bool `json:"settings_default"` |
| - // Egress is the instance's egress read-back from its box, with the |
| - // console's conflicts (#328). nil from an older console and for a host |
| - // no fresh box reports: the EGRESS column prints a dash. |
| + // Egress is the instance's egress read-back from its box (#328). The |
| + // console sends no conflicts on this member-visible list. nil from an |
| + // older console and for a host no fresh box reports: the EGRESS column |
| + // prints a dash. |
| Egress *apiEgress `json:"egress,omitempty"` |
| } |
diff --git a/instances_cli_test.go b/instances_cli_test.go| index 1de2ad2d6..eb03e052b 100644 |
| --- a/instances_cli_test.go |
| +++ b/instances_cli_test.go |
| @@ -135,12 +135,13 @@ func TestEgressCellTable(t *testing.T) { |
| // TestInstancesListShowsEgress: the list's EGRESS column sits right after DB |
| // and before CREATED (plan 3 puts SIZE between DB and EGRESS), and an old |
| -// console's record, which has no egress key, reads "-". |
| +// console's record, which has no egress key, reads "-". The records are the |
| +// console's shape: the member-visible list carries no conflicts. |
| func TestInstancesListShowsEgress(t *testing.T) { |
| var recs []apiInstanceRecord |
| body := `[ |
| {"host":"shop-a.example.com","channel":"stable","health":"running","db_bytes":2048, |
| - "egress":{"allowed":["10.0.5.20","fd00:5::20"],"conflicts":["fd00:5::20"]}}, |
| + "egress":{"allowed":["10.0.5.20","fd00:5::20"]}}, |
| {"host":"shop-b.example.com","channel":"stable","health":"running","egress":{"state":"expired"}}, |
| {"host":"shop-c.example.com","channel":"stable","health":"running"} |
| ]` |
| @@ -168,7 +169,7 @@ func TestInstancesListShowsEgress(t *testing.T) { |
| return "" |
| } |
| for _, c := range []struct{ host, db, egress string }{ |
| - {"shop-a.example.com", "2.0KB", "10.0.5.20,!fd00:5::20"}, |
| + {"shop-a.example.com", "2.0KB", "10.0.5.20,fd00:5::20"}, |
| {"shop-b.example.com", "-", "- !policy expired"}, |
| {"shop-c.example.com", "-", "-"}, |
| } { |
diff --git a/internal/console/apiinstances.go b/internal/console/apiinstances.go| index c01804f0b..591d3ae5a 100644 |
| --- a/internal/console/apiinstances.go |
| +++ b/internal/console/apiinstances.go |
| @@ -211,10 +211,12 @@ type instanceListRecord struct { |
| // never asked for any. |
| SettingsDefault bool `json:"settings_default"` |
| // Egress is this host's egress read-back as its box last sent it |
| - // (status.BoxMetrics.Egress, #328), joined under DBBytes' rules, with |
| - // the fleet-address report's conflicts. Absent when no fresh box |
| - // reports one, which is most hosts: a host with no allow and nothing to |
| - // say is not reported. |
| + // (status.BoxMetrics.Egress, #328), joined under DBBytes' rules. Absent |
| + // when no fresh box reports one, which is most hosts: a host with no |
| + // allow and nothing to say is not reported. It never carries Conflicts: |
| + // this list is a member's, and that an address belongs to a fleet box |
| + // is fleet topology a member does not learn. The operator views |
| + // (status --layout, the policy GET) carry the marks. |
| Egress *apiEgress `json:"egress,omitempty"` |
| } |
| @@ -471,10 +473,10 @@ func (j boxJoin) dbSize(host string) *int64 { |
| } |
| // egressFor is the join's egress view for host, nil when no fresh box |
| -// reported one, with conflicts (egressConflicts) marked. |
| -func (j boxJoin) egressFor(host string, conflicts map[string]string) *apiEgress { |
| +// reported one. It marks no conflicts (instanceListRecord.Egress). |
| +func (j boxJoin) egressFor(host string) *apiEgress { |
| h, ok := j.egress[host] |
| - return egressView(h, ok, conflicts) |
| + return egressView(h, ok, nil) |
| } |
| // loadBoxJoin builds boxJoin from every NON-STALE box's own |
| @@ -807,7 +809,6 @@ func (s *Server) handleAPIInstanceList(w http.ResponseWriter, r *http.Request) { |
| } |
| } |
| health := s.instanceHealth(ctx, recs) |
| - conflicts := s.egressConflicts() |
| counts := map[string]int{} |
| matched := make([]instanceListRecord, 0, len(recs)) |
| for _, rec := range recs { |
| @@ -828,7 +829,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, conflicts)}) |
| + Egress: join.egressFor(rec.Host)}) |
| } |
| 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 f10052478..82fb31d82 100644 |
| --- a/internal/console/apiinstances_test.go |
| +++ b/internal/console/apiinstances_test.go |
| @@ -2634,8 +2634,10 @@ func TestAPIInstanceListDBBytes(t *testing.T) { |
| // TestAPIInstancesJoinsEgress (#328): egress joins from a FRESH box's |
| // Metrics.Egress under db_bytes' rules: absent for a host no box reports, |
| -// and dropped for a host whose only reporting box has gone stale. Conflicts |
| -// are the held addresses the fleet-address report found on a box. |
| +// and dropped for a host whose only reporting box has gone stale. The list |
| +// is a member's, so it never carries the fleet-address report's conflicts, |
| +// even for a held address the report found on a box: that an address is a |
| +// fleet box's is fleet topology a member does not learn. |
| func TestAPIInstancesJoinsEgress(t *testing.T) { |
| t.Parallel() |
| fx, token := instanceFixture(t, "code-inst-egress") |
| @@ -2680,8 +2682,11 @@ func TestAPIInstancesJoinsEgress(t *testing.T) { |
| if err := json.Unmarshal([]byte(out), &list); err != nil { |
| t.Fatalf("list body %s: %v", out, err) |
| } |
| + if strings.Contains(out, "conflicts") || strings.Contains(out, "box-b") { |
| + t.Fatalf("a member's list names a fleet-address finding: %s", out) |
| + } |
| want := map[string]string{ |
| - "shop-a.example.com": `{"allowed":["10.0.5.20","fd00:5::20"],"conflicts":["10.0.5.20"],"state":"failing"}`, |
| + "shop-a.example.com": `{"allowed":["10.0.5.20","fd00:5::20"],"state":"failing"}`, |
| "shop-b.example.com": ``, |
| "shop-c.example.com": ``, |
| } |