File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed
lib/runtime/src/component Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -146,26 +146,32 @@ impl Client {
146146 let instances = self . instances ( ) ;
147147 let mut inhibited = self . instance_inhibited . lock ( ) . await ;
148148
149- instances
149+ // 1. Remove inhibited instances that are no longer in `self.instances()`
150+ // 2. Remove inhibited instances that have expired
151+ // 3. Only return instances that are not inhibited after removals
152+ let mut new_inhibited = HashMap :: < i64 , u64 > :: new ( ) ;
153+ let filtered = instances
150154 . into_iter ( )
151155 . filter_map ( |instance| {
152156 let id = instance. id ( ) ;
153157 if let Some ( & timestamp) = inhibited. get ( & id) {
154- // If the inhibition is stale, remove it and include the instance
155158 if now. saturating_sub ( timestamp) > ETCD_LEASE_TTL {
156159 tracing:: debug!( "instance {id} stale inhibition" ) ;
157- inhibited. remove ( & id) ;
158160 Some ( instance)
159161 } else {
160162 tracing:: debug!( "instance {id} is inhibited" ) ;
163+ new_inhibited. insert ( id, timestamp) ;
161164 None
162165 }
163166 } else {
164167 tracing:: debug!( "instance {id} not inhibited" ) ;
165168 Some ( instance)
166169 }
167170 } )
168- . collect ( )
171+ . collect ( ) ;
172+
173+ * inhibited = new_inhibited;
174+ filtered
169175 }
170176
171177 /// Mark an instance as down/unavailable
You can’t perform that action at this time.
0 commit comments