carlos / platform Public

ingresshealth: a self entry with no health is unknown, not dropped

Astra fix round 1. A registration of this box with no reported health
was skipped, so one unhealthy port beside an unreported one read as
withdrawn. It is now kept as StateUnknown, which never counts as
withdrawn. Fake-client regression for exactly that mixed response.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev c36f69e58f9718f14751134d597fc1e8284f0d1d parent 180c57d
4 files changed, +47 −3
  • internal/ingresshealth/awstg/awstg.go +9 −3
  • internal/ingresshealth/awstg/awstg_test.go +34 −0
  • internal/ingresshealth/ingresshealth.go +3 −0
  • internal/ingresshealth/ingresshealth_test.go +1 −0

Intent

Human

<task-notification> <task-id>a0ed24bdf33bcf76f</task-id> <tool-use-id>toolu_01Hkf9uS4KfV69c3Pr4KeXHU</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/a373aecd-faa9-4b83-8736-ff726fb2d3af/tasks/a0ed24bdf33bcf76f.output</output-file> <status>completed</status> <summary>Agent "Implement W6 Tasks 1+2" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>Status: DONE_WITH_CONCERNS Commits: - 7329d323 lbhealth: ingress-drain condition, listed last - 180c57dd ingresshealth: target-health reader and AWS adapter for the ingress drain Tests: `internal/lbhealth`, `internal/ingresshealth` and `internal/ingresshealth/awstg` pass in full, with RED recorded for each first. `go vet` and gofmt are clean, the darwin and windows builds work, and the edge health tests pass. Concerns: 1. I put the AWS adapter in a subpackage, `internal/ingresshealth/awstg`, so the core package and the ARN validator use no AWS SDK. A test enforces that. Task 8 can call the validator from hostenv without pulling in AWS. The validator is in `internal/ingresshealth` as ruling 6 says. 2. If a read fails, the adapter returns an empty result, not the groups it read before the failure. A test caught that a partial result could look "withdrawn". 3. For Task 4: a target group that has no entry for this box reads as `absent`. That counts as neither withdrawn nor healthy, so the drain ends `unverified` at the first poll. The driver should pass ports 80 and 443. 4. `.superpowers/` is gitignored, so the report is not committed. 5. Go tests ran with the sandbox off because the default Go cache is read-only inside it. GOCACHE was left at the default. Report: /home/paulca/amadan.net/carlos/platform/.claude/worktrees/w6-build/.superpowers/sdd/2026-11-10-fixed-edge-ingress-drain/task-1-2-report.md</result> <usage><subagent_tokens>103157</subagent_tokens><tool_uses>45</tool_uses><duration_ms>425528</duration_ms></usage> </task-notification>

Attributed to this commit: 17.9 g CO₂e (2,320,582 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on w6-ingress-drain, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.

diff --git a/internal/ingresshealth/awstg/awstg.go b/internal/ingresshealth/awstg/awstg.go
index bec352867..dcc43ff71 100644
--- a/internal/ingresshealth/awstg/awstg.go
+++ b/internal/ingresshealth/awstg/awstg.go
@@ -90,10 +90,16 @@ func (r *Reader) Withdrawn(ctx context.Context, self ingresshealth.Self) (ingres
}
g := ingresshealth.Group{TargetGroup: arn}
for _, d := range out.TargetHealthDescriptions {
- if d.Target == nil || d.TargetHealth == nil {
+ if d.Target == nil {
continue
}
- state := ingresshealth.State(d.TargetHealth.State)
+ // A registration with no reported health is unknown, not
+ // skipped: dropping one of this box's ports would let the
+ // others alone read as withdrawn.
+ state, reason := ingresshealth.StateUnknown, ""
+ if d.TargetHealth != nil && d.TargetHealth.State != "" {
+ state, reason = ingresshealth.State(d.TargetHealth.State), string(d.TargetHealth.Reason)
+ }
if aws.ToString(d.Target.Id) != self.InstanceID {
if state == ingresshealth.StateHealthy {
g.OtherHealthy++
@@ -106,7 +112,7 @@ func (r *Reader) Withdrawn(ctx context.Context, self ingresshealth.Self) (ingres
// neither this box's ingress nor a peer.
continue
}
- g.Self = append(g.Self, ingresshealth.Entry{Port: port, State: state, Reason: string(d.TargetHealth.Reason)})
+ g.Self = append(g.Self, ingresshealth.Entry{Port: port, State: state, Reason: reason})
}
v.Groups = append(v.Groups, g)
}
diff --git a/internal/ingresshealth/awstg/awstg_test.go b/internal/ingresshealth/awstg/awstg_test.go
index 92a009b66..df54f93e9 100644
--- a/internal/ingresshealth/awstg/awstg_test.go
+++ b/internal/ingresshealth/awstg/awstg_test.go
@@ -246,3 +246,37 @@ func TestRetention(t *testing.T) {
// The adapter satisfies the core's interface.
var _ ingresshealth.Reader = (*Reader)(nil)
+
+// A self registration with no health data is unknown, never dropped: one
+// port unhealthy and the other unreported must not read as withdrawn.
+func TestWithdrawnSelfWithMissingHealthIsUnknown(t *testing.T) {
+ for name, th := range map[string]*types.TargetHealth{
+ "nil health": nil,
+ "empty state": {},
+ } {
+ t.Run(name, func(t *testing.T) {
+ f := &fakeAPI{health: map[string][]types.TargetHealthDescription{
+ tg80: {
+ target(me, 80, types.TargetHealthStateEnumUnhealthy),
+ {Target: &types.TargetDescription{Id: aws.String(me), Port: aws.Int32(443)}, TargetHealth: th},
+ target(peer, 80, types.TargetHealthStateEnumHealthy),
+ },
+ }}
+ v, err := New(f, []string{tg80}).Withdrawn(context.Background(), self)
+ if err != nil {
+ t.Fatal(err)
+ }
+ g := v.Groups[0]
+ want := []ingresshealth.Entry{{Port: 80, State: ingresshealth.StateUnhealthy}, {Port: 443, State: ingresshealth.StateUnknown}}
+ if !reflect.DeepEqual(g.Self, want) {
+ t.Fatalf("self %+v", g.Self)
+ }
+ if v.Withdrawn() || g.State() != ingresshealth.StateUnknown {
+ t.Fatalf("withdrawn %v state %q", v.Withdrawn(), g.State())
+ }
+ if g.OtherHealthy != 1 {
+ t.Fatalf("other healthy %d", g.OtherHealthy)
+ }
+ })
+ }
+}
diff --git a/internal/ingresshealth/ingresshealth.go b/internal/ingresshealth/ingresshealth.go
index 89a54d3e8..b0a2338c7 100644
--- a/internal/ingresshealth/ingresshealth.go
+++ b/internal/ingresshealth/ingresshealth.go
@@ -34,6 +34,9 @@ const (
// StateAbsent is this package's own: the target group listed no entry
// for this box at all.
StateAbsent State = "absent"
+ // StateUnknown is this package's own: the target group listed this
+ // box but reported no health for it. Never withdrawn.
+ StateUnknown State = "unknown"
)
// Withdrawn reports whether s means the load balancer sends the target no
diff --git a/internal/ingresshealth/ingresshealth_test.go b/internal/ingresshealth/ingresshealth_test.go
index 8753d36c3..8db745493 100644
--- a/internal/ingresshealth/ingresshealth_test.go
+++ b/internal/ingresshealth/ingresshealth_test.go
@@ -31,6 +31,7 @@ func TestStateWithdrawn(t *testing.T) {
StateUnused: false,
StateUnavailable: false,
StateAbsent: false,
+ StateUnknown: false,
State("future.state"): false,
State(""): false,
} {