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 18, 2024
1 parent b4139a6 commit 7833b92
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 @@ -224,6 +224,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 @@ -233,10 +237,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) => {
Expand Down

0 comments on commit 7833b92

Please sign in to comment.