fix: remove stop command on delete

This commit is contained in:
kieran 2025-01-06 15:42:26 +00:00
parent de55d34086
commit 06f7beb26f
No known key found for this signature in database
GPG Key ID: DE71CEB3925BE941
2 changed files with 5 additions and 5 deletions

View File

@ -470,13 +470,13 @@ impl Provisioner for LNVpsProvisioner {
async fn delete_vm(&self, vm_id: u64) -> Result<()> { async fn delete_vm(&self, vm_id: u64) -> Result<()> {
let vm = self.db.get_vm(vm_id).await?; let vm = self.db.get_vm(vm_id).await?;
let host = self.db.get_host(vm.host_id).await?; //let host = self.db.get_host(vm.host_id).await?;
let client = get_host_client(&host)?;
// TODO: delete not implemented, stop only // TODO: delete not implemented, stop only
//let client = get_host_client(&host)?;
//let j_start = client.delete_vm(&host.name, vm.id + 100).await?; //let j_start = client.delete_vm(&host.name, vm.id + 100).await?;
let j_stop = client.stop_vm(&host.name, vm.id + 100).await?; //let j_stop = client.stop_vm(&host.name, vm.id + 100).await?;
client.wait_for_task(&j_stop).await?; //client.wait_for_task(&j_stop).await?;
if let Some(r) = self.router.as_ref() { if let Some(r) = self.router.as_ref() {
let ent = r.list_arp_entry().await?; let ent = r.list_arp_entry().await?;

View File

@ -228,7 +228,7 @@ impl Worker {
} }
// delete vm if not paid (in new state) // delete vm if not paid (in new state)
if vm.expires < Utc::now().sub(Days::new(1)) && state.is_none() { if !vm.deleted && vm.expires < Utc::now().sub(Days::new(1)) && state.is_none() {
info!("Deleting unpaid VM {}", vm.id); info!("Deleting unpaid VM {}", vm.id);
self.provisioner.delete_vm(vm.id).await?; self.provisioner.delete_vm(vm.id).await?;
} }