Skip to content

Commit

Permalink
wip: missed a spot - use the timeout supplied by sled-agent
Browse files Browse the repository at this point in the history
  • Loading branch information
lif committed Jan 23, 2024
1 parent 10b8851 commit 686006f
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions nexus/src/app/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -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()
{
Expand Down

0 comments on commit 686006f

Please sign in to comment.