-
Notifications
You must be signed in to change notification settings - Fork 29
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
feat: Add ability to specify range of VM IDs to use #286
Conversation
0118c49
to
f18a4e8
Compare
…ines before querying the Proxmox API.
…ing it to usedVMIDs
@@ -311,10 +315,15 @@ func getMachineAddresses(scope *scope.MachineScope) ([]clusterv1.MachineAddress, | |||
} | |||
|
|||
func createVM(ctx context.Context, scope *scope.MachineScope) (proxmox.VMCloneResponse, error) { | |||
vmid, err := getVMID(ctx, scope) | |||
if err != nil { | |||
return proxmox.VMCloneResponse{}, err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there's only one remaining thing:
you will probably need to fail the machine provisioning here.
if err != nil {
if errors.Is(err, ErrNoVMIDInRangeFree) {
// fail the machine, by setting failureReason, and failureMessage
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you have the time to check my above comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
without failing the machine here,
the user will not know what's happening, and the reconciliation is always be queued
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Disregard the nitpicks in the review.
My problem is with the API itself:
Putting the VMID range into cluster id works for your usecase, but other people may have different use cases.
The only sensible place where to put VM IDs is into the ProxmoxMachineTemplates, as people may want to set VM ID ranges per machine kind.
Of course this means that if you want to reuse ProxmoxMachineTemplates but not VM IDs, you can't, but that's a small price to pay.
config/crd/bases/infrastructure.cluster.x-k8s.io_proxmoxclusters.yaml
Outdated
Show resolved
Hide resolved
config/crd/bases/infrastructure.cluster.x-k8s.io_proxmoxclusters.yaml
Outdated
Show resolved
Hide resolved
config/crd/bases/infrastructure.cluster.x-k8s.io_proxmoxclusters.yaml
Outdated
Show resolved
Hide resolved
Very good point. I tested the functionality by specifying different vmidRanges for my control plane and worker nodes and liked it immediately. |
I cannot reproduce the issue. When I create a new VM, the controller reliably picks the first free VM ID from the Can you please have a look in the debug log at the API call to It should look something like this and it happens just before the VM clone task is started:
|
@mcbenjemaa Have you had a chance to test this again with debug output enabled? Is there anything I can do to help you test this branch? |
I will test it again and let you know |
Testing with VMIDRanges is okay. |
Ok, I will also test without VMIDRanges. Can you be a bit more specific about "something strange"? |
The machines are failing and are a bit slow. Honestly, I don't know whether it is because of the code or because some issues are happening in my setup. |
@mcbenjemaa I can't see from the logs why the e2e tests failed. The logs from the Proxmox cluster would be interesting, though:
Any idea why it failed? |
Quality Gate passedIssues Measures |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR looks good to me (I don't even have a nitpick). I'll give it a try and then greenlight.
Description of changes:
This feature allows you to specify a
vmidRange
on aProxmoxCluster
object. A free ID betweenvmidRange.start
andvmidRange.end
will then be determined and used for a new VM.We use ranges of VM IDs in Proxmox to differentiate between projects/customers/stages. I suspect many Proxmox users do this.
While developing this feature I found a bug in luthermonson/go-proxmox which will be fixed in the next release. Due to the size of this PR and possible requests from your side to merge it, I have created this PR with a dependency on the current main branch of
go-proxmox
. Of course, it shouldn't be merged until the new release ofgo-proxmox
is out.What do you think of this feature and its implementation?
Testing performed:
I created tests for the new features. We also tested the functionality on our Proxmox test cluster.