@@ -51,24 +51,9 @@ impl LatestHandshakesCache {
5151 self . cell . set ( timestamps) ;
5252 }
5353
54- /// The cached snapshot, never a freshly produced one.
55- ///
56- /// The routing path reaches this from `select_top_n_hosts` once per
57- /// proxied connection, holding the `ProxyState` mutex every tenant's
58- /// traffic takes. Producing a value here means forking `wg show` under
59- /// that lock -- and the cell only ever fills on success, so a host where
60- /// `wg show` cannot work (wrong `core.wg.interface`, no WireGuard module,
61- /// a container without `CAP_NET_ADMIN`) would fork once per inbound
62- /// connection, for as long as the traffic lasts. The producer runs in
63- /// [`Self::refresh`] and in the periodic task instead, both off the
64- /// routing path and on the blocking pool.
65- ///
66- /// Serving an expired snapshot rather than nothing is deliberate: every
67- /// consumer compares handshake *age* against its own threshold, so a stale
68- /// snapshot ages the whole fleet uniformly, while an empty map reads as
69- /// "no instance has ever handshaked" and would drain routing on the first
70- /// refresh that fails. Empty is only what a node that has never had a
71- /// snapshot actually knows.
54+ /// The cached snapshot, stale if need be; never runs `wg show`. Callers
55+ /// hold the routing lock, and a host where `wg show` always fails would
56+ /// otherwise fork once per connection.
7257 pub ( crate ) fn latest ( & self , stale_timeout : Option < Duration > ) -> Result < HandshakesWithAge > {
7358 let timestamps = match self . cell . get_allow_stale ( ) {
7459 Ok ( snapshot) => snapshot. into_value ( ) ,
@@ -146,14 +131,6 @@ fn add_elapsed_time(
146131mod tests {
147132 use super :: * ;
148133
149- /// A cold cache must not fork a process on the routing path.
150- ///
151- /// `latest` is reached from `select_top_n_hosts` while `ProxyState`'s mutex
152- /// is held, once per proxied connection. A host where `wg show` can never
153- /// succeed -- a misconfigured `core.wg.interface`, no WireGuard module, a
154- /// container without `CAP_NET_ADMIN` -- never fills the cell, so a `latest`
155- /// that produces its own value forks once per inbound connection while
156- /// holding the lock every tenant's traffic takes.
157134 #[ test]
158135 fn a_cold_cache_does_not_shell_out_on_the_routing_path ( ) {
159136 const CONNECTIONS : usize = 500 ;
@@ -181,23 +158,6 @@ mod tests {
181158 ) ;
182159 }
183160
184- /// An expired snapshot still routes.
185- ///
186- /// Consumers threshold on handshake *age*, so serving a stale map ages the
187- /// whole fleet uniformly. Returning nothing instead would read as "no
188- /// instance has ever handshaked" and drain routing on the first refresh
189- /// that fails.
190- #[ test]
191- fn an_expired_snapshot_is_still_served ( ) {
192- let cache = LatestHandshakesCache :: new ( "dstack-no-such-iface0" . to_string ( ) , Duration :: ZERO ) ;
193- cache. set_for_test ( BTreeMap :: from ( [ ( "pubkey-a" . to_string ( ) , 1730190589 ) ] ) ) ;
194-
195- assert ! ( cache
196- . latest( None )
197- . expect( "an expired snapshot still answers" )
198- . contains_key( "pubkey-a" ) ) ;
199- }
200-
201161 #[ test]
202162 fn parses_latest_handshake_timestamps ( ) {
203163 let handshakes = parse_latest_handshake_timestamps (
0 commit comments