Skip to content

Commit

Permalink
handle Option in update saga too (oops)
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkw committed Sep 4, 2024
1 parent 837b7a5 commit 0ff10d6
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions nexus/src/app/sagas/instance_update/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ struct UpdatesRequired {
/// The instance's auto-restart policy. This indicates whether the
/// `instance-reincarnation` background task should be activated if the
/// instance has transitioned to [`InstanceState::Failed`].
auto_restart_policy: InstanceAutoRestart,
auto_restart_policy: Option<InstanceAutoRestart>,
}

#[derive(Debug, Deserialize, Serialize)]
Expand Down Expand Up @@ -1218,15 +1218,17 @@ async fn siu_commit_instance_updates(
// update saga is required, and the instance's auto-restart policy allows it
// to be automatically restarted, activate the instance-reincarnation
// background task to automatically restart it.
if update.new_runtime.can_reincarnate(update.auto_restart_policy) {
info!(
log,
"instance update: instance transitioned to Failed, but can \
be automatically restarted; activating reincarnation.";
"instance_id" => %instance_id,
"auto_restart_policy" => ?update.auto_restart_policy,
);
nexus.background_tasks.task_instance_reincarnation.activate();
if let Some(auto_restart_policy) = update.auto_restart_policy {
if update.new_runtime.can_reincarnate(auto_restart_policy) {
info!(
log,
"instance update: instance transitioned to Failed, but can \
be automatically restarted; activating reincarnation.";
"instance_id" => %instance_id,
"auto_restart_policy" => ?update.auto_restart_policy,
);
nexus.background_tasks.task_instance_reincarnation.activate();
}
}

Ok(())
Expand Down

0 comments on commit 0ff10d6

Please sign in to comment.