containerlab icon indicating copy to clipboard operation
containerlab copied to clipboard

clab assumes a bridge exists when using an existing docker network

Open pdumais opened this issue 1 year ago • 0 comments

Create a docker network based on macvlan

# docker network create -d macvlan --subnet=10.40.40.0/24 --gateway=10.40.40.1 -o parent=ens3 awesome

Use that network in the clab config

# cat lab.yml 
name: lab
mgmt:
  network: awesome
topology:
  nodes:
    srl:
      kind: srl
      image: ghcr.io/nokia/srlinux
    linux:
      kind: linux
      image: alpine

Run clab

# clab deploy -t lab.yml
INFO[0000] Containerlab v0.46.2 started
INFO[0000] Parsing & checking topology file: lab.yml    
----> WARN[0000] failed gleaning v4 and/or v6 addresses from bridge via netlink, falling back to docker network inspect data
----> WARN[0000] failed to enable LLDP on docker bridge: open /sys/class/net/br-1fe17c702ea0/bridge/group_fwd_mask: no such file or directory
----> WARN[0000] failed to disable TX checksum offloading for the br-1fe17c702ea0 bridge interface: no such device
INFO[0000] Creating lab directory: /root/clabtest/clab-lab 
INFO[0000] Creating container: "linux"
INFO[0000] Creating container: "srl"
INFO[0000] Running postdeploy actions for Nokia SR Linux 'srl' node 
----> INFO[0000] Failed to disable TX checksum offload for 'eth0' interface for Linux 'linux' node: operation not supported
----> ERRO[0000] failed to run postdeploy task for node linux: operation not supported
INFO[0007] Adding containerlab host entries to /etc/hosts file 
+---+----------------+--------------+-----------------------+-------+---------+---------------+--------------+
| # |      Name      | Container ID |         Image         | Kind  |  State  | IPv4 Address  | IPv6 Address |
+---+----------------+--------------+-----------------------+-------+---------+---------------+--------------+
| 1 | clab-lab-linux | cb5adddaa131 | alpine                | linux | running | 10.40.40.2/24 | N/A          |
| 2 | clab-lab-srl   | 9103b86c3769 | ghcr.io/nokia/srlinux | srl   | running | 10.40.40.3/24 | N/A          |
+---+----------------+--------------+-----------------------+-------+---------+---------------+--------------+

As we can see, when using a docker network that is not bridge-based, clab attempts to set a few options on a non existing bridge. clab should probably detect this and either prevent the user from using such a network or to support that network (preferred option IMO) Note that the lab works just fine though. But in the case of linux, this was the only postdeploy action, so if other actions are added in the postdeploy handler, then I think they won't be executed after the 1st failure. So it's a lucky shot.

Also, when destroying the lab, clab destroys the network. clab should probably only destroy networks that it created.

If it is agreed that this is a valid issue, I can submit a PR.

pdumais avatar Oct 17 '23 10:10 pdumais