netplan backported on bionic (0.40~18.04.1) crash when there is an empty YAML configuration file

Bug #1795343 reported by EOLE team on 2018-10-01
12
This bug affects 1 person
Affects Status Importance Assigned to Milestone
netplan
Undecided
Unassigned
netplan.io (Ubuntu)
Undecided
Unassigned
Bionic
Undecided
Unassigned

Bug Description

[Impact]
Any Netplan user leaving empty files in /etc/netplan.

[Test case]

1) put a valid configuration under /etc/netplan/
2) create an empty YAML file /etc/netplan/99-empty.yaml
3) execute netplan apply

Validate that 'netplan apply' does not crash, and correctly applies the configuration.

[Regression potential]
Watch out for issues in merging netplan configuration or evaluating the parts of configuration that can't be reverted safely, for the use of 'netplan try'.

---

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/apply.py", line 43, 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/apply.py", line 83, in command_apply
    config_manager.parse()
  File "/usr/share/netplan/netplan/configmanager.py", line 111, in parse
    self._merge_yaml_config(yaml_file)
  File "/usr/share/netplan/netplan/configmanager.py", line 197, in _merge_yaml_config
    network = yaml_data.get('network')
AttributeError: 'NoneType' object has no attribute 'get'
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 145, in apport_excepthook
    os.O_WRONLY | os.O_CREAT | os.O_EXCL, 0o640), 'wb') as f:
FileNotFoundError: [Errno 2] No such file or directory: '/var/crash/_usr_share_netplan_netplan.script.0.crash'

Original exception was:
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/apply.py", line 43, 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/apply.py", line 83, in command_apply
    config_manager.parse()
  File "/usr/share/netplan/netplan/configmanager.py", line 111, in parse
    self._merge_yaml_config(yaml_file)
  File "/usr/share/netplan/netplan/configmanager.py", line 197, in _merge_yaml_config
    network = yaml_data.get('network')
AttributeError: 'NoneType' object has no attribute 'get'

This is a regression with the previous version.

apt policy netplan.io
netplan.io:
  Installé : 0.40~18.04.1
  Candidat : 0.40~18.04.1
 Table de version :
 *** 0.40~18.04.1 500
        500 http://fr.archive.ubuntu.com/ubuntu bionic-proposed/main amd64 Packages
        100 /var/lib/dpkg/status
     0.36.3 500
        500 http://fr.archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages
     0.36.1 500
        500 http://fr.archive.ubuntu.com/ubuntu bionic/main amd64 Packages

Distributor ID: Ubuntu
Description: Ubuntu 18.04.1 LTS
Release: 18.04
Codename: bionic

EOLE team (eole-team) on 2018-10-01
description: updated
description: updated
Ryan Harper (raharper) wrote :

I can reproduce the failure as well after upgrading to netplan.io in proposed and touching /etc/netplan/99-empty.yaml

It does not fail prior to the upgrade.

Changed in netplan:
status: New → Confirmed

Hello EOLE, 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.

tags: added: verification-needed verification-needed-bionic
Changed in netplan.io (Ubuntu):
status: New → Fix Committed
Changed in netplan.io (Ubuntu Bionic):
status: New → Fix Committed
description: updated
Ryan Harper (raharper) wrote :

Tested 0.40.1 from -proposed; things look good here.

root@b1:~# ls -al /etc/netplan/
total 9
drwxr-xr-x 2 root root 4 Oct 4 20:29 .
drwxr-xr-x 87 root root 175 Oct 2 06:36 ..
-rw-r--r-- 1 root root 381 Oct 1 14:53 50-cloud-init.yaml
-rw-r--r-- 1 root root 0 Oct 1 15:16 99-empty.yaml
root@b1:~# apt-cache policy netplan.io
netplan.io:
  Installed: 0.40~18.04.1
  Candidate: 0.40.1~18.04.1
  Version table:
     0.40.1~18.04.1 500
        500 http://archive.ubuntu.com/ubuntu bionic-proposed/main amd64 Packages
 *** 0.40~18.04.1 100
        100 /var/lib/dpkg/status
     0.36.3 500
        500 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages
     0.36.1 500
        500 http://archive.ubuntu.com/ubuntu bionic/main amd64 Packages
root@b1:~# netplan apply
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/apply.py", line 43, 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/apply.py", line 83, in command_apply
    config_manager.parse()
  File "/usr/share/netplan/netplan/configmanager.py", line 111, in parse
    self._merge_yaml_config(yaml_file)
  File "/usr/share/netplan/netplan/configmanager.py", line 197, in _merge_yaml_config
    network = yaml_data.get('network')
AttributeError: 'NoneType' object has no attribute 'get'
root@b1:~# mv /etc/netplan/99-empty.yaml .
root@b1:~# apt install netplan.io
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
  libfreetype6
Use 'apt autoremove' to remove it.
Suggested packages:
  network-manager | wpasupplicant
The following packages will be upgraded:
  netplan.io
1 upgraded, 0 newly installed, 0 to remove and 45 not upgraded.
Need to get 63.8 kB of archives.
After this operation, 0 B of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu bionic-proposed/main amd64 netplan.io amd64 0.40.1~18.04.1 [63.8 kB]
Fetched 63.8 kB in 1s (108 kB/s)
(Reading database ... 28509 files and directories currently installed.)
Preparing to unpack .../netplan.io_0.40.1~18.04.1_amd64.deb ...
Unpacking netplan.io (0.40.1~18.04.1) over (0.40~18.04.1) ...
Setting up netplan.io (0.40.1~18.04.1) ...
Processing triggers for man-db (2.8.3-2) ...
root@b1:~# mv 99-empty.yaml /etc/netplan/
root@b1:~# netplan apply
root@b1:~# networkctl status
● State: routable
       Address: 10.8.107.180 on eth0
                fe80::216:3eff:fede:ccf1 on eth0
       Gateway: 10.8.107.1 on eth0
           DNS: 10.8.107.1
Search Domains: lxd

Launchpad Janitor (janitor) wrote :

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

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

  * tests/integration.py: Mark regexes with r to pacify pycodestyle's W605.

 -- Mathieu Trudel-Lapierre <email address hidden> Thu, 04 Oct 2018 16:02:53 -0400

Changed in netplan.io (Ubuntu):
status: Fix Committed → Fix Released

Marking verification-done based on Ryan's verification.

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

Other bug subscribers