Repository navigation
fix(webhook): reload TLS certificates without server restart - #450
Conversation
Signed-off-by: Gaurav Chaudhary <chaudharygaurav2004@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
matthyx
left a comment
There was a problem hiding this comment.
Approve 02b27ec59311454078aa0b03249618f393423a53 targeting main (98eda6b3029729b03bb0b8c94542cc19f52f14a5). No material blockers found; independent correctness and architecture reviews agree.
The fix is needed: current main shuts down the listener before replacement during certificate rotation, creating the availability gap documented in #441. A single server with a synchronized GetCertificate cache removes that cause. Stable metadata checks, immutable published certificates, preservation of the last valid pair, and retry after failed loads are sound. Existing public interfaces and admission handling are preserved. Tests cover held connections, in-flight admission, concurrent handshakes, repeated rotation, invalid replacements, symlink replacement, startup and listen errors.
History: #440 is the merged restart-based predecessor, not a duplicate of this improvement. Its earlier incomplete-pair and watcher-race objections were addressed; this PR also removes the dropped-notification/restart path. #372 was explicitly replaced by helm-charts#843 to avoid a separate certgen image, not rejected as a runtime-reload approach. #427 concerns admission alert identity. Searches across indexed open/closed/merged PRs and issues used certificate, TLS, rotation, webhook restart, notifyChanges and server.go/webhook (100-result limits per search); no superseding implementation found within those limits. This is not an exhaustive proof of absence.
Validation: both changed files inspected, caller lifecycle traced, description/reviews/inline comments and prior decisions read. gofmt -d is clean. In a credential-free, network-isolated component harness, the five supplied certificate-cache tests pass with go test -race -count=3 -v .; cache logic was extracted with only its logging call removed. This is component validation, not full-package or end-to-end continuity execution. The baseline restart problem is established by source tracing; I did not independently run a before/after continuity reproduction. Full-package tests, build, vet and lint were not rerun locally. GitHub reports successful cross-platform build, Basic-Test, integration-build, CodeQL and other listed checks for this head. PR450 currently has no existing inline findings or submitted reviews to resolve.
Nonblocking limits: metadata-preserving in-place rewrites remain intentionally undetectable; each callback performs serialized filesystem checks and retries invalid replacements. Neither establishes a material regression for the supported Secret-file rotation path. Immediately before submission, the PR remained open, non-draft, mergeable, with head and current main unchanged.
Overview
Fixes #441.
Certificate rotation currently shuts down and restarts the webhook HTTPS server, temporarily refusing connections. This change serves certificates through a synchronized
tls.Config.GetCertificatecache while keeping the same server running.Exported interfaces, admission behavior, Helm configuration, and certificate-trust policy remain unchanged.
Signed Commits
How to Test
go test -count=1 ./admission/webhookCGO_ENABLED=1 go test -race -count=3 ./admission/webhookgo vet ./...CGO_ENABLED=0 go build ./...These checks pass locally, alongside formatting, changed-scope lint, and all three Helm fixture tests. The continuity regressions fail against the original restart implementation and pass with this change.
Full-repository race, CGO-disabled, and integration suites encounter one environment blocker:
TestRegistryCommandWatchrequires an available Docker-compatible runtime. The same failure reproduces on the unchanged baseline. Remaining watcher tests pass separately with race detection and with CGO disabled.Summary by CodeRabbit
New Features
Reliability