Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DeleteVm on a "failed" VM does not remove NICs #72

Open
blackwood821 opened this issue Sep 24, 2020 · 0 comments
Open

DeleteVm on a "failed" VM does not remove NICs #72

blackwood821 opened this issue Sep 24, 2020 · 0 comments

Comments

@blackwood821
Copy link

blackwood821 commented Sep 24, 2020

I found several old VMs in the failed state that I wanted to clean up so I ran the following on the head node:

for uuid in $(sdc-vmapi "/vms?predicate=$(urlencode '{ "eq" : [ "state", "failed" ] }')" | json -Ha uuid); do
    echo "Deleting VM ${uuid}"
    sdc-vmapi /vms/${uuid} -X DELETE | json -H
done

(Side note: I'm surprised "/vms?state=failed" doesn't work and requires a predicate for that particular state.)

The code above successfully created and completed a destroy job for each VM but when I look at the job details in AdminUI I see the following even for VMs that do still have NICs in NAPI in the provisioning state:

napi.remove_nics
No MAC addresses to remove

So for some reason DeleteVm is not finding the NICs associated with these VMs in NAPI which means the IP addresses associated with these NICs are not free. I'm guessing it has something to do with the fact that a zone was never actually created on a CN for the VM so perhaps it can't find the MAC addresses? However, I would expect it to look up the NICs in NAPI using ?belongs_to_uuid=<vm_uuid> regardless of whether a zone was ever created or not.

Because DeleteVm didn't find any NICs to delete I had to manually find and delete any NICs associated with any of these VMs that were in the failed state with the following code:

for uuid in $(sdc-vmapi "/vms?predicate=$(urlencode '{ "eq" : [ "state", "failed" ] }')" | json -Ha uuid); do
    for mac in $(sdc-napi /nics?belongs_to_uuid=${uuid} | json -Ha mac); do
        echo "Deleting NIC ${mac} under failed VM ${uuid}"
        sdc-napi /nics/${mac} -X DELETE
    done
done

That successfully deleted all the NICs from NAPI and freed up the IPs.

Now I wonder if there are any other steps in a DeleteVm job that need manual attention as well....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant