mirror of
https://github.com/tailscale/tailscale.git
synced 2026-11-21 20:22:41 +09:00
The write replica of an HA ProxyGroup (cert share "rw") doesn't keep TLS certs in memory, so that it notices a recreated, empty cert Secret and issues a new cert. As a result, it read the cert Secret from the API server on every TLS handshake, with a 30s timeout. When the API server was slow or unavailable, handshakes on that replica waited for the read, and feature/acme repeated the read under the per-domain lock. Clients with a 10s handshake timeout, such as kubectl, failed. This commit adds a small per-domain cache of the last-known-good cert and key for write replicas. The replica serves a cached cert for 30s before it reads the Secret again. When it has a cached cert, the read uses a 3s timeout, and on an error other than not found or forbidden the replica serves the cached cert and waits another 30s before the next read. A read that finds the Secret missing, forbidden or empty removes the cached cert and returns ipn.ErrStateNotExist as before, so a recreated Ingress still gets a new cert, at most 30s later. Concurrent reads of the same Secret share one GET, and a read that is in flight when a cert is written does not replace the written cert. A Secret watch remains the long-term fix. Fixes #22009 Change-Id: Id107bf0a7628a1a026f94e621173d7c5d02fb451 Signed-off-by: David Bond <davidsbond93@gmail.com>