@@ -298,19 +298,13 @@ impl Manager {
298298 // Discover desired instance state.
299299 let instances: Vec < Instance > = local_state. client . instances ( ) . await ?;
300300 for instance in instances {
301- // Remove known instances.
302- running_unknown. remove ( & instance. id ) ;
303-
304301 match instance. status {
305302 InstanceStatus :: Created => {
306303 // Instance has not yet been accepted, nothing to do.
307304 continue ;
308305 }
309306 InstanceStatus :: Cancelled => {
310- // Instance has been cancelled, make sure it is stopped if running.
311- if local_state. running . contains_key ( & instance. id ) {
312- local_state. pending_stop . push ( ( instance. id , true ) ) ;
313- }
307+ // Instance has been cancelled.
314308 local_state
315309 . maybe_remove
316310 . push ( ( instance. id , instance. updated_at ) ) ;
@@ -325,6 +319,9 @@ impl Manager {
325319 }
326320 }
327321
322+ // Remove known instances. Any remaining unknown instances will be stopped.
323+ running_unknown. remove ( & instance. id ) ;
324+
328325 // Check if the instance is still paid for. If not, we immediately stop it and schedule
329326 // its removal.
330327 if instance. paid_until < now {
@@ -614,13 +611,6 @@ impl Manager {
614611 . or_default ( )
615612 . node_id = Some ( local_node_id) ;
616613 }
617-
618- // Queue a job to deploy when a deployment exists.
619- if let Some ( deployment) = instance. deployment . clone ( ) {
620- local_state
621- . pending_start
622- . push ( ( instance, deployment. clone ( ) , true ) ) ;
623- }
624614 }
625615
626616 Ok ( ( ) )
@@ -824,6 +814,17 @@ impl Manager {
824814 return Ok ( ( ) ) ;
825815 }
826816
817+ // XXX: Temporarily skip instances that cannot be removed due to a claim bug.
818+ let info = self
819+ . client
820+ . queries_at_latest ( )
821+ . await ?
822+ . instance ( instance)
823+ . await ?;
824+ if info. paid_until == info. paid_from {
825+ return Ok ( ( ) ) ;
826+ }
827+
827828 self . client . remove_instance ( instance) . await ?;
828829
829830 let mut instances = self . instances . write ( ) . unwrap ( ) ;
0 commit comments