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

fix: prevent deletion attempts for non-existent vmID -1 #38

Merged
merged 1 commit into from
Dec 16, 2023
Merged

Conversation

pborn-ionos
Copy link
Contributor

This should fix #31. It simply checks if the passed vmID is < 100 (which is not allowed by Proxmox) and then returns the does not exist error, which we'd expect anyways, in case a VM does not exist. That way it also spares us from making unnecessary API calls to Proxmox.

Alternative solution would be to just reword our error in the same function from cannot find vm with id %d to vm with id %d does not exist, which would effectively have the same functional effect in our controller, but would in turn make unnecessary API calls to Proxmox for a VM that could've never existed.

Both solutions would work with https://github.com/ionos-cloud/cluster-api-provider-proxmox/blob/5f6d700a2d39e0c54818354485c8fbadf8cb442d/internal/service/vmservice/delete.go#L52C1-L55C2

Copy link
Member

@mcbenjemaa mcbenjemaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM,

That's correct.
The GetVirtualMachine ID returns -1 if the vm is not yet created.

We could also put this check in the reconciler but also here, is okay.

Copy link

sonarcloud bot commented Dec 16, 2023

@pborn-ionos pborn-ionos merged commit a1666e4 into main Dec 16, 2023
9 checks passed
@pborn-ionos pborn-ionos deleted the fix/31 branch December 16, 2023 18:53
pborn-ionos added a commit that referenced this pull request Dec 17, 2023
…ost's reserveable memory

Previously, it was only checked for VMs, without taking their Template status into consideration. (A Template VM can't be started, without explicitly removing the flag.). Existing LXCs on a host weren't taken into consideration either.

Now, we'll no longer include VM Template in our calculations. But in exchange we include LXCs now.

Fixes #38.
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

Successfully merging this pull request may close these issues.

ProxmoxMachine deletion fails and loops with cannot find vm with id -1
2 participants