fix: spawn only if vms are not expired

This commit is contained in:
2024-11-26 19:57:32 +00:00
parent 464b823944
commit 7d8956e7c7
2 changed files with 6 additions and 3 deletions

View File

@ -3,6 +3,7 @@ use crate::provisioner::lnvps::LNVpsProvisioner;
use crate::provisioner::Provisioner;
use crate::status::{VmRunningState, VmState, VmStateCache};
use anyhow::{bail, Result};
use chrono::Utc;
use fedimint_tonic_lnd::Client;
use ipnetwork::IpNetwork;
use lnvps_db::{LNVpsDb, Vm, VmHost};
@ -137,7 +138,9 @@ impl Worker {
}
Err(e) => {
warn!("Failed to get VM status: {}", e);
self.spawn_vm(&vm, &host, &client).await?;
if vm.expires > Utc::now() {
self.spawn_vm(&vm, &host, &client).await?;
}
}
}
Ok(())