Skip to content

Podman network interfaces not properly deleted during containerlab destroy #2578

@FloSch62

Description

@FloSch62

When using containerlab with the podman runtime, network interfaces aren't being properly cleaned up after destroying a lab. This causes subnet conflicts when attempting to redeploy the same topology using the default network.

clab@FloSch:~$ containerlab -r podman deploy -c -t .clab/srl01/srl01.clab.yml 
19:21:21 INFO Containerlab started version=0.68.0
19:21:21 INFO Parsing & checking topology file=srl01.clab.yml
19:21:21 INFO Removing directory path=/home/clab/.clab/srl01/clab-srl01
19:21:21 INFO Creating lab directory path=/home/clab/.clab/srl01/clab-srl01
19:21:21 INFO Running postdeploy actions kind=nokia_srlinux node=srl2
19:21:21 INFO Created link: srl1:e1-1 ▪┄┄▪ srl2:e1-1
19:21:21 INFO Running postdeploy actions kind=nokia_srlinux node=srl1
19:21:31 INFO Adding host entries path=/etc/hosts
19:21:31 INFO Adding SSH config for nodes path=/etc/ssh/ssh_config.d/clab-srl01.conf
╭─────────────────┬──────────────────────────────┬─────────┬───────────────────╮
│       Name      │          Kind/Image          │  State  │   IPv4/6 Address  │
├─────────────────┼──────────────────────────────┼─────────┼───────────────────┤
│ clab-srl01-srl1 │ nokia_srlinux                │ running │ 172.20.20.23      │
│                 │ ghcr.io/nokia/srlinux:latest │         │ 3fff:172:20:20::f │
├─────────────────┼──────────────────────────────┼─────────┼───────────────────┤
│ clab-srl01-srl2 │ nokia_srlinux                │ running │ 172.20.20.22      │
│                 │ ghcr.io/nokia/srlinux:latest │         │ 3fff:172:20:20::e │
╰─────────────────┴──────────────────────────────┴─────────┴───────────────────╯
(reverse-i-search)`': ^C
clab@FloSch:~$ containerlab -r podman destroy -c -t .clab/srl01/srl01.clab.yml 
19:21:55 INFO Parsing & checking topology file=srl01.clab.yml
19:21:55 INFO Parsing & checking topology file=srl01.clab.yml
19:21:55 INFO Destroying lab name=srl01
19:21:56 INFO Removing host entries path=/etc/hosts
19:21:56 INFO Removing SSH config path=/etc/ssh/ssh_config.d/clab-srl01.conf
clab@FloSch:~$ containerlab -r podman deploy -c -t .clab/srl01/srl01.clab.yml 
19:21:58 INFO Containerlab started version=0.68.0
19:21:58 INFO Parsing & checking topology file=srl01.clab.yml
19:21:58 INFO Removing directory path=/home/clab/.clab/srl01/clab-srl01
Error: subnet 172.20.20.0/24 is already used on the host or by another config

When attempting to redeploy, containerlab fails with:

Error: subnet 172.20.20.0/24 is already used on the host or by another config

The debug logs show containerlab attempting to delete the management network:

20:26:41 DEBU Calling DeleteNet method. *CLab.Config.Mgmt value is: &{Network:clab Bridge:podman1 IPv4Subnet:172.20.20.0/24 IPv4Gw: IPv4Range: IPv6Subnet:3fff:172:20:20::/64 IPv6Gw: IPv6Range: MTU:0 ExternalAccess:0xc00057c4cf}
20:26:41 DEBU Method DeleteNet was called with runtime inputs &{config:0xc0001169d8 mgmt:0xc00015de60} and net settings &{Network:clab Bridge:podman1 IPv4Subnet:172.20.20.0/24 IPv4Gw: IPv4Range: IPv6Subnet:3fff:172:20:20::/64 IPv6Gw: IPv6Range: MTU:0 ExternalAccess:0xc00057c4cf}
20:26:41 DEBU trying to delete mgmt network clab

However, despite this attempt, the network interfaces remain:

61: br-017aa95cb641: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 
    inet 172.20.20.1/24 brd 172.20.20.255 scope global br-017aa95cb641
       valid_lft forever preferred_lft forever
... or
78: podman1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
    inet 172.20.20.1/24 brd 172.20.20.255 scope global podman1
       valid_lft forever preferred_lft forever

However the the clab nework is gone:

clab@FloSch:~/.clab/srl01$ sudo podman network ls
NETWORK ID    NAME        DRIVER
2f259bab93aa  podman      bridge

The DeleteNet method in the podman runtime implementation doesn't appear to be fully cleaning up network interfaces. While containerlab correctly identifies the management network and bridge interface, the actual deletion of these resources is not completing successfully.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions