Skip to content

fix(adapter): warn on malformed external-dns resource label#305

Merged
golgoth31 merged 2 commits into
mainfrom
fix/log-malformed-resource-label
Jun 18, 2026
Merged

fix(adapter): warn on malformed external-dns resource label#305
golgoth31 merged 2 commits into
mainfrom
fix/log-malformed-resource-label

Conversation

@golgoth31

Copy link
Copy Markdown
Owner

Summary

Pre-existing observability debt (flagged during #291): the three sites in internal/adapter/endpoint.go parsing the external-dns resource label (kind/namespace/name) returned nil on any parse error, conflating absent (expected: no origin) with present-but-malformed (an anomaly). A malformed label silently dropped the FQDN origin — the card showed no source, with no way to tell a missing origin from a broken one.

Fix

  • parseOriginLabel (shared by originRefFromLabel v1 and originRefV2FromLabel v2): empty stays silent; a non-empty unparsable label is logged at warn (internal/log, slog/zap) with the raw value.
  • extractNamespace stays silent — it is paired with originRef* on the same endpoints, so the origin path already logs the anomaly once.
  • Parse the origin label once per endpoint (hoisted out of the per-group loop) in both EndpointStatusToGroups and EndpointStatusToGroupsV2: the label is identical across an endpoint's groups, so this avoids re-parsing and avoids emitting one warn per group.

No behavior change for valid/absent labels; only adds a warn for the malformed-present case.

Test plan

  • white-box tests: valid → ref; empty → nil, no log; malformed → nil + WARN (slog captured)
  • go test -race ./internal/adapter/..., golangci-lint clean
  • Review panel (exec-trace / silent-failure / code) — RAS; the per-group log amplification was caught and fixed (hoist)

🤖 Generated with Claude Code

golgoth31 and others added 2 commits June 18, 2026 21:46
The 3 sites parsing the external-dns "resource" label (kind/namespace/name)
returned nil on any parse error, conflating "label absent" (expected: no
origin) with "label present but malformed" (an anomaly). A malformed label
silently dropped the FQDN origin — the card showed no source and there was
no way to tell a missing origin from a broken one.

Add parseOriginLabel, shared by originRefFromLabel (v1) and
originRefV2FromLabel (v2): empty stays silent; a non-empty unparsable label
is logged at warn level (internal/log, slog/zap) with the raw value.
extractNamespace stays silent — it is paired with originRef* on the same
endpoints, so the origin path already logs the anomaly once.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…port

Review follow-ups:
- hoist originRef parsing out of the per-group loop in EndpointStatusToGroups
  and EndpointStatusToGroupsV2: the resource label is identical across an
  endpoint's groups, so this avoids re-parsing and, for a malformed label,
  avoids emitting one warn per group (now one per endpoint).
- import internal/log unaliased ("log") to match the rest of the repo.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@golgoth31 golgoth31 merged commit f618da7 into main Jun 18, 2026
2 checks passed
@golgoth31 golgoth31 deleted the fix/log-malformed-resource-label branch June 18, 2026 22:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant