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

Domains set to be incorrectly recreated to add "type=kvm" property #1062

Open
1 of 5 tasks
rombert opened this issue Dec 28, 2023 · 2 comments
Open
1 of 5 tasks

Domains set to be incorrectly recreated to add "type=kvm" property #1062

rombert opened this issue Dec 28, 2023 · 2 comments

Comments

@rombert
Copy link

rombert commented Dec 28, 2023

System Information

Linux distribution

openSUSE Tumbleweed

Terraform version

Terraform v1.5.5

Provider and libvirt versions

v0.7.6

Checklist

  • Is your issue/contribution related with enabling some setting/option exposed by libvirt that the plugin does not yet support, or requires changing/extending the provider terraform schema?

    • Make sure you explain why this option is important to you, why it should be important to everyone. Describe your use-case with detail and provide examples where possible.
    • If it is a very special case, consider using the XSLT support in the provider to tweak the definition instead of opening an issue
    • Maintainers do not have expertise in every libvirt setting, so please, describe the feature and how it is used. Link to the appropriate documentation
  • Is it a bug or something that does not work as expected? Please make sure you fill the version information below:

Description of Issue/Question

Setup

I have a very plain terraform setup, coming from the 0.6.x days. The domain definition looks like this

# domain (VM definition)
resource "libvirt_domain" "microos_domain" {
  for_each  = { for vm_def in var.vm_defs : vm_def.hostname => vm_def }
  name      = "homelab002-${each.key}"
  autostart = true

  cpu {
    mode = "host-passthrough"
  }

  memory = each.value.memory
  vcpu   = each.value.cpu_count

  disk {
    volume_id = libvirt_volume.os_volume[each.key].id
  }

  network_interface {
    network_name   = libvirt_network.homelab002_net.name
    hostname       = data.template_file.ignition_data[each.key].vars.hostname
    wait_for_lease = true
  }

I upgraded from 0.6.14 to 0.7.6 and terraform plan now wants to recreate my domains, e.g.

  # libvirt_domain.microos_domain["worker-1"] must be replaced
-/+ resource "libvirt_domain" "microos_domain" {
      ~ arch            = "x86_64" -> (known after apply)
      - cmdline         = [] -> null
      ~ emulator        = "/usr/bin/qemu-system-x86_64" -> (known after apply)
      ~ id              = "5c6ce085-2f92-4af9-966e-a04a3aaa1567" -> (known after apply)
      ~ machine         = "pc-i440fx-6.2" -> (known after apply)
        name            = "homelab002-worker-1"
      + type            = "kvm" # forces replacement
        # (7 unchanged attributes hidden)

      ~ network_interface {
          ~ addresses      = [
              - "10.25.1.107",
            ] -> (known after apply)
          ~ mac            = "52:54:00:E6:3A:DC" -> (known after apply)
          ~ network_id     = "a7677a48-27ad-4769-8af2-504d9cb396ef" -> (known after apply)
            # (3 unchanged attributes hidden)
        }

        # (2 unchanged blocks hidden)
    }

I checked the VM definitions via virt-manager and they all start with

<domain xmlns:qemu="http://libvirt.org/schemas/domain/qemu/1.0" type="kvm">
  <name>homelab002-worker-1</name>

Steps to Reproduce Issue

I guess start with 0.6.x and upgrade to 0.7.x?

Additional information:

Do you have SELinux or Apparmor/Firewall enabled? Some special configuration?
No.
Have you tried to reproduce the issue without them enabled?
N/A

This behaviour seems to have been brought in via #1045

@michaelbeaumont
Copy link
Collaborator

Yeah, it was probably a mistake to set the default to be kvm. Can you set it to the empty string to avoid the recreation?

@rombert
Copy link
Author

rombert commented Dec 29, 2023

Yeah, it was probably a mistake to set the default to be kvm. Can you set it to the empty string to avoid the recreation?

Thanks for the hint. With that property set the domains are no longer set to be re-created.

My immediate problem is solved, I'll leave this up to you whether you want to follow-up with a fix or just close.

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

2 participants