canonical / lxd

Powerful system container and virtual machine manager
https://canonical.com/lxd
GNU Affero General Public License v3.0
4.33k stars 926 forks source link

Containers not being granted IPs on non-Ubuntu OS, cloud-init can't find network #13494

Closed marcoppenheimer closed 3 months ago

marcoppenheimer commented 4 months ago

Required information

Issue description

I am fairly certain this is a cloud-init, but confirming. I'm not getting any container IPs for my machines, any idea why I'm not getting container IPs. Mattermost thread - https://chat.canonical.com/canonical/pl/9rfjs1w5piba3q1okw7y8hzeso

Steps to reproduce

sudo snap install lxd --channel latest/edge
lxd init --auto && lxc network set lxdbr0 ipv6.address none
lxc launch ubuntu:22.04 my-test --config=user.user-data="$(cat /tmp/my-user-data)" -n lxdbr0
cat /tmp/my-user-data
runcmd:
    - echo  'Hello, World!' > /var/tmp/hello-world.txt
lxc shell my-test
cloud-init status --wait
# ...................................................... , runs forever

Information to attach

Cloud-init v. 24.1.3-0ubuntu1~22.04.1 running 'init-local' at Wed, 22 May 2024 16:59:04 +0000. Up 0.68 seconds.
Cloud-init v. 24.1.3-0ubuntu1~22.04.1 running 'init' at Wed, 22 May 2024 16:59:05 +0000. Up 1.65 seconds.
ci-info: ++++++++++++++++++++++++++++++++++++++Net device info+++++++++++++++++++++++++++++++++++++++
ci-info: +--------+------+-----------------------------+---------------+--------+-------------------+
ci-info: | Device |  Up  |           Address           |      Mask     | Scope  |     Hw-Address    |
ci-info: +--------+------+-----------------------------+---------------+--------+-------------------+
ci-info: |  eth0  | True |         10.218.21.53        | 255.255.255.0 | global | 00:16:3e:f4:b8:4f |
ci-info: |  eth0  | True | fe80::216:3eff:fef4:b84f/64 |       .       |  link  | 00:16:3e:f4:b8:4f |
ci-info: |   lo   | True |          127.0.0.1          |   255.0.0.0   |  host  |         .         |
ci-info: |   lo   | True |           ::1/128           |       .       |  host  |         .         |
ci-info: +--------+------+-----------------------------+---------------+--------+-------------------+
ci-info: ++++++++++++++++++++++++++++++Route IPv4 info++++++++++++++++++++++++++++++
ci-info: +-------+-------------+-------------+-----------------+-----------+-------+
ci-info: | Route | Destination |   Gateway   |     Genmask     | Interface | Flags |
ci-info: +-------+-------------+-------------+-----------------+-----------+-------+
ci-info: |   0   |   0.0.0.0   | 10.218.21.1 |     0.0.0.0     |    eth0   |   UG  |
ci-info: |   1   | 10.218.21.0 |   0.0.0.0   |  255.255.255.0  |    eth0   |   U   |
ci-info: |   2   | 10.218.21.1 |   0.0.0.0   | 255.255.255.255 |    eth0   |   UH  |
ci-info: +-------+-------------+-------------+-----------------+-----------+-------+
ci-info: +++++++++++++++++++Route IPv6 info+++++++++++++++++++
ci-info: +-------+-------------+---------+-----------+-------+
ci-info: | Route | Destination | Gateway | Interface | Flags |
ci-info: +-------+-------------+---------+-----------+-------+
ci-info: |   0   |  fe80::/64  |    ::   |    eth0   |   U   |
ci-info: |   2   |    local    |    ::   |    eth0   |   U   |
ci-info: |   3   |  multicast  |    ::   |    eth0   |   U   |
ci-info: +-------+-------------+---------+-----------+-------+
~  ❯ lxc network show lxdbr0                 
name: lxdbr0
description: ""
type: bridge
managed: true
status: Created
config:
  ipv4.address: 10.218.21.1/24
  ipv4.dhcp: "true"
  ipv4.nat: "true"
  ipv6.address: none
  ipv6.nat: "true"
used_by:
- /1.0/instances/my-test
- /1.0/profiles/default
locations:
- none
  ❯ lxc shell my-test
root@my-test:~# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
38: eth0@if39: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 00:16:3e:f4:b8:4f brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 10.218.21.53/24 metric 100 brd 10.218.21.255 scope global dynamic eth0
       valid_lft 2032sec preferred_lft 2032sec
    inet6 fe80::216:3eff:fef4:b84f/64 scope link 
       valid_lft forever preferred_lft forever
root@my-test:~# cat /etc/netplan/*
# This file is generated from information provided by the datasource.  Changes
# to it will not persist across an instance reboot.  To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
    version: 2
    ethernets:
        eth0:
            dhcp4: true
~  ❯ lxc list                  
+---------------+---------+------+------+-----------+-----------+
|     NAME      |  STATE  | IPV4 | IPV6 |   TYPE    | SNAPSHOTS |
+---------------+---------+------+------+-----------+-----------+
| my-test       | RUNNING |      |      | CONTAINER | 0         |
+---------------+---------+------+------+-----------+-----------+
~  ❯ lxc info my-test        
Name: my-test
Status: RUNNING
Type: container
Architecture: x86_64
PID: 325706
Created: 2024/05/22 17:59 BST
Last Used: 2024/05/22 17:59 BST

Resources:
  Processes: 66
  CPU usage:
    CPU usage (in seconds): 2688
  Memory usage:
    Memory (current): 484.62MiB
  Network usage:
    eth0:
      Type: broadcast
      State: UP
      Host interface: vetha8a72546
      MAC address: 00:16:3e:f4:b8:4f
      MTU: 1500
      Bytes received: 31.90MB
      Bytes sent: 246.69kB
      Packets received: 4394
      Packets sent: 3395
      IP addresses:
        inet6: fe80::216:3eff:fef4:b84f/64 (link)
    lo:
      Type: loopback
      State: UP
      MTU: 65536
      Bytes received: 5.80kB
      Bytes sent: 5.80kB
      Packets received: 52
      Packets sent: 52
      IP addresses:
        inet:  127.0.0.1/8 (local)
        inet6: ::1/128 (local)
holmanb commented 4 months ago

@marcoppenheimer since cloud-init does not complete could you please run through these steps and if that doesn't help you resolve your issue please share the output of those commands in this bug report?

holmanb commented 4 months ago

@marcoppenheimer There is a doc on how to debug cloud-init never completing.

If that doesn't help you, or if you want an extra set of eyes on the output of those commands or cloud-init's logs, please add them to this bug and ping me in a comment.

tomponline commented 3 months ago

What does lxc config show <instance> --expanded show?

Also, have you confirmed its not a host firewall issue?

https://documentation.ubuntu.com/lxd/en/latest/howto/network_bridge_firewalld/

Finally, as I notice you're running Arch, please can you see if networkd hasnt started properly inside the container by listing output from: lxc exec <instance> -- systemctl —failed

Thanks

marcoppenheimer commented 3 months ago

I think we can close this, the issue was https://github.com/lxc/incus/issues/892 I believe!

tomponline commented 3 months ago

Thanks!