summaryrefslogtreecommitdiffhomepage
path: root/appc
diff options
context:
space:
mode:
authorFran Bull <fran@tailscale.com>2024-04-12 13:34:14 -0700
committerfranbull <fran@tailscale.com>2024-04-29 11:40:04 -0700
commitfea2e73bc15680c867e2e3ab5e65e8df059efa4b (patch)
tree2b38d9075cbf97270487a43cf631b8aef403df67 /appc
parent1bd1b387b298a09ae49d7084e644e0f4ff0cb4c2 (diff)
downloadtailscale-fea2e73bc15680c867e2e3ab5e65e8df059efa4b.tar.xz
tailscale-fea2e73bc15680c867e2e3ab5e65e8df059efa4b.zip
appc: write discovered domains to StateStore
If the controlknob is on. This will allow us to remove discovered routes associated with a particular domain. Updates #11008 Signed-off-by: Fran Bull <fran@tailscale.com>
Diffstat (limited to 'appc')
-rw-r--r--appc/appconnector.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/appc/appconnector.go b/appc/appconnector.go
index 6d06656f9..4d0c5d00b 100644
--- a/appc/appconnector.go
+++ b/appc/appconnector.go
@@ -103,6 +103,18 @@ func (e *AppConnector) ShouldStoreRoutes() bool {
return e.storeRoutesFunc != nil
}
+// storeRoutesLocked takes the current state of the AppConnector and persists it
+func (e *AppConnector) storeRoutesLocked() error {
+ if !e.ShouldStoreRoutes() {
+ return nil
+ }
+ return e.storeRoutesFunc(&RouteInfo{
+ Control: e.controlRoutes,
+ Domains: e.domains,
+ Wildcards: e.wildcards,
+ })
+}
+
// UpdateDomainsAndRoutes starts an asynchronous update of the configuration
// given the new domains and routes.
func (e *AppConnector) UpdateDomainsAndRoutes(domains []string, routes []netip.Prefix) {
@@ -199,6 +211,9 @@ nextRoute:
}
e.controlRoutes = routes
+ if err := e.storeRoutesLocked(); err != nil {
+ e.logf("failed to store route info: %v", err)
+ }
}
// Domains returns the currently configured domain list.
@@ -409,6 +424,9 @@ func (e *AppConnector) scheduleAdvertisement(domain string, routes ...netip.Pref
e.logf("[v2] advertised route for %v: %v", domain, addr)
}
}
+ if err := e.storeRoutesLocked(); err != nil {
+ e.logf("failed to store route info: %v", err)
+ }
})
}