Commit Graph
11188 Commits
Author SHA1 Message Date
Becky Pauley b28cbc5ef0 ad protections against hot loop 2026-08-25 16:19:25 +01:00
Becky Pauley dd838129a6 v1 changes 2026-08-25 13:40:17 +01:00
Brad Fitzpatrick 5428027685 go.mod: bump github.com/go4org/hashtriemap for slight speed boost
(bumping in oss mostly to get it into corp, and we require them to be in sync
for now. But we do use this in derpserver too.)

Updates tailscale/corp#46884

Change-Id: If01e3e91787e9ec4331eb9c997292239c6b379f1
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-08-23 22:37:00 -07:00
Paul Scott ed7d521cae go.mod: upgrade go4.org/netipx (#20967)
Bring in perf improvements from go4org/netipx#22

Diff: https://github.com/go4org/netipx/compare/fdeea329fbba...3075585bcbeb

Updates tailscale/corp#46884

Signed-off-by: Paul Scott <[email protected]>
2026-08-23 18:26:21 +01:00
Brad Fitzpatrick de9ec7ee25 go.mod: bump x/net for http2-in-std fix for Go 1.27
There's a deadlock in x/net/http2 with Go 1.27 that's
fixed with v0.58. This is prep for switching to Go 1.27.

Updates #20220

Change-Id: I8e81eafc0c2f78e1760b36e9d39ac4f6046565af
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-08-22 11:48:56 -04:00
Bonobo 86e5d3873a cmd/tailscale/cli: stop Serve port ranges at 65535
The set-config loop uses uint16 endpoints. When Last is 65535, the increment wraps to zero and file or Unix targets continue indefinitely.

Break after applying Last so every closed range terminates without changing ordinary range behavior.

Fixes #20873

Signed-off-by: Bonobo <[email protected]>
2026-08-21 14:23:06 -06:00
Adriano Sela Aviles 6d7f1212b7 go.mod,go.sum: bump wireguard-go to fix AllowedIPs mem leak
Pulls in https://github.com/tailscale/wireguard-go/pull/85 which
fixes an unbounded memory leak in mkIPInCIDRsTestFunc. It used a
package-level placeholder Peer, and AllowedIPs.Insert threads every
trie node onto that peer's trieEntries list, so each call leaked
its whole trie. SetAllowedIPs calls it on every netmap update, so
peer churn accumulated trie nodes until the client OOMed.

Fixes tailscale/corp#47010

Signed-off-by: Adriano Sela Aviles <[email protected]>
2026-08-21 12:44:21 -07:00
Brad Fitzpatrick 886d1b2e63 control/controlclient: return ctx.Err() from canceled map polls
When a map poll's context is canceled mid-read, the error that
surfaces from the response body read depends on the transport and Go
version: Go 1.26's http2 returned the context error, while Go 1.27's
returns the underlying "use of closed network connection". Normalize
the read-error paths in sendMapRequest to report ctx.Err() when the
context was canceled so callers see a stable, meaningful error
regardless of Go version.

Updates #20220

Signed-off-by: Brad Fitzpatrick <[email protected]>
Change-Id: I5898d3f452a2e61cfdf3ee015386365943c08e70
2026-08-21 14:36:59 -04:00
chaosinthecrd 1de85e1972 cmd/k8s-operator: watch ProxyGroups for HA Services with a Service handler
The service-pg-reconciler reconciles Services annotated for an ingress
ProxyGroup, but its ProxyGroup watch reused ingressProxyGroupFilter,
which is ingressesFromIngressProxyGroup. That handler lists Ingresses
and returns Ingress keys, so when a ProxyGroup became Available the
requests it produced never matched a Service and the reconciler's Get
just came back NotFound.

This fixes this by adding servicesFromIngressProxyGroup, which lists the
Services indexed for the ProxyGroup and returns their keys, matching what
the egress path already does with egressSvcsFromEgressProxyGroup.

Fixes #20944

Signed-off-by: chaosinthecrd <[email protected]>
2026-08-21 18:19:37 +01:00
chaosinthecrd 0ed6af7b72 cmd/k8s-operator: return the requeue result from HA Service reconcile
Fixes a dropped assignment of `res` in HA service reconciler necessary
for requeuing.

Fixes #20946
Signed-off-by: chaosinthecrd <[email protected]>
2026-08-21 16:46:12 +01:00
Adrian Dewhurst 0fd2f14deb feature/conn25: enforce policy during TransitIP allocation
Only allow TransitIPs to be allocated when the client has permission to
access the requested app.

Updates tailscale/corp#40076

Change-Id: Ib4b37afa25ffbdd220ba2c0fd9cfec8d5df5311f
Signed-off-by: Adrian Dewhurst <[email protected]>
2026-08-20 21:50:49 -04:00
yaruk-byte 2ee33782e7 cmd/testwrapper: name the flaky tests in the Windows integration panel (#20932)
Also reports when shard results are missing, unreadable, duplicated, or
empty, so the pass count and percentage can't overstate what actually ran.

Updates #20931

Signed-off-by: Yaruk Asghar <[email protected]>
2026-08-20 15:44:55 -07:00
Brad Fitzpatrick fc9533dc10 go.toolchain.next.rev: bump 'next' to Go 1.27.0
Updates #20220

Change-Id: Ic37fd49e2d4e6198965fc549b2efac04579f99c8
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-08-20 09:01:25 -04:00
joshrzemien c2f3230c80 k8s-operator: allow annotationless resources under proxy group policy (#20907)
Guard optional annotations maps in generated CEL expressions before
looking up expose or proxy-group annotations. This lets ordinary
annotationless Services and Ingresses pass admission while preserving
deny-all and allowlist behavior for present proxy-group annotations.

RELNOTE: Kubernetes ProxyGroupPolicy now permits annotationless resources.

Fixes #20906

Change-Id: I8b9475d34c003ca6d233246c021ac656e0530fb1

Signed-off-by: joshrzemien <[email protected]>
2026-08-20 12:27:18 +01:00
yaruk-byte c87680a0bf tstest/integration: run multi-node Windows tests with userspace peers (#20764)
Updates #20711

Signed-off-by: Yaruk Asghar <[email protected]>
2026-08-19 16:32:05 -07:00
Simon Law 0e84b4a3a0 tailcfg: replace int with DERPRegionID for additional type safety (#20646)
Historically, when DERP regions were switched away from strings to
numeric identifiers in PR #14641, tailcfg.Node.HomeDERP was declared
as an int instead of its own type.

This PR declares a new tailcfg.DERPRegionID type, represented by an
int64, and converts the following fields to use this type:

- netcheck.Report.PreferredDERP
- netcheck.Report.RegionLatency
- netcheck.Report.RegionV4Latency
- netcheck.Report.RegionV6Latency
- tailcfg.DERPHomeParams.RegionScore
- tailcfg.DERPMap.Regions
- tailcfg.DERPNode.RegionID
- tailcfg.DERPRegion.RegionID
- tailcfg.NetInfo.PreferredDERP
- tailcfg.Node.HomeDERP
- tailcfg.PeerChange.DERPRegion
- tailcfg.PingResponse.DERPRegionID

Note that the original field was an int, while the new field is backed
by an int64. This change makes DERPRegionID the same size on both
32-bit and 64-bit architectures.

Fixes: #20165

Change-Id: Ic6f795a6d791dd16f756f246d5a02085443e212f

Signed-off-by: Simon Law <[email protected]>
2026-08-19 16:25:50 -07:00
yaruk-byte bf18243bf7 cmd/testwrapper: add Windows integration results panel + Slack notification (#20811)
Updates #20464

Signed-off-by: Yaruk Asghar <[email protected]>
2026-08-19 12:55:12 -07:00
M. J. Fromberger f3552c29c0 ipn/ipnlocal: fix cache update for peers deleted by netmap deltas (#20851)
After a netmap delta is applied, we scan the mutations for affected peers and
update the cache (if enabled) for those peers. For removals in particular, we
were relying on the node backend to resolve node IDs (provided by the delta
mutation) to stable IDs.

Prior to 65fd320a this happened to work because the node backend would hold on
to all the peers mentioned by the previous full netmap, even after applying
deltas. But that was essentially accidental, and once we fixed it not to do
that, these lookups no longer worked. We need the stable ID, since that is how
the cache is keyed, and now that they're no longer pinned, we were not properly
evicting removed peers from the cache.

To fix this, capture removed peer stable IDs while applying mutations to the
node backend, instead of trying to look them up afterward.

Updates #20796

Change-Id: I14ded78eaf9657645f0869a52460fd3cd86edba6
Signed-off-by: M. J. Fromberger <[email protected]>
2026-08-19 10:31:38 -07:00
Mike Jensen 90ed0bcf4b wgengine/netstack: block 4via6 forwards to host-scoped targets (#20866)
The packet filter only sees a via address's outer ULA, so netstack unconditionally dialed whatever IPv4 was embedded in it.

This change refuses TCP, UDP, and ping relays to host-scoped destinations after UnmapVia.

Credit to the Anthropic infrastructure security team for finding and reporting.

Fixes https://github.com/tailscale/corp/issues/46646

Change-Id: I93d8e27a2eddbce7eb3f8c5fa4677f8de3a8ed9e

Signed-off-by: Mike Jensen <[email protected]>
2026-08-19 09:16:08 -06:00
Brad FitzpatrickandAdriano Sela Aviles f29f127ace control/controlhttp/controlhttpserver: detach websocket conns from request context
The websocket upgrade path bound the returned conn's reads and writes
to the context passed to AcceptHTTP via wsconn.NetConn. That context is
typically an http.Request context, which net/http cancels once the
calling handler returns, so a caller that served the accepted conn
beyond its handler's lifetime had the conn killed out from under it.
The hijack-based HTTP/1 upgrade path has no such binding.

Make the two paths consistent: ctx now only bounds the handshake (its
deadline, if any, is applied to the conn by controlbase.Server) and the
returned conn's lifetime is the caller's responsibility. Document that
contract on AcceptHTTP and add a regression test that uses a
websocket-accepted conn after the accepting handler has returned.

Updates tailscale/corp#46806
Updates tailscale/corp#29053

Change-Id: I4fc4ea5cddc2c6174fdf21f8d832f2e0984a7533
Co-authored-by: Adriano Sela Aviles <[email protected]>
Signed-off-by: Brad Fitzpatrick <[email protected]>
2026-08-19 10:58:47 -04:00
Tom Proctor f9417e3687 go.mod: bump ebpf, go-git, go-billy and aws-sdk-go-v2 for govulncheck (#20920)
Bump five dependencies to resolve the following advisories;
GO-2026-6238, GO-2026-5764, GO-2026-5597, GO-2026-5490, GO-2026-5496,
GO-2026-5105.

Updates tailscale/corp#9497

Signed-off-by: Tom Proctor <[email protected]>
2026-08-19 15:53:13 +01:00
Will HannahandWill Hannah e1ffeeffba client,feature/favorites: add locally-pinned favorites (#20563)
Let clients pin favorite devices, exit nodes, and services so GUIs can
surface & change them. Pins are stored per login profile in the new
favorites feature module, keyed per category; devices and exit nodes by
StableNodeID, services by ServiceName.

The item types live in a leaf package feature/favorites/pintype,
keeping them out of the core ipn hierarchy. Each category has
its own type (pintype.Device, pintype.ExitNode, pintype.Service).

Exposed over LocalAPI at GET/POST /localapi/v0/pins, where POST replaces
only the categories named in the request so a client can update one
category without clobbering the others. Pins are local to the device and
are not synced across a user's devices.

updates tailscale/corp#44836

Signed-off-by: Will Hannah <[email protected]>
Co-authored-by: Will Hannah <[email protected]>
2026-08-19 09:52:56 -04:00
Alex Chan 468241a13f envknob: add SetenvForTest helper for safe environment variable handling
Our tests are inconsistent in how they set environment variables and cleanup.
Missing cleanup logic can leak environment variable state across tests and
change the behaviour of subsequent tests.

This recently caused flakes in feature/acme, where `TestGetCertPEMWithValidity`
leaked `TS_CERT_SHARE_MODE` and `TestAsyncRenewalDedup` to fail inconsistently.

To fix the immediate flake and prevent future leaks, introduce a `SetenvForTest`
helper that handles setting and cleaning up environment variables in tests.

Fixes #20902

Change-Id: I9f8ef45ec875d66034cfd0054311bd69b67e2243
Signed-off-by: Alex Chan <[email protected]>
2026-08-19 12:22:26 +01:00
chaosinthecrd 86c178754d cmd/containerboot: make the boot map-response timeout configurable
containerboot waits up to 60s for the initial map response before
failing. Slow map responses (>60s seen in production) leaves
containerboot to timeout and fail.

Add a TS_BOOT_TIMEOUT env var to override the default. Falls back to
60s when unset.

Fixes #20912

Signed-off-by: chaosinthecrd <[email protected]>
2026-08-19 12:21:52 +01:00
Amal Bansode 0f02428a20 net/traffic: port some rendezvous hasher testcases (#20899)
Port some tiny testcases that apply to our corp impl of the rdv hasher
to OSS as well. This is in preparation for cutting over to the OSS
impl exclusively.

Updates tailscale/corp#46471

Signed-off-by: Amal Bansode <[email protected]>
2026-08-18 09:56:45 -07:00
kari-ts d3d14a8831 ipn/{desktop,ipnlocal}: register per-user policy stores on session lifecycle (#20293)
This registers per-user RSOP policy stores when a user logs into a Windows session and ensures that per-user poicy settings are delivered to clients via IPN bus.

The store lifecycle is tied to Windows session lifetime via desktopSessionExt's SessionInitCallback, which handles unattended mode (per-user policies stay enforced after gui disconnection) and multi-user (refcounted across sessions for the same user).

Updates tailscale/corp#42259

Signed-off-by: kari-ts <[email protected]>
2026-08-17 19:59:42 -07:00
Fran Bull 6e0912f979 feature/conn25: expire connector state
The connector struct holds a map of peer+transitIP -> destinationIP that
it uses for routing traffic. The client registers new entries in the map
over the peer API.

Stop the transitIPs map from growing indefinitely by expiring entries
after 1 hour.

Updates tailscale/corp#38261

Signed-off-by: Fran Bull <[email protected]>
2026-08-17 10:54:10 -07:00
Tom Proctor 902f5c414a cmd/cigocacher: make token optional for --stats (#20896)
In cases where cigocacher is using a proxy that handles the auth, it's
possible to fetch stats without knowing our own access token. Don't fail
early if the access token isn't passed. If there's no proxy, it will
fail with the error from the gocached server.

Updates tailscale/corp#45427

Signed-off-by: Tom Proctor <[email protected]>
2026-08-17 14:23:17 +01:00
BeckyPauley 083e8ddfc2 cmd/k8s-operator/e2e: add tests to cover DNSConfig (#20861)
Deploy k8s nameserver during e2e test setup, and point the cluster resolver
(CoreDNS or kube-dns) to it so tests can resolve MagicDNS names inside the
cluster.

Add a test to verify singleton L7 Ingress is reachable from inside the
cluster using its MagicDNS Name.

Update existing egress tests to use a dedicated tailnet target per test (to
avoid conflicts). Egress tests now also verify that an egress target is
reachable from within the cluster using both its Service and MagicDNS name.

To successfully curl using the target's MagicDNS name, publish test CAs as a
ConfigMap to the cluster, and mount these for each curl pod.

Fixes tailscale/corp#38027

Signed-off-by: Becky Pauley <[email protected]>
2026-08-17 14:22:14 +01:00
yaruk-byte cfe32b8be6 tstest/integration: run Windows integration tests against the service by default (#20565)
Updates #20464

Signed-off-by: Yaruk Asghar <[email protected]>
2026-08-14 22:49:30 -07:00
Bonobo 8052bb2c53 cmd/tailscale/cli: handle kubeconfig stat errors
kubeconfigPath dereferences FileInfo for non-ENOENT stat errors even though os.Stat returns nil FileInfo. Preserve the failing list entry so checkKubeconfigWritable reports the existing access error instead of panicking.

Updates #11604

Signed-off-by: Bonobo <[email protected]>
2026-08-14 17:39:15 -07:00
License Updater 290aad71cc licenses: update license notices
Signed-off-by: License Updater <[email protected]>
2026-08-14 16:52:55 -07:00
James Tucker 0d66cde14f tstest/membudget: add live-heap budget regression tests
Static size checks (iossize) catch binary dirty-page growth but nothing
covered runtime heap cost, which is what actually consumes the iOS
Network Extension's 50 MiB jetsam budget. Bring up a tsnet backend
(with the full condregister feature set, matching shipping clients)
against an in-process testcontrol server and assert live post-GC heap
budgets for (a) backend startup with zero peers and (b) marginal cost
per netmap peer.

The startup test measures 1.3 MiB today and fails loudly on the
conn25 flow-table pre-allocation regression (17 MiB) that jetsam-killed
the iOS extension on large tailnets.

Budgets are deliberately generous (6-12x current measurements) to stay
flake-free while still catching the multi-MiB regressions that matter
for mobile.

A new debugknob enables us to constrain the GSO/GRO batch size to 1 for
these tests so as to avoid the memory allocation associated with those
buffers, which are a known issue with their own work stream.

Updates tailscale/corp#46408
Updates tailscale/corp#18514

Signed-off-by: James Tucker <[email protected]>
2026-08-14 16:45:04 -07:00
Alex Chan 2d98e75249 feature/acme: only allow one async renewal at a time
Currently we serialise ACME account setup and ACME issuances for domains
which don't yet have a valid certificate, but not for async renewals of
still-valid certificates.

This patch adds a check that we only have one async renewal for a domain
in-flight at a time, and a test that ensures we de-dupe these renewals.

Updates tailscale/corp#46420

Change-Id: Ibbaa537cd28b8adf238b5c9396403e845f95b7e7
Signed-off-by: Alex Chan <[email protected]>
2026-08-14 20:15:30 +01:00
Claus Lensbøl ffaa5a361f hostinfo: improve detection of linux desktops (#20848)
Our desktop detection was using "wayland-1" as a search string for
detecting wayland desktops, but many desktops use other indexes for the
session. Additionally we did not detect mir or gamescope.

Add a new detection method that leans on systemd-logind (if available)
and fall back to using the existing method of looking for open unix
sockets, but add search strings and tail the index off of the wayland
session detection.

Fixes #20847

Signed-off-by: Claus Lensbøl <[email protected]>
2026-08-14 15:12:45 -04:00
Adrian Dewhurst 5a1066f494 tailcfg/peercap, types/appctype: prepare for conn25 grants
This change contains the protocol changes needed to support
describing authorization for conn25 apps. As a temporary transition
measure during development, app configurations can disable authorization
enforcement.

Updates tailscale/corp#40076

Change-Id: I3183c10374aacb0048f6632c384f71f758c20f2f
Signed-off-by: Adrian Dewhurst <[email protected]>
2026-08-14 13:48:46 -04:00
Michael Ben-Ami 0953fd9a97 conn25: return early in handleConnectorTransitIP if conn25 not configured
We were checking and writing an HTTP error, but not returning.

Updates tailscale/corp#39033

Signed-off-by: Michael Ben-Ami <[email protected]>
2026-08-14 07:31:34 -04:00
Patrick O'Doherty 4782f36506 go.mod: update to Go 1.26.6 (#20857) 2026-08-13 21:11:13 -07:00
Jordan Whited ab0489912f go.mod,wgengine/wgcfg: bump wireguard-go for device.Option
Move away from mutating global, exported variables in wireguard-go. Use
device.Option's passed to device.NewDevice, instead. No functional
changes, just API cleanup in preparation of future changes.

Updates tailscale/corp#22467
Updates tailscale/corp#46396
Updates tailscale/corp#37878

Signed-off-by: Jordan Whited <[email protected]>
2026-08-13 15:05:36 -07:00
Joe Tsai 9f4fe8b5f2 util/ioqueue: new log buffer implementation (#20816)
This adds a new ring buffer implementation that aims to replace
logtail.Buffer and the on-disk implementation in filch.Filch.

There are several problems with filch.Filch:

* Filching stderr should not be done at the buffer layer.
  This makes structured representation within the buffer difficult
  as arbitrary stderr data may unexpectedly appear,
  which hinders attempts at more structured data.

* Log messages are assumed to be discreet lines rather than arbitrary bytes.
  This makes it harder to switch the structured representation (e.g., using CBOR instead).

* Data that appears asynchronously through stderr never triggers a wake-up within logtail.
  Consequently logs may never be uploaded.

* Relatedly, there is no mechanism for notifying that data has newly arrived in the buffer.

* There is no two-stage exfiltration. The TryReadLine method may or may not persist
  the fact that the data was read. It arbitrarily depends on whether we cross
  a magical file boundary in the dual-file approach.
  A failed upload followed by a restart results in dropped logs.
  A successful upload followed by a restart results in duplicated logs.

The new Buffer interface and VolatileBuffer implementation are
a step in the direction to resolving these problems.

* In the future, filching will output to a separate pipe
  that we explicitly process the data for,
  before putting it into the log buffer.
  By processing the data, we can protect against stderr garbage being inserted
  into the buffer unexpectedly breaking any structure.

* The Buffer.Peek and Buffer.DiscardUntil methods provide a way
  to exfiltrate in a two-step manner.
  When uploading, we peek at a chunk of data to upload.
  When successful, we discard the data, ensuring that the buffer knows
  not to provide that data again. The Len method can be used to suggest
  to the logging service the amount of back pressure that exists.

Updates tailscale/corp#21363

Signed-off-by: Joe Tsai <[email protected]>
2026-08-13 13:04:53 -07:00
Aaron Klotz 4bf9382c3b net/dns: only attempt registry changes on address families that are actually enabled on interface
We stop waiting to see if registry keys come available; this causes bad
interactions with the LocalBackend watchdog.

Instead we check the network interface for availability of AF_INET,
AF_INET6, and AF_NETBIOS. If no IP families are available on the
interface, we fail with an error. Otherwise we only attempt to configure
DNS for the address families that are actually enabled.

We also avoid changing any NetBIOS settings if AF_NETBIOS is disabled.

Fixes #46276

Change-Id: Ic7ae8a3dc810f4c428085f8b3ad905c6c32ae351
Signed-off-by: Aaron Klotz <[email protected]>
2026-08-13 13:13:20 -06:00
Michael Renner ea9b1a2309 tka: avoid quadratic filesystem scans
Since #17567, FS.ChildAUMs scans and decodes every active AUM file.
Authority reconstruction and compaction call it repeatedly, making
filesystem work quadratic in the number of AUMs.

Build per-FS indexes of active AUM hashes and parent-to-child
relationships in one scan. Use the indexes for graph queries while
continuing to decode returned AUM values from disk. Invalidate the
indexes after mutations, but retain them for empty purges.

A production-sized 825-AUM benchmark improves from 124 seconds to
4 seconds on macOS with Defender and from 5.9 seconds to 34 milliseconds
on Linux ext3. The checked-in benchmark exercises the 2,000-AUM maximum
linear history accepted by the traversal guardrail.

RELNOTE: Avoid Tailnet Lock startup failures with large authority histories.

Fixes #20735

Change-Id: I088136bc2e9d1b6bfdecb223c069d42400c9f63d
Signed-off-by: Michael Renner <[email protected]>
2026-08-13 11:33:45 +01:00
Amal Bansode fd07b9a2b6 net/traffic: fix rendezvous hashing (#20828)
The rendezvous hasher for traffic steering loadbalancing was flawed.
By plainly using the FNV-1a hash value, the result often reflected the
magnitude of the most significant bits in the hash seed, meaning the
hash function was not diffusive (aka missing the Avalanche Effect).

Popular wisdom seems to be that the output of FNV-1a should be mixed
with some large numbers to perturb more output bits. Borrow concepts
from other (Rust, Java) libraries by using the mix13 variant of 64-bit
finalizers by David Stafford.

Modify the fuzz test that asserts this fairness. Adjust a few
constants like client count and candidate count to more closely
reflect real-world scenarios and practical probabilities. Tighten
the bounds for distribution from 50% to +-20%.

Updates tailscale/corp#46471

Signed-off-by: Amal Bansode <[email protected]>
2026-08-12 14:13:42 -07:00
David Bond 5e7f189e04 cmd/k8s-operator: move dnsrecords and nameserver into their own packages (#19696)
This commit moves the reconcilers for both the DNS nameserver and
DNSConfig custom resource into their own packages within
`k8s-operator/reconciler`

Closes: https://github.com/tailscale/corp/issues/37088

Signed-off-by: David Bond <[email protected]>
2026-08-12 19:55:16 +01:00
M. J. Fromberger 93912bbe1d ipn/ipnlocal/netmapcache: invalidate digest caches when removing objects (#20839)
Previously, a delta update that drops a peer would not invalidate the digest
cache for that peer after deleting its cache entry. If a subsequent (later)
delta re-adds that peer with the same content, the digest cache would prevent
us from updating the persistent entry.  Add a test to exercise this, and fix
the bug.

Updates #20795

Change-Id: I4a9ef03e8787a330d6395629251ee61ca2221fdd
Signed-off-by: M. J. Fromberger <[email protected]>
2026-08-12 09:49:18 -07:00
David Bond 13a293a563 cmd/k8s-operator: ensure CRDs are always generated
This commit modifies the "generate" tool we use on the kubernetes operator
that produces helm chart and static manifest assets for CRDs.

Previously, this required always remembering to add new constants to
a `main.go` and did not have any mechanism to fail in CI if you forgot
to. Now this tool will iterate over all the CRDs and ensures that they're
in the places they're expected to be, with a test that will fail if they
are not.

This removes the requirement for remembering to add these constants
every time you have a new CRD.

Closes: #20594
Signed-off-by: David Bond <[email protected]>
Signed-off-by: chaosinthecrd <[email protected]>
2026-08-12 15:55:08 +01:00
David Bond 7f458941ae k8s-operator: make PeerRelay endpoints reachable on EKS by default (#20834)
This commit changes how PeerRelay services are exposed on AWS. A Network
Load Balancer only forwards to targets in an availability zone enabled
on it, and spec.aws.elasticIPs pins each service to a single subnet,
which enables just one zone. A replica scheduled anywhere else silently
receives nothing while still reporting PeerRelayReady with an address in
status.endpoints.

Without spec.aws we now leave the subnet unpinned, so the AWS Load
Balancer Controller spreads the load balancer over every zone it finds,
and cross-zone load balancing is on by default so any of its addresses
reach the pod. Hostname resolution is no longer gated on the
eip-allocations annotation, which had left these unpinned services in
EndpointsPending forever, and a failure to resolve now logs at debug
since it is expected while a load balancer provisions.

Such a load balancer has an address per zone, and AWS bills for each, so
every one of them is now advertised rather than only the lowest sorted.
That also lets a peer reach the relay when one zone is unreachable.
status.endpoints gains address as a second list map key so a replica can
hold an entry per address; no field changes, so existing readers of
endpoints[].address keep working. Readiness counts the replicas that
have an endpoint rather than the entries, so a replica with several
addresses cannot mask one that has none.

The pods now serve containerboot's health check endpoint and the load
balancer is pointed at it over HTTP. A peer relay listens only on UDP,
so the default TCP check against the port the load balancer forwards
could never succeed and every target sat unhealthy while relaying
perfectly well. /healthz reports 200 once the device has tailnet
addresses, which is the condition that actually matters.

The CRD docs now describe spec.aws as the exception, note that it also
needs a ProxyClass pinning pods to the zone of the subnets it names, and
drop the claim that an Elastic IP has an availability zone of its own.

Fixes: https://github.com/tailscale/tailscale/issues/20833

Signed-off-by: David Bond <[email protected]>
2026-08-12 15:31:16 +01:00
chaosinthecrd db07a34204 k8s-operator/reconciler/peerrelay: add missing tsclient import
authkey.go references tsclient.Client in getAuthKey but never imported
the package, breaking main.

Updates #20544

Signed-off-by: chaosinthecrd <[email protected]>
2026-08-12 15:24:51 +01:00
chaosinthecrd 6a6742c90e cmd/k8s-operator: attach egress readiness gate to ProxyGroup Pods
The egressPodsReconciler (added in #14792) only sets the
tailscale.com/egress-services readiness condition on egress ProxyGroup
replica Pods that declare the corresponding readiness gate. However, the
gate was never actually added to the egress Pod template, so the
reconciler always hit its early-return and the readiness condition was
never set. This commit adds said readiness gate to the egress Pod template.

Updates #14326

Signed-off-by: chaosinthecrd <[email protected]>
2026-08-12 14:58:17 +01:00
chaosinthecrd 0e93fdea5a cmd/k8s-operator,k8s-operator/reconciler: dedupe auth key reissuance
ProxyGroup, Recorder, and PeerRelay each carried a near-identical copy of
the auth key re-issuance state machine (in-flight tracking, per-parent rate
limiting, stale-device cleanup). A bug fix had to land in three places and
could silently drift.

Extract it into a shared tailscaled.Reissuer, alongside the other tailscaled
workload helpers (NewAuthKey, AuthKeyFromConfigSecret, DeviceIDFromStateSecret)
that the callers already use. It owns its own mutex, tracks in-flight reissues
per replica keyed by parent, and rate-limits re-issuance per parent; the three
reconcilers drive it via EnsureState/RemoveState/ShouldReissue. The device
deletion helper is shared too, so the reissue state machine and its tests now
live in one place.

Updates #20544

Signed-off-by: chaosinthecrd <[email protected]>
2026-08-12 14:57:28 +01:00