dmacvicar / terraform-provider-libvirt

Terraform provider to provision infrastructure with Linux's KVM using libvirt
Apache License 2.0
1.54k stars 457 forks source link

Plugin Crashes network UUID length #875

Open h3b4r1 opened 2 years ago

h3b4r1 commented 2 years ago

System Information

Linux distribution

gitlab terraform image created with the following dockerfile

FROM registry.gitlab.com/gitlab-org/terraform-images/stable:latest RUN apk update \ && apk add ansible \ && apk add xorriso

Terraform version

Terraform v1.0.3 on linux_amd64

Provider and libvirt versions

required_providers { libvirt = { source = "dmacvicar/libvirt" version = "0.6.10" }

Libvirt on the hypervisor Installed Packages Name : libvirt Version : 6.0.0 Release : 36.module_el8.5.0+821+97472045 Architecture : x86_64 Size : 0.0
Source : libvirt-6.0.0-36.module_el8.5.0+821+97472045.src.rpm

If that gives you "was not built correctly", get the Git commit hash from your local provider repository:

Checklist

Description of Issue/Question

Setup

terraform { required_providers { libvirt = { source = "dmacvicar/libvirt" version = "0.6.10" } ansible = { source = "nbering/ansible" version = "1.0.4" } } }

provider "libvirt" { uri = "qemu+ssh://ansible@lshyp01.lab/system?known_hosts_verify=ignore&keyfile=/root/.ssh/id_rsa" } resource "libvirt_pool" "an-pool" { name = "an-pool" type = "dir" path = "/home/ansible/pool01" }

resource "libvirt_volume" "centos7-qcow2" { name = "centos7-qcow2" pool = libvirt_pool.an-pool.name source = "http://10.16.4.18/CentOS-7-x86_64-GenericCloud-2009.qcow2" format = "qcow2" }

resource "libvirt_network" "userLan" { name = "userLan" autostart = "true" mode = "bridge" bridge = "bridge0" } resource "libvirt_network" "internal" { name = "internal" autostart = "true" mode = "none" } data "template_file" "user_data" { template = file("${path.module}/cloud_init.cfg") }

data "template_file" "network_config" { template = file("${path.module}/network_config.cfg") } resource "libvirt_cloudinit_disk" "commoninit" { name = "commoninit.iso" user_data = data.template_file.user_data.rendered network_config = data.template_file.network_config.rendered pool = libvirt_pool.an-pool.name } resource "libvirt_domain" "testDom" { name = "testDom" description = "test server" vcpu = 2 memory = 2048 running = true cloudinit = libvirt_cloudinit_disk.commoninit.id autostart = true

disk { volume_id = libvirt_volume.centos7-qcow2.id }

network_interface { network_id = libvirt_network.userLan.name addresses = ["10.16.4.32/24"] } network_interface { network_id = libvirt_network.internal.name addresses = ["10.0.0.16/24"] }

IMPORTANT: this is a known bug on cloud images, since they expect a console

we need to pass it

https://bugs.launchpad.net/cloud-images/+bug/1573095

console { type = "pty" target_port = "0" target_type = "serial" }

console { type = "pty" target_type = "virtio" target_port = "1" }

}

Steps to Reproduce Issue

(Include debug logs if possible and relevant).

Stack trace from the terraform-provider-libvirt_v0.6.10 plugin: panic: uuid: Parse(userLan): invalid UUID length: 7 goroutine 52 [running]: github.com/google/uuid.MustParse(0xc000332997, 0x7, 0x0, 0x0) github.com/google/uuid@v1.1.2/uuid.go:142 +0x125 github.com/dmacvicar/terraform-provider-libvirt/libvirt.parseUUID(...) github.com/dmacvicar/terraform-provider-libvirt/libvirt/utils_libvirt.go:11 github.com/dmacvicar/terraform-provider-libvirt/libvirt.setNetworkInterfaces(0xc00043a700, 0xc000017410, 0xc000334600, 0xc0000172a0, 0xc0000171d8, 0x1, 0xfbba78) github.com/dmacvicar/terraform-provider-libvirt/libvirt/domain.go:705 +0x168e github.com/dmacvicar/terraform-provider-libvirt/libvirt.resourceLibvirtDomainCreate(0xc00043a700, 0xdffde0, 0xc00011b170, 0x2, 0x16a7440) github.com/dmacvicar/terraform-provider-libvirt/libvirt/resource_libvirt_domain.go:508 +0x98d github.com/hashicorp/terraform-plugin-sdk/helper/schema.(Resource).Apply(0xc000420990, 0xc000322780, 0xc0004c90a0, 0xdffde0, 0xc00011b170, 0xe78e01, 0xc0001156d8, 0xc00028ed80) github.com/hashicorp/terraform-plugin-sdk@v1.9.0/helper/schema/resource.go:310 +0x375 github.com/hashicorp/terraform-plugin-sdk/helper/schema.(Provider).Apply(0xc000196980, 0xc00056da18, 0xc000322780, 0xc0004c90a0, 0xc00027e2c8, 0xc00000e1a0, 0xe7ada0) github.com/hashicorp/terraform-plugin-sdk@v1.9.0/helper/schema/provider.go:294 +0x99 github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin.(GRPCProviderServer).ApplyResourceChange(0xc000132c60, 0x114ac90, 0xc0004369c0, 0xc00043a070, 0xc000132c60, 0xc0004369c0, 0xc00046cb80) github.com/hashicorp/terraform-plugin-sdk@v1.9.0/internal/helper/plugin/grpc_provider.go:885 +0x8a5 github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5._Provider_ApplyResourceChange_Handler(0xf7dee0, 0xc000132c60, 0x114ac90, 0xc0004369c0, 0xc000334840, 0x0, 0x114ac90, 0xc0004369c0, 0xc000224800, 0x79d) github.com/hashicorp/terraform-plugin-sdk@v1.9.0/internal/tfplugin5/tfplugin5.pb.go:3305 +0x214 google.golang.org/grpc.(Server).processUnaryRPC(0xc000136c00, 0x1153018, 0xc000137380, 0xc00018a900, 0xc0005463c0, 0x16685a0, 0x0, 0x0, 0x0) google.golang.org/grpc@v1.27.1/server.go:1024 +0x522 google.golang.org/grpc.(Server).handleStream(0xc000136c00, 0x1153018, 0xc000137380, 0xc00018a900, 0x0) google.golang.org/grpc@v1.27.1/server.go:1313 +0xd2c google.golang.org/grpc.(Server).serveStreams.func1.1(0xc00003e240, 0xc000136c00, 0x1153018, 0xc000137380, 0xc00018a900) google.golang.org/grpc@v1.27.1/server.go:722 +0xab created by google.golang.org/grpc.(*Server).serveStreams.func1 google.golang.org/grpc@v1.27.1/server.go:720 +0xa5 Error: The terraform-provider-libvirt_v0.6.10 plugin crashed! This is always indicative of a bug within the plugin. It would be immensely helpful if you could report the crash with the plugin's maintainers so that it can be fixed. The output above should help diagnose the issue.