@@ -579,7 +579,8 @@ impl InstanceRunner {
579
579
"Instance failed to stop within the grace period, \
580
580
terminating it violently!",
581
581
) ;
582
- self . terminate( false ) . await ;
582
+ let mark_failed = false ;
583
+ self . terminate( mark_failed) . await ;
583
584
}
584
585
585
586
// Requests to terminate the instance take priority over any
@@ -697,6 +698,7 @@ impl InstanceRunner {
697
698
698
699
}
699
700
}
701
+
700
702
self . publish_state_to_nexus ( ) . await ;
701
703
702
704
// Okay, now that we've terminated the instance, drain any outstanding
@@ -3101,6 +3103,7 @@ mod tests {
3101
3103
3102
3104
let instance_id = InstanceUuid :: new_v4 ( ) ;
3103
3105
let propolis_id = PropolisUuid :: from_untyped_uuid ( PROPOLIS_ID ) ;
3106
+ let zone_name = propolis_zone_name ( & propolis_id) ;
3104
3107
let InstanceInitialState {
3105
3108
hardware,
3106
3109
vmm_runtime,
@@ -3180,7 +3183,26 @@ mod tests {
3180
3183
. expect ( "timed out waiting for VmmState::Stopping in FakeNexus" )
3181
3184
. expect ( "failed to receive FakeNexus' InstanceState" ) ;
3182
3185
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 ( ) ;
3184
3206
3185
3207
// The timeout should now fire and sled-agent will murder propolis,
3186
3208
// allowing the zone to be destroyed.
@@ -3189,7 +3211,7 @@ mod tests {
3189
3211
TIMEOUT_DURATION ,
3190
3212
state_rx. wait_for ( |maybe_state| match maybe_state {
3191
3213
ReceivedInstanceState :: InstancePut ( sled_inst_state) => {
3192
- sled_inst_state. vmm_state . state == VmmState :: Stopped
3214
+ sled_inst_state. vmm_state . state == VmmState :: Destroyed
3193
3215
}
3194
3216
_ => false ,
3195
3217
} ) ,
0 commit comments