netplan ip leases <interface> traceback when interface not managed by netplan or set to DHCP

Bug #1768823 reported by Eric Desrochers on 2018-05-03
52
This bug affects 8 people
Affects Status Importance Assigned to Milestone
netplan
Undecided
Unassigned
netplan.io (Ubuntu)
Medium
Unassigned
Bionic
Undecided
Unassigned

Bug Description

[Impact]
"netplan ip leases <interface>" command is failing with a Traceback[1] when specifying an interface non-existing on the system. non-dhcp configured or non configured with netplan.

[1] $ netplan ip leases eth1

Traceback (most recent call last):
  File "/usr/sbin/netplan", line 23, in <module>
    netplan.main()
  File "/usr/share/netplan/netplan/cli/core.py", line 50, in main
    self.run_command()
  File "/usr/share/netplan/netplan/cli/utils.py", line 130, in run_command
    self.func()
  File "/usr/share/netplan/netplan/cli/commands/ip.py", line 56, in run
    self.run_command()
  File "/usr/share/netplan/netplan/cli/utils.py", line 130, in run_command
    self.func()
  File "/usr/share/netplan/netplan/cli/commands/ip.py", line 75, in run
    self.run_command()
  File "/usr/share/netplan/netplan/cli/utils.py", line 130, in run_command
    self.func()
  File "/usr/share/netplan/netplan/cli/commands/ip.py", line 142, in command_ip_leases
    out = subprocess.check_output(argv, universal_newlines=True)
  File "/usr/lib/python3.6/subprocess.py", line 336, in check_output
    **kwargs).stdout
  File "/usr/lib/python3.6/subprocess.py", line 418, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['/lib/netplan/generate', '--mapping', 'eth1']' returned non-zero exit status 1.

[Test Case]

* Performed the command "netplan ip leases <INTERFACE>" on a Bionic/18.04 LTS system with netplan installed. If interface is non-existent, not configured in netplan or not set to DHCP, it will generate a Traceback[1] instead of displaying an error message with some explanation as of why it fails.

Otherwise it will succeed as follow :

$ netplan ip leases eth0

# This is private data. Do not parse.
ADDRESS=10.104.180.111
NETMASK=255.255.255.0
ROUTER=10.104.180.1
SERVER_ADDRESS=10.104.180.1
NEXT_SERVER=10.104.180.1
BROADCAST=10.104.180.255
T1=1673
T2=3023
LIFETIME=3600
DNS=10.104.180.1
DOMAINNAME=lxd
HOSTNAME=nplan
CLIENTID=ffefc0b3c900020000ab118611d41fefa41121

[Regression Potential]
'netplan ip leases' is used as informational only, so failures with it should be considered a low priority issue. Nevertheless, failures to properly parse the data from the networking backends, experienced as tracebacks (like the one this is supposed to fix) or as invalid data / incomplete data being shown on screen should be investigated as potential regressions.

[Other Info]

 * Netplan PR:
   - https://github.com/CanonicalLtd/netplan/pull/25

The above PR will output "Interface <INTERFACE> is not managed by netplan or not configured for DHCP"

Example:

$ 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
45: eth0@if46: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 00:16:3e:91:0d:24 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 10.104.180.139/24 brd 10.104.180.255 scope global dynamic eth0
       valid_lft 3422sec preferred_lft 3422sec
    inet6 fd42:ad0:706e:4129:216:3eff:fe91:d24/64 scope global dynamic mngtmpaddr noprefixroute
       valid_lft 3497sec preferred_lft 3497sec
    inet6 fe80::216:3eff:fe91:d24/64 scope link
       valid_lft forever preferred_lft forever

$ netplan ip leases eth1
Interface eth1 is not managed by netplan or not configured for DHCP

$ netplan ip leases eth2
Interface eth2 is not managed by netplan or not configured for DHCP

$ netplan ip leases eth0
# This is private data. Do not parse.
ADDRESS=10.104.180.139
NETMASK=255.255.255.0
ROUTER=10.104.180.1
SERVER_ADDRESS=10.104.180.1
NEXT_SERVER=10.104.180.1
BROADCAST=10.104.180.255
T1=1800
T2=3150
LIFETIME=3600
DNS=10.104.180.1
DOMAINNAME=lxd
HOSTNAME=nplan8bionic
CLIENTID=ffb1e17c0e00020000ab11ab1476591f0e77eb

Eric Desrochers (slashd) on 2018-05-03
description: updated
Eric Desrochers (slashd) on 2018-05-04
description: updated
Ryan Harper (raharper) on 2018-05-08
Changed in netplan.io (Ubuntu):
importance: Undecided → Medium
status: New → Confirmed
Eric Desrochers (slashd) on 2018-05-10
summary: - netplan ip leases <interface>
+ netplan ip leases <interface> traceback when interface not managed by
+ netplan or set to DHCP
description: updated
Eric Desrochers (slashd) on 2018-05-10
description: updated
Eric Desrochers (slashd) on 2018-05-10
description: updated
Eric Desrochers (slashd) on 2018-05-16
Changed in netplan:
assignee: nobody → Eric Desrochers (slashd)
status: New → In Progress
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in netplan.io (Ubuntu Bionic):
status: New → Confirmed
Eric Desrochers (slashd) on 2018-05-28
Changed in netplan:
status: In Progress → Fix Committed
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package netplan.io - 0.38

---------------
netplan.io (0.38) cosmic; urgency=medium

  * New upstream release:
    - Write udev .rules files to /run/udev/rules.d to enforce interface
      renaming. (LP: #1770082)
    - Don't traceback for 'netplan ip leases' when iface is not managed or
      doesn't DHCP (LP: #1768823)
    - Fix duplicate "/" path separator in error messages (LP: #1771440)
    - Fix incorrect terminal reset in 'netplan try' on Ctrl-C. (LP: #1768798)
    - Updated doc entries: mtu, fix fwmark->mark, cleanup optional.
      (LP: #1768783)
    - Added documentation validation at build.
    - Added configuration example for multi-ip interfaces.
  * tests/integration.py: fix test_eth_and_bridge autopkg test harder.
  * debian/control:
    - Add iproute2 to Depends.
    - Add python3-netifaces to Depends, Build-Depends.

 -- Mathieu Trudel-Lapierre <email address hidden> Mon, 04 Jun 2018 14:45:26 -0400

Changed in netplan.io (Ubuntu):
status: Confirmed → Fix Released
mkurz (matthias.kurz) wrote :

Please backport the fix to bionic. It's very annoying. Thank you!

description: updated
Changed in netplan:
status: Fix Committed → Fix Released
assignee: Eric Desrochers (slashd) → nobody

Hello Eric, or anyone else affected,

Accepted netplan.io into bionic-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/netplan.io/0.40~18.04.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested and change the tag from verification-needed-bionic to verification-done-bionic. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-bionic. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Changed in netplan.io (Ubuntu Bionic):
status: Confirmed → Fix Committed
tags: added: verification-needed verification-needed-bionic
Łukasz Zemczak (sil2100) wrote :

Hello Eric, or anyone else affected,

Accepted netplan.io into bionic-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/netplan.io/0.40.1~18.04.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested and change the tag from verification-needed-bionic to verification-done-bionic. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-bionic. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

ubuntu@new-man:~$ dpkg -l netplan.io | grep ii
ii netplan.io 0.40.1~18.04.1 amd64 YAML network configuration abstraction for various backends

Verification-done:

netplan now correctly reports either nothing at all (if the interface does not exist on the system), or a meaningful error message that there is no lease for the interface (in the event it is not managed by DHCP):

ubuntu@new-man:~$ netplan ip leases eth0
ubuntu@new-man:~$ netplan ip leases eth9
ubuntu@new-man:~$ ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: ens6: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
    link/ether 52:54:00:ab:37:d8 brd ff:ff:ff:ff:ff:ff
ubuntu@new-man:~$ netplan ip leases ens6
No lease found for interface 'ens6': [Errno 2] No such file or directory: '/run/systemd/netif/leases/2'

Works for DHCP-managed interfaces as well:

ubuntu@new-man:~$ netplan ip leases ens6
# This is private data. Do not parse.
ADDRESS=10.3.21.28
NETMASK=255.255.240.0
ROUTER=10.3.16.1
SERVER_ADDRESS=10.3.21.25
NEXT_SERVER=10.3.21.25
T1=300
T2=525
LIFETIME=600
DNS=10.3.21.25
NTP=10.3.21.25
DOMAINNAME=cloud.cyphermox.net
CLIENTID=ff6618dd4200020000ab11a9b91276f681b0c8

tags: added: verification-done-bionic
removed: verification-needed verification-needed-bionic
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers