fix: spawn only if vms are not expired

This commit is contained in:
kieran 2024-11-26 19:57:32 +00:00
parent 464b823944
commit 7d8956e7c7
No known key found for this signature in database
GPG Key ID: DE71CEB3925BE941
2 changed files with 6 additions and 3 deletions

View File

@ -80,7 +80,7 @@ impl ProxmoxClient {
.await?;
let status = rsp.status();
let text = rsp.text().await?;
info!("<< {}", text);
//info!("<< {}", text);
if status.is_success() {
Ok(serde_json::from_str(&text)?)
} else {
@ -100,7 +100,7 @@ impl ProxmoxClient {
.await?;
let status = rsp.status();
let text = rsp.text().await?;
info!("<< {}", text);
//info!("<< {}", text);
if status.is_success() {
Ok(serde_json::from_str(&text)?)
} else {

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(())