fix: prevent deletion attempts for non-existent vmID -1 #38
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This should fix #31. It simply checks if the passed vmID is
< 100
(which is not allowed by Proxmox) and then returns thedoes 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
tovm 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