diff --git a/nexus/src/app/instance.rs b/nexus/src/app/instance.rs index 359b333dbb2..8755a797808 100644 --- a/nexus/src/app/instance.rs +++ b/nexus/src/app/instance.rs @@ -950,9 +950,14 @@ impl super::Nexus { }, ) .await - .map(|res| res.into_inner().updated_runtime.map(Into::into)) + .map(|res| res.into_inner()) + .map(|res| { + ( + res.updated_runtime.map(Into::into), + res.expect_callback_in_seconds, + ) + }) .map_err(|e| SledAgentInstancePutError(e)); - // If the operation succeeded, write the instance state back, // returning any subsequent errors that occurred during that // write. @@ -965,14 +970,8 @@ impl super::Nexus { // (We later asynchronously receive a cpapi call that invokes // write_returned_instance_state with the outcome.) match instance_put_result { - Ok(state) => { - if state.is_none() - && matches!( - requested, - InstanceStateChangeRequest::Run - | InstanceStateChangeRequest::Migrate(..) - ) - { + Ok((state, callback_timeout)) => { + if let Some(timeout_secs) = callback_timeout { // TODO: This is fragile -- suppose the nexus with // this task crashes *and* the instance creation // happens to also hang. The new nexus won't know @@ -991,8 +990,10 @@ impl super::Nexus { .log .new(o!("component" => "Instance timeout")); tokio::spawn(async move { - tokio::time::sleep(Duration::from_secs(120)) - .await; + tokio::time::sleep(Duration::from_secs_f64( + timeout_secs, + )) + .await; if let Some(db_datastore) = db_datastore_weak.upgrade() {