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

Can't create VM without specifying an affinity_host - issue with an empty string #243

Closed
killroy1971 opened this issue May 5, 2023 · 8 comments

Comments

@killroy1971
Copy link

I'm trying to create a diskless VM. The VM creation part works, however I need to include an affinity_host line in my VM's configuration, so I used the data.xenorchestra_pool.pool.id item, which in my mind should allow the hypervisor to choose the best host within the Homelab pool. The VMs create, but they can't be started because the hypervisor never assigns a host to the VMs.

Ultimately, that's what I would like to do. Omit the affinity_host configuration item entirely, or specify the xenorchestra.host as "none" on the affinity_host line, and have the hypervisor choose the host.

main.tf has:
data "xenorchetra.pool" "pool" {
name_label = "Homelab"
}

vm.tf has:
...
memory_max = 107374182400
cpus = 2
hvm_boot_firmware = "uefi"
name_label = each.key
name_description = each.value
affinity_host = data.xenorchestra_pool.pool.id
template = data.xenorchestra_template.talos_control.id

network {
network_id = data.xenorchestra_network.net.id
}
...

@collegue1337
Copy link

Same issue here,

 Error: jsonrpc2: code 10 message: invalid parameters: {"errors":[{"instancePath":"/affinityHost","schemaPath":"#/properties/affinityHost/minLength","keyword":"minLength","params":{"limit":1},"message":"must NOT have fewer than 1 characters"},

@illethrias
Copy link

+1 with that issue

@olivierlambert
Copy link
Member

Pinging @julien-f so we can fix this (likely in XO)

@ddelnano
Copy link
Collaborator

ddelnano commented May 8, 2023

This is essentially the same root cause as #238 and my work in progress PR is one way to address this (#239). I unfortunately haven't had time to focus on that change and it still needs more work before it's ready to merge.

If there is a way to handle this on the XO side, that would be great.

@killroy1971
Copy link
Author

Is the error message coming from the XO side, because of a requirement or because of how the VM is being created by terraform?

@ddelnano
Copy link
Collaborator

ddelnano commented May 8, 2023

The error message is coming from XO. The api was recently updated to enforced that optional fields should be null rather than empty strings. See #231 for the link to the XO commits.

@marlluslustosa
Copy link

#231 (comment)

@killroy1971
Copy link
Author

Sorry for the delay. Travel, work, and stuff. Plus, it's been nice outside in my area.

I ran across this in the documentation:
# Prefer to run the VM on the primary pool instance
affinity_host = data.xenorchestra_pool.pool.master
network {
network_id = data.xenorchestra_network.net.id
}

This solves my problem, I can't say if this was added since I started playing with terraform or not. Either way, my problem is solved.

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

6 participants