Skip to content

delete-vms silently skips deletion when Proxmox API is reachable (no API fast-path in delete script) #120

Description

@t0kubetsu

Summary

range42-context delete-vms stops VMs successfully but never deletes them. The deletion is silently skipped with a warning:

[WARNING]: Could not match supplied host pattern, ignoring: pve

Root Cause

proxmox_vm.vm_id.delete.to.jsons.sh has no Proxmox API delegation block. It always falls through to the Ansible slow-path via proxmox__inc.jsons.basic_vm_actions.to.jsons.sh, which resolves the Ansible inventory host as:

ANSIBLE_HOST="${RANGE42_INFRASTRUCTURE_CODENAME:-$PROXMOX_NODE}"

When RANGE42_INFRASTRUCTURE_CODENAME is not exported (e.g. sourced_range42.sh not in scope), ANSIBLE_HOST falls back to $PROXMOX_NODE = "pve" (from the JSON line). The inventory does not have a host named pve — it uses the alias local-lab — so Ansible silently skips the play.

The stop_force, start, pause, resume, and stop scripts were all updated in PR #119 with an API delegation guard that bypasses Ansible entirely when the Proxmox HTTPS API is reachable. delete was the only lifecycle script not updated.

Impact

VMs are left running (or stopped but not destroyed) after range42-context delete-vms. Re-running setup-vms then fails with HTTP 500 because the VM ID already exists (vm_clone is not idempotent, see #19).

Fix

See PR for two new files:

  • proxmox_vm.vm_id.delete_with_api.to.jsons.sh — direct DELETE /qemu/{vm_id} with UPID polling (60 s timeout), modelled after stop_force_with_api.to.jsons.sh
  • API delegation guard added to proxmox_vm.vm_id.delete.to.jsons.sh (same pattern as all other lifecycle scripts)

Set RANGE42_PROXMOX_API_FORCE=off to opt out and keep the Ansible slow-path.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions