terraform-lxd / terraform-provider-lxd

LXD Resource provider for Terraform
https://registry.terraform.io/providers/terraform-lxd/lxd/latest/docs
Mozilla Public License 2.0
257 stars 71 forks source link

Error waiting for container (ubuntu) network information: timeout while waiting for state to become 'OK' (last state: 'NOT FOUND', timeout: 3m0s) #197

Closed thepenguinthatwants closed 4 years ago

thepenguinthatwants commented 4 years ago

Hi!

I reinstalled my desktop and tried to run this simple terrafom setup but it still fails.

provider "lxd" {
  generate_client_certificates = true
  accept_remote_certificate    = true

}

resource "lxd_container" "ubuntu" {
  name                         = "ubuntu"
  image                        = "ubuntu:18.04"
  ephemeral                    = false
}

Not sure what is the cause of this.

Error waiting for container (ubuntu) network information: timeout while waiting for state to become 'OK' (last state: 'NOT FOUND', timeout: 3m0s)

Any idea how to further debug?

My lxc should work fine as I could launch an image by. I've reinstalled my laptop so I might have something that I missed.

lxc launch ubuntu:18.04

Creating the instance Instance name is: supreme-leech Starting supreme-leech

thepenguinthatwants commented 4 years ago

Seems like my containers dont even have IPV4 nor are capable of accessing network. Most likely problem is related on something being broken on lxd.

jtopjian commented 4 years ago

@thepenguinthatwants I was able to create an Ubuntu 18.04 virtual machine, install LXD, and have the configuration you provided successfully create a container:

sudo su
snap install lxd
lxd init
<choose the default answer for all questions>
apt-get install unzip
wget https://releases.hashicorp.com/terraform/0.12.26/terraform_0.12.26_linux_amd64.zip
unzip terraform_0.12.26_linux_amd64.zip
mv terraform /usr/local/bin
wget https://github.com/sl1pm4t/terraform-provider-lxd/releases/download/v1.3.0/terraform-provider-lxd_v1.3.0_linux_amd64.zip
unzip terraform-provider-lxd_v1.3.0_linux_amd64.zip 
mv terraform-provider-lxd_v1.3.0_x4 /usr/local/bin
mkdir t
cd t
vi main.tf

contents of main.tf:

resource "lxd_container" "ubuntu" {
  name                         = "ubuntu"
  image                        = "ubuntu:18.04"
  ephemeral                    = false
}

then:

terraform init
terraform apply

lxd_container.ubuntu: Creating...
lxd_container.ubuntu: Still creating... [10s elapsed]
lxd_container.ubuntu: Still creating... [20s elapsed]
lxd_container.ubuntu: Still creating... [30s elapsed]
lxd_container.ubuntu: Still creating... [40s elapsed]
lxd_container.ubuntu: Still creating... [50s elapsed]
lxd_container.ubuntu: Still creating... [1m0s elapsed]
lxd_container.ubuntu: Still creating... [1m10s elapsed]
lxd_container.ubuntu: Still creating... [1m20s elapsed]
lxd_container.ubuntu: Still creating... [1m30s elapsed]
lxd_container.ubuntu: Creation complete after 1m34s [id=ubuntu]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

lxc ls

+--------+---------+-----------------------+-----------------------------------------------+------------+-----------+
|  NAME  |  STATE  |         IPV4          |                     IPV6                      |    TYPE    | SNAPSHOTS |
+--------+---------+-----------------------+-----------------------------------------------+------------+-----------+
| ubuntu | RUNNING | 10.149.237.220 (eth0) | fd42:296b:ac3a:e697:216:3eff:fe6b:9dee (eth0) | PERSISTENT | 0         |
+--------+---------+-----------------------+-----------------------------------------------+------------+-----------+

lxc exec ubuntu bash

root@ubuntu:~# ping yahoo.com
PING yahoo.com (72.30.35.9) 56(84) bytes of data.
64 bytes from media-router-fp1.prod1.media.vip.bf1.yahoo.com (72.30.35.9): icmp_seq=1 ttl=50 time=59.4 ms

I'm not sure of the issue you could be running into based on the information you've provided.

thepenguinthatwants commented 4 years ago

Thanks for the reply. This was my own foolishness.

The problem was because I had dnsmasq enabled and it somehow messed it up. So I disabled the service and its now good.