@@ -579,7 +579,8 @@ impl InstanceRunner {
579579 "Instance failed to stop within the grace period, \
580580 terminating it violently!",
581581 ) ;
582- self . terminate( false ) . await ;
582+ let mark_failed = false ;
583+ self . terminate( mark_failed) . await ;
583584 }
584585
585586 // Requests to terminate the instance take priority over any
@@ -697,6 +698,7 @@ impl InstanceRunner {
697698
698699 }
699700 }
701+
700702 self . publish_state_to_nexus ( ) . await ;
701703
702704 // Okay, now that we've terminated the instance, drain any outstanding
@@ -3101,6 +3103,7 @@ mod tests {
31013103
31023104 let instance_id = InstanceUuid :: new_v4 ( ) ;
31033105 let propolis_id = PropolisUuid :: from_untyped_uuid ( PROPOLIS_ID ) ;
3106+ let zone_name = propolis_zone_name ( & propolis_id) ;
31043107 let InstanceInitialState {
31053108 hardware,
31063109 vmm_runtime,
@@ -3180,7 +3183,26 @@ mod tests {
31803183 . expect ( "timed out waiting for VmmState::Stopping in FakeNexus" )
31813184 . expect ( "failed to receive FakeNexus' InstanceState" ) ;
31823185
3183- // NOW WE STOP ADVANCING THE MOCK --- IT WILL NEVER REACH STOPPED
3186+ // NOW WE STOP ADVANCING THE MOCK PROPOLIS STATE MACHINE --- IT WILL
3187+ // NEVER REACH `Stopped`.
3188+
3189+ // Expect that the `InstanceRunner` will attempt to halt and remove the
3190+ // zone.
3191+ let halt_ctx = MockZones :: halt_and_remove_logged_context ( ) ;
3192+ halt_ctx. expect ( ) . returning ( move |_, name| {
3193+ assert_eq ! ( name, & zone_name) ;
3194+ Ok ( ( ) )
3195+ } ) ;
3196+
3197+ // Now, pause time and advance the Tokio clock past the stop grace
3198+ // period. This should casue the stop timeout to fire, without requiring
3199+ // the test to actually wait for ten minutes.
3200+ tokio:: time:: pause ( ) ;
3201+ tokio:: time:: advance (
3202+ super :: InstanceRunner :: STOP_GRACE_PERIOD + Duration :: from_secs ( 1 ) ,
3203+ )
3204+ . await ;
3205+ tokio:: time:: resume ( ) ;
31843206
31853207 // The timeout should now fire and sled-agent will murder propolis,
31863208 // allowing the zone to be destroyed.
@@ -3189,7 +3211,7 @@ mod tests {
31893211 TIMEOUT_DURATION ,
31903212 state_rx. wait_for ( |maybe_state| match maybe_state {
31913213 ReceivedInstanceState :: InstancePut ( sled_inst_state) => {
3192- sled_inst_state. vmm_state . state == VmmState :: Stopped
3214+ sled_inst_state. vmm_state . state == VmmState :: Destroyed
31933215 }
31943216 _ => false ,
31953217 } ) ,
0 commit comments