Skip to content

Commit

Permalink
Attempt to restart VM by name
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander V. Nikolaev <[email protected]>
  • Loading branch information
avnik committed Dec 2, 2024
1 parent e161230 commit 6dcc4d6
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/admin/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,10 @@ impl AdminServiceImpl {
}

pub async fn handle_error(&self, entry: RegistryEntry) -> anyhow::Result<()> {
info!(
"Handling error for {} vm type {} service type {}",
entry.name, entry.r#type.vm, entry.r#type.service
);
match (entry.r#type.vm, entry.r#type.service) {
(VmType::AppVM, ServiceType::App) => {
if entry.status.is_exitted() {
Expand All @@ -231,10 +235,11 @@ impl AdminServiceImpl {
Ok(())
}
(VmType::AppVM, ServiceType::Mgr) | (VmType::SysVM, ServiceType::Mgr) => {
let name = parse_service_name(&entry.name)?;
self.start_vm(name)
.await
.with_context(|| format!("handing error, by restart VM {}", entry.name))?;
if let Placement::Managed { vm: vm_name, .. } = entry.placement {
self.start_vm(&vm_name)
.await
.with_context(|| format!("handing error, by restart VM {}", entry.name))?;
}
Ok(()) // FIXME: should use `?` from line above, why it didn't work?
}
(x, y) => bail!("Don't known how to handle_error for VM type: {x:?}:{y:?}"),
Expand Down

0 comments on commit 6dcc4d6

Please sign in to comment.