Repository navigation
fix(dns): surface DNS registration failures instead of swallowing them (#435, #434) - #436
Merged
Merged
Conversation
#435, #434) Post-#173 AuthType: AWS_IAM cutover, a DNS Function URL rejects a bad/absent SigV4 signature with a 403, but the failure was invisible: - pkg/dns/client.go parsed the 403 body ({"Message":"Forbidden"}) as a normal DNSUpdateResponse → empty `DNS API error:`. Now it checks the HTTP status and surfaces the code + body snippet. - pkg/agent: spored records the outcome as spawn:dns-status / spawn:dns-error instance tags (best-effort, throttle/deny-tolerant), not just an on-instance journal line. - cmd/status: `spawn status` shows a clear warning when registration failed, so the "FQDN never resolves" symptom is diagnosable from the launch account. Tests: 403-not-swallowed (httptest) + dnsStatusNotice table. Also #434: corrected the stale base36 example in pkg/dns/encoding.go and the DNS-updater Lambda comment (123456789012 -> 1kpqzg2c, ≤8 chars; code was already correct). Note: the root cause of the live 403 (why a freshly-installed, correctly signing spored is rejected by the AWS_IAM Function URL) is still open — the Lambda's resource policy and Function URL AuthType are correct (verified read-only), so it's signature/credential-level; this PR makes that failure visible rather than silent. See #435 for the ongoing root-cause investigation.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Investigation (see #435) proved every static element correct — resource policy, dev role's cross-account InvokeFunctionUrl grant, region, and the SigV4 signing mechanism (a signed probe from BOTH the infra and dev accounts reaches the Lambda; only UNSIGNED requests get the 403 the reporter saw). That points to spored signing with empty/anonymous creds at runtime (IMDS not reachable yet), which SignHTTP does NOT error on — it produces a signature the AWS_IAM Function URL rejects with a silent 403. Now signRequest fails closed with a clear error when the resolved credential is empty, rather than emitting an unsigned-effectively request. Test: TestCallAPI_EmptyCredsFailClosed (no network call, actionable error).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses #435 (DNS registration silently broken post-AWS_IAM cutover) and #434 (stale base36 doc example).
#435 — the failure was invisible
After the #173
AuthType: AWS_IAMcutover, spored's DNS registration is rejected with a403at the Function URL auth layer (0 Lambda invocations). Three things hid it:pkg/dns/client.goswallowed non-2xx. It never checkedresp.StatusCode— it parsed the403body ({"Message":"Forbidden"}) straight into aDNSUpdateResponse, which unmarshals to all-empty (Success=false, Error=""), producing a uselessDNS API error:(empty). Now it checks the status and surfacesHTTP 403: <body snippet>.Warning: Failed to register DNS. spored now recordsspawn:dns-status(registered/failed) andspawn:dns-erroras instance tags (best-effort, throttle/deny-tolerant, mirroring the existingspawn:ready-statuspattern).spawn statussaid nothing. It now prints a clear warning whenspawn:dns-status=failed, naming the cause — so "the FQDN never resolves" is diagnosable from the launch account.Tests:
TestCallAPI_ForbiddenNotSwallowed(httptest 403) andTestDNSStatusNotice(table).Root cause status (still open)
This PR makes the failure visible; it does not yet fix the underlying 403. I verified read-only that the infra side is correct — the Function URL is
AuthType: AWS_IAMand the Lambda's resource policy (FunctionURLAllowIAMAccess,Principal:*,FunctionUrlAuthType: AWS_IAMcondition) does allow cross-account IAM callers, and the dev instance role grantslambda:InvokeFunctionUrl. So it's a signature/credential-level rejection, not a missing policy. The signing code (signRequest, SigV4lambdaservice) also has passing unit tests. Continuing to root-cause on #435.#434 — stale base36 example (doc-only)
123456789012encodes to1kpqzg2c(≤8 chars), not the1s69p4h(7 chars) in thepkg/dns/encoding.godoc comment. Verified with Go'sbig.Int.Text(36); the code was always correct and the sibling Lambda already had the right value. Fixed the comment in both files (incl. the misleading "(7 chars)").Notes
lambda/dns-updateris a separate Go module; both build clean.Pre-existing unrelated failureCorrection:TestCatalogValidTestCatalogValiddoes not fail on cleanmain/CI. It only fails locally when a developer has a private-image overlay in~/.spawn/catalog.yaml(the validator wrongly applies the public-only gate to the overlay-merged list). Filed as libs#28. Not related to this PR and does not affect its CI.