[Bug 1959570] Re: netplan crashes on UbuntuCore with the network-manager snap installed

Launchpad Bug Tracker 1959570 at bugs.launchpad.net
Tue Nov 28 23:22:16 UTC 2023


This bug was fixed in the package netplan.io - 0.104-0ubuntu2~20.04.4

---------------
netplan.io (0.104-0ubuntu2~20.04.4) focal; urgency=medium

  * Cherry-pick upstream commit fc12872 (PR#336) to fix crash in 'snapd set'
    (LP: #1959570)
  * Add autopkgtest for LP#1959570

 -- Lukas Märdian <slyon at ubuntu.com>  Thu, 26 Oct 2023 15:59:19 +0200

** Changed in: netplan.io (Ubuntu Focal)
       Status: Fix Committed => Fix Released

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to netplan.io in Ubuntu.
Matching subscriptions: foundations-bugs
https://bugs.launchpad.net/bugs/1959570

Title:
  netplan crashes on UbuntuCore with the network-manager snap installed

Status in netplan:
  Fix Released
Status in netplan.io package in Ubuntu:
  Fix Released
Status in netplan.io source package in Focal:
  Fix Released
Status in netplan.io source package in Jammy:
  Won't Fix
Status in netplan.io source package in Kinetic:
  Invalid
Status in netplan.io source package in Lunar:
  Fix Released

Bug description:
  [ Impact ]

   * When using the netplan-dbus API on Ubuntu Core and the network-
  manager renderer (NM snap) the "netplan-dbus" application will crash.
  Leaving the device unreachable.

   * Netplan's CLI is unable to find the network-manager.nmcli binary
  from the NetworkManager snap, as it's not in netplan-dbus's PATH (nor
  Python's default BINDIR), therefore it cannot properly restart NM's
  connections to re-activate the network after changes were applied.

  [ Test Plan ]

  ==============================
  Boot an Ubuntu Core 20 system, which this fix as part of the core20 base snap
  ==============================
  $ snap install network-manager --channel=20/stable
  $ nmcli # VERIFY br54 is not there
  ens3: connected to netplan-ens3
          "ens3"
          ethernet (virtio_net), 52:54:00:12:34:56, hw, mtu 1500
          ip4 default
          inet4 10.0.2.15/24
          route4 0.0.0.0/0
          route4 10.0.2.0/24
          inet6 fe80::5054:ff:fe12:3456/64
          route6 fe80::/64

  lo: unmanaged
          "lo"
          loopback (unknown), 00:00:00:00:00:00, sw, mtu 65536

  DNS configuration:
          servers: 10.0.2.3
          interface: ens3
  $ sudo snap set system system.network.netplan.network.bridges.br54.dhcp4=true
  ==============================
   Network/SSH connection will be interrupted briefly, but reconnect after some seconds.
  ==============================
  $ netplan get # VERIFY br54 is there
  network:
    version: 2
    renderer: NetworkManager
    ethernets:
      ens3:
        dhcp4: true
    bridges:
      br54:
        dhcp4: true
  $ sudo journalctl | grep FileNotFound # EMPTY => no errors
  $ nmcli # VERIFY br54 is there
  ens3: connected to netplan-ens3
          "ens3"
          ethernet (virtio_net), 52:54:00:12:34:56, hw, mtu 1500
          ip4 default, ip6 default
          inet4 10.0.2.15/24
          route4 0.0.0.0/0
          route4 10.0.2.0/24
          inet6 fec0::5054:ff:fe12:3456/64
          inet6 fe80::5054:ff:fe12:3456/64
          route6 fe80::/64
          route6 ::/0
          route6 fec0::/64

  br54: connecting (getting IP configuration) to netplan-br54
          "br54"
          bridge, 12:E6:74:FA:8A:75, sw, mtu 1500

  lo: unmanaged
          "lo"
          loopback (unknown), 00:00:00:00:00:00, sw, mtu 65536

  DNS configuration:
          servers: 10.0.2.3
          interface: ens3

  [ Test Plan 2 "Classic" ]

  # Prepare environment with NetworkManager installed and the 'nmcli' binary moved to /snap/bin/nmcli  (outside of PATH and outside of Python's default/fallback BINDIR).
  $ apt install network-manager
  $ mv /usr/bin/nmcli /snap/bin/nmcli

  $ netplan get
  network:
    version: 2
    ethernets:
      eth0:
        dhcp4: true
  $ netplan set network.renderer=NetworkManager # change global renderer to NM
  $ netplan set network.bridges.br54.addresses=[10.0.0.20/24]
  $ netplan get
  network:
    version: 2
    renderer: NetworkManager
    ethernets:
      eth0:
        dhcp4: true
    bridges:
      br54:
        addresses:
        - "10.0.0.20/24"
  $ env -u PATH /usr/sbin/netplan try # Try-Apply the configuration

  => This should NOT crash!
  => Check that the "netplan-br54" connection is "connected" and the "br54" got created correctly with IP address 10.0.0.20/24:

  $ /snap/bin/nmcli d show br54
  GENERAL.DEVICE:                         br54
  GENERAL.TYPE:                           bridge
  GENERAL.HWADDR:                         6E:70:F7:76:39:67
  GENERAL.MTU:                            1500
  GENERAL.STATE:                          100 (connected)
  GENERAL.CONNECTION:                     netplan-br54
  GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/ActiveConnection/2
  IP4.ADDRESS[1]:                         10.0.0.20/24
  IP4.GATEWAY:                            --
  IP4.ROUTE[1]:                           dst = 10.0.0.0/24, nh = 0.0.0.0, mt = 425
  $ ip addr show  br54
  5: br54: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
      link/ether 6e:70:f7:76:39:67 brd ff:ff:ff:ff:ff:ff
      inet 10.0.0.20/24 brd 10.0.0.255 scope global noprefixroute br54
         valid_lft forever preferred_lft forever

  # Running a similar test through 'netplan-dbus'
  $ killall netplan-dbus
  $ env -u PATH /usr/lib/netplan/netplan-dbus &
  $ busctl call io.netplan.Netplan /io/netplan/Netplan io.netplan.Netplan Config
  o "/io/netplan/Netplan/config/UV0ID2"
  $ busctl call io.netplan.Netplan /io/netplan/Netplan/config/UV0ID2 io.netplan.Netplan.Config Try u 120
  b true
  $ busctl call io.netplan.Netplan /io/netplan/Netplan/config/UV0ID2 io.netplan.Netplan.Config Apply
  b true

  => Make sure the 'netplan-dbus' binary did not crash.

  [ Where problems could occur ]

   * Netplan is a core component, thus changing it bears a high risk
   * This upload modifies Netplan's CLI only, therefor the system boot-up and initial network connection should not be affect if anything goes wrong.
   * Netplan's CLI could be affected, breaking the snapd integration (dbus-netplan) and CLI commands like "netplan apply"

  [ Other Info ]

   * This is addressed in Jammy via bug #2025519 (SRU/backport of 0.106.1)
   * This has been fixed upstream in https://github.com/canonical/netplan/pull/336
   * A test PPA is available here: https://launchpad.net/~slyon/+archive/ubuntu/lp1959570

  === original bug report ===

  When using the netplan-dbus API on Ubuntu Core and the network-manager
  renderer the "netplan-dbus" appication will crash. To reproduce take a
  UC20 or UC22 system and run:

  ```
  $ sudo snap set system system.network.netplan.network.bridges.br54.dhcp4=true
  ```
  (which in effect just drives the dbus API of netplan).

  After that the network is lost. When manually restarting it the error is:
  ```
  error: cannot perform the following tasks:
  - Run configure hook of "core" snap (run hook "configure": cannot try netplan config: no specific reason returned from netplan and cannot cancel netplan config: Unknown object '/io/netplan/Netplan/config/VDDSG1'.)
  ```

  and the journal reports:
  ```
  Jan 31 10:46:04 ubuntu sudo[1746]:      mvo : TTY=pts/0 ; PWD=/home/mvo ; USER=root ; COMMAND=/usr/bin/snap set system system.network.netplan.network.bridges.br54.dhcp4=true
  Jan 31 10:46:04 ubuntu sudo[1746]: pam_unix(sudo:session): session opened for user root(uid=0) by mvo(uid=1000)
  Jan 31 10:46:05 ubuntu io.netplan.Netplan[1763]: Traceback (most recent call last):
  Jan 31 10:46:05 ubuntu io.netplan.Netplan[1763]:   File "/usr/share/netplan/netplan/cli/commands/try_command.py", line 99, in command_try
  Jan 31 10:46:05 ubuntu io.netplan.Netplan[1763]:     NetplanApply().command_apply(run_generate=True, sync=True, exit_on_error=False, state_dir=self.state)
  Jan 31 10:46:05 ubuntu io.netplan.Netplan[1763]:   File "/usr/share/netplan/netplan/cli/commands/apply.py", line 272, in command_apply
  Jan 31 10:46:05 ubuntu io.netplan.Netplan[1763]:     if b'\nconnected' in subprocess.check_output(cmd, env=env):
  Jan 31 10:46:05 ubuntu io.netplan.Netplan[1763]:   File "/usr/lib/python3.9/subprocess.py", line 424, in check_output
  Jan 31 10:46:05 ubuntu io.netplan.Netplan[1763]:     return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  Jan 31 10:46:05 ubuntu io.netplan.Netplan[1763]:   File "/usr/lib/python3.9/subprocess.py", line 505, in run
  Jan 31 10:46:05 ubuntu io.netplan.Netplan[1763]:     with Popen(*popenargs, **kwargs) as process:
  Jan 31 10:46:05 ubuntu io.netplan.Netplan[1763]:   File "/usr/lib/python3.9/subprocess.py", line 951, in __init__
  Jan 31 10:46:05 ubuntu io.netplan.Netplan[1763]:     self._execute_child(args, executable, preexec_fn, close_fds,
  Jan 31 10:46:05 ubuntu io.netplan.Netplan[1763]:   File "/usr/lib/python3.9/subprocess.py", line 1821, in _execute_child
  Jan 31 10:46:05 ubuntu io.netplan.Netplan[1763]:     raise child_exception_type(errno_num, err_msg, err_filename)
  Jan 31 10:46:05 ubuntu io.netplan.Netplan[1763]: FileNotFoundError: [Errno 2] No such file or directory: 'nmcli'
  Jan 31 10:46:05 ubuntu io.netplan.Netplan[1763]: During handling of the above exception, another exception occurred:
  Jan 31 10:46:05 ubuntu io.netplan.Netplan[1763]: Traceback (most recent call last):
  Jan 31 10:46:05 ubuntu io.netplan.Netplan[1763]:   File "/usr/sbin/netplan", line 23, in <module>
  Jan 31 10:46:05 ubuntu io.netplan.Netplan[1763]:     netplan.main()
  Jan 31 10:46:05 ubuntu io.netplan.Netplan[1763]:   File "/usr/share/netplan/netplan/cli/core.py", line 50, in main
  Jan 31 10:46:05 ubuntu io.netplan.Netplan[1763]:     self.run_command()
  Jan 31 10:46:05 ubuntu io.netplan.Netplan[1763]:   File "/usr/share/netplan/netplan/cli/utils.py", line 315, in run_command
  Jan 31 10:46:05 ubuntu io.netplan.Netplan[1763]:     self.func()
  Jan 31 10:46:05 ubuntu io.netplan.Netplan[1763]:   File "/usr/share/netplan/netplan/cli/commands/try_command.py", line 81, in run
  Jan 31 10:46:05 ubuntu io.netplan.Netplan[1763]:     self.run_command()
  Jan 31 10:46:05 ubuntu io.netplan.Netplan[1763]:   File "/usr/share/netplan/netplan/cli/utils.py", line 315, in run_command
  Jan 31 10:46:05 ubuntu io.netplan.Netplan[1763]:     self.func()
  Jan 31 10:46:05 ubuntu io.netplan.Netplan[1763]:   File "/usr/share/netplan/netplan/cli/commands/try_command.py", line 113, in command_try
  Jan 31 10:46:05 ubuntu io.netplan.Netplan[1763]:     self.revert()
  Jan 31 10:46:05 ubuntu io.netplan.Netplan[1763]:   File "/usr/share/netplan/netplan/cli/commands/try_command.py", line 143, in revert
  Jan 31 10:46:05 ubuntu io.netplan.Netplan[1763]:     NetplanApply().command_apply(run_generate=False, sync=True, exit_on_error=False, state_dir=tempdir)
  Jan 31 10:46:05 ubuntu io.netplan.Netplan[1763]:   File "/usr/share/netplan/netplan/cli/commands/apply.py", line 272, in command_apply
  Jan 31 10:46:05 ubuntu io.netplan.Netplan[1763]:     if b'\nconnected' in subprocess.check_output(cmd, env=env):
  Jan 31 10:46:05 ubuntu io.netplan.Netplan[1763]:   File "/usr/lib/python3.9/subprocess.py", line 424, in check_output
  Jan 31 10:46:05 ubuntu io.netplan.Netplan[1763]:     return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  Jan 31 10:46:05 ubuntu io.netplan.Netplan[1763]:   File "/usr/lib/python3.9/subprocess.py", line 505, in run
  Jan 31 10:46:05 ubuntu io.netplan.Netplan[1763]:     with Popen(*popenargs, **kwargs) as process:
  Jan 31 10:46:05 ubuntu io.netplan.Netplan[1763]:   File "/usr/lib/python3.9/subprocess.py", line 951, in __init__
  Jan 31 10:46:05 ubuntu io.netplan.Netplan[1763]:     self._execute_child(args, executable, preexec_fn, close_fds,
  Jan 31 10:46:05 ubuntu io.netplan.Netplan[1763]:   File "/usr/lib/python3.9/subprocess.py", line 1821, in _execute_child
  Jan 31 10:46:05 ubuntu io.netplan.Netplan[1763]:     raise child_exception_type(errno_num, err_msg, err_filename)
  Jan 31 10:46:05 ubuntu io.netplan.Netplan[1763]: FileNotFoundError: [Errno 2] No such file or directory: 'nmcli'
  Jan 31 10:46:10 ubuntu io.netplan.Netplan[884]: 'netplan try' exited with status: 0
  Jan 31 10:46:10 ubuntu snapd[605]: taskrunner.go:271: [change 13 "Run configure hook of \"core\" snap" task] failed: run hook "configure": cannot try netplan config: no specific reason returned from netplan and cannot cancel netplan config: Unknown object '/io/netplan/Netplan/config/LX32G1'.
  ```

  The full journal log is attached.

  I guess it's a bit the question if this is a netplan or a nm-snap bug
  (it might need to provide an nmcli alias?). But in any case the crash
  and losing network is worth fixing regardless I think.

  Fwiw, I also suspect this is the issue that prevents my spread tests
  in https://github.com/snapcore/snapd/compare/master...mvo5:netplan-
  read-write-nm?expand=1 from working.

To manage notifications about this bug go to:
https://bugs.launchpad.net/netplan/+bug/1959570/+subscriptions




More information about the foundations-bugs mailing list