Skip to content

Commit 686006f

Browse files
author
lif
committed
wip: missed a spot - use the timeout supplied by sled-agent
1 parent 10b8851 commit 686006f

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

nexus/src/app/instance.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -950,9 +950,14 @@ impl super::Nexus {
950950
},
951951
)
952952
.await
953-
.map(|res| res.into_inner().updated_runtime.map(Into::into))
953+
.map(|res| res.into_inner())
954+
.map(|res| {
955+
(
956+
res.updated_runtime.map(Into::into),
957+
res.expect_callback_in_seconds,
958+
)
959+
})
954960
.map_err(|e| SledAgentInstancePutError(e));
955-
956961
// If the operation succeeded, write the instance state back,
957962
// returning any subsequent errors that occurred during that
958963
// write.
@@ -965,14 +970,8 @@ impl super::Nexus {
965970
// (We later asynchronously receive a cpapi call that invokes
966971
// write_returned_instance_state with the outcome.)
967972
match instance_put_result {
968-
Ok(state) => {
969-
if state.is_none()
970-
&& matches!(
971-
requested,
972-
InstanceStateChangeRequest::Run
973-
| InstanceStateChangeRequest::Migrate(..)
974-
)
975-
{
973+
Ok((state, callback_timeout)) => {
974+
if let Some(timeout_secs) = callback_timeout {
976975
// TODO: This is fragile -- suppose the nexus with
977976
// this task crashes *and* the instance creation
978977
// happens to also hang. The new nexus won't know
@@ -991,8 +990,10 @@ impl super::Nexus {
991990
.log
992991
.new(o!("component" => "Instance timeout"));
993992
tokio::spawn(async move {
994-
tokio::time::sleep(Duration::from_secs(120))
995-
.await;
993+
tokio::time::sleep(Duration::from_secs_f64(
994+
timeout_secs,
995+
))
996+
.await;
996997
if let Some(db_datastore) =
997998
db_datastore_weak.upgrade()
998999
{

0 commit comments

Comments
 (0)