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

With the version 0.24.1 it is not possible to remove the affinity host on an existing VM. #238

Closed
bufanda opened this issue Apr 11, 2023 · 6 comments

Comments

@bufanda
Copy link

bufanda commented Apr 11, 2023

I have a VM I had configured an affinity host, now with an expanded cluster and reworking some of the VM distribution I want this one particular VM to not have a affinity to one particular host anymore. So I removed the affinity host rule from the terraform file but now I get the following error.

╷
│ 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"}]}
│
│   with xenorchestra_vm.aegir,
│   on instance-aegir.tf line 1, in resource "xenorchestra_vm" "aegir":
│    1: resource "xenorchestra_vm" "aegir" {
│
╵

As the affinity host rule os only optional per documentation shouldn't it be possible to remove the rule and have terraform remove the setting from the host? Or do I have to destroy the VM and recreate it. Which sure would be possible but it isn't the behaviour I would expect. As in the gui I can simply click on the 'X' to remove the affinity.

@ddelnano
Copy link
Collaborator

Hi @bufanda, thanks for reporting this issue.

It is definitely possible for terraform to handle this case properly. At the moment, I don't know if this is additional fallout from the XO api preventing empty string params (#231) or if the changes to address that caused a new bug. In any case, the provider should be able to handle this.

I'm currently traveling through April 23rd, but I'm hoping to have time to address this. In the meantime, I would use terraform's ignore_changes meta argument and remove the affinity host from the UI (note the code below is an example and was not tested):

resource "xenorchestra_vm" "vm_name" {

[ .. ]
  lifecycle {
    ignore_changes = [affinity_host],
  }
}

That should allow you to continue using the provider to manage these resources until the bug is fixed.

@bufanda
Copy link
Author

bufanda commented Apr 13, 2023

Hi,

the ignore_changes works for now. Thanks.

@exu-g
Copy link

exu-g commented Jun 30, 2023

I found a workaround to remove affinity. Simply set the affinity_host the pool id. This makes the affinity None in Xen Orchestra.

  affinity_host = data.xenorchestra_pool.pool.id

@bufanda
Copy link
Author

bufanda commented Jul 1, 2023

I found a workaround to remove affinity. Simply set the affinity_host the pool id. This makes the affinity None in Xen Orchestra.

  affinity_host = data.xenorchestra_pool.pool.id

Tried it. When you have a VM stopped it won't start anymore as the affinity host wiht the pool id doesn't exists.

You'll get an error message like this

You gave an invalid object reference. The object may have recently been deleted. The class parameter gives the type of reference given, and the handle parameter echoes the bad value given.
class: host
handle: b0b45af2-b561-5cc7-fc28-0a65b3aa32e0

@exu-g
Copy link

exu-g commented Jul 2, 2023

@bufanda yeah, you're right. I should've tested that more than just checking if the host was removed.

@ddelnano
Copy link
Collaborator

ddelnano commented Aug 15, 2023

This will be fixed in v0.24.2, which will be available when this GitHub action completes.

Sorry that this has taken quite a while to be addressed!

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

3 participants