"//" at beginning of YAML file path when error in network config found

Bug #1771440 reported by Eric Desrochers on 2018-05-15
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
netplan
Medium
Eric Desrochers
netplan.io (Ubuntu)
Medium
Unassigned
Bionic
Undecided
Unassigned

Bug Description

[Impact]
When performing "netplan try" or "netplan apply" on a network configuration with errors, netplan error out a message as follow :

$ netplan try
---------------------
Error in network definition //etc/netplan/50-cloud-init.yaml line 6 column 4: unknown key xversion

An error occured: the configuration could not be generated
---------------------

$ netplan apply
---------------------
Error in network definition //etc/netplan/50-cloud-init.yaml line 6 column 4: unknown key xversion
---------------------

[Explanation]
While debugging the situation a little more I found out that it seems to come from here:

# src/generate.c
---------------------
g_autofree char* glob_etc = g_strjoin(NULL, rootdir ?: "", G_DIR_SEPARATOR_S, "/etc/netplan/*.yaml", NULL);
g_autofree char* glob_run = g_strjoin(NULL, rootdir ?: "", G_DIR_SEPARATOR_S, "/run/netplan/*.yaml", NULL);
g_autofree char* glob_lib = g_strjoin(NULL, rootdir ?: "", G_DIR_SEPARATOR_S, "/lib/netplan/*.yaml", NULL);
---------------------

To prove my theory, as a debug exercise, I have modified netplan code to g_fprint() the variable when the above commands are executed:

$ netplan apply
---------------------
glob_etc://etc/netplan/*.yaml
glob_run://run/netplan/*.yaml
glob_lib://lib/netplan/*.yaml
Error in network definition //etc/netplan/50-cloud-init.yaml line 6 column 4: unknown key xversion
---------------------

$ netplan try
---------------------
glob_etc://etc/netplan/*.yaml
glob_run://run/netplan/*.yaml
glob_lib://lib/netplan/*.yaml
Error in network definition //etc/netplan/50-cloud-init.yaml line 6 column 4: unknown key xversion

An error occured: the configuration could not be generated
---------------------

Further more investigation revealed that the double slash "//" is added by the combination of G_DIR_SEPARATOR_S "/" and "/etc/netplan/*.yaml" joined together with g_strjoin()

# netplan try
---------------------
rootdir:(null)
G_DIR_SEPARATOR_S:/
glob_etc://etc/netplan/*.yaml
Error in network definition //etc/netplan/50-cloud-init.yaml line 6 column 4: unknown key xversion

An error occured: the configuration could not be generated
---------------------

[Test Case]
1) Have netplan installed & configured
2) Do a typo in your network definition on purpose (above situation I change "version" for "xversion" to force the error to be displayed
3) Perform "netplan try" and/or "netplan apply"

The following output will be displayed:
"Error in network definition //etc/netplan/50-cloud-init.yaml line 6 column 4: unknown key xversion"

Ideally the output should look like this :
"Error in network definition /etc/netplan/50-cloud-init.yaml line 6 column 4: unknown key xversion"

With only 1 "/" instead of 2 "//".

[Regression Potential]
Regression low.

For some reasons it seems like multiples slashes can be handle without problem. Functionality-wise, nothing will be change. Simply that the file path will be treated with only 1 "/".

Example:
$ ls -altr /////////tmp/test
-rwxr-xr-x 1 user group 8392 May 15 18:14 /////////tmp/test

$ ls -altr /tmp/test
-rwxr-xr-x 1 user group 8392 May 15 18:14 /tmp/test

[Other info]
https://developer.gnome.org/glib/stable/glib-Standard-Macros.html#G-DIR-SEPARATOR-S:CAPS
https://developer.gnome.org/glib/stable/glib-String-Utility-Functions.html#g-strjoin

Eric Desrochers (slashd) on 2018-05-15
description: updated
Eric Desrochers (slashd) on 2018-05-15
description: updated
description: updated
Eric Desrochers (slashd) on 2018-05-15
description: updated
description: updated
Eric Desrochers (slashd) on 2018-05-15
Changed in netplan:
assignee: nobody → Eric Desrochers (slashd)
Eric Desrochers (slashd) on 2018-05-15
description: updated
description: updated
description: updated
Eric Desrochers (slashd) on 2018-05-16
Changed in netplan:
status: New → In Progress
Eric Desrochers (slashd) on 2018-05-28
Changed in netplan:
status: In Progress → Fix Committed
Changed in netplan.io (Ubuntu):
status: New → In Progress
importance: Undecided → Medium
status: In Progress → Triaged
Changed in netplan:
importance: Undecided → Medium
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: Triaged → Fix Released
Changed in netplan:
status: Fix Committed → Fix Released

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: New → 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

Setting verification-done:

I have verified that error messages for 'netplan apply' or 'netplan try' now correctly display error messages without the duplicate / in paths:

ubuntu@new-man:~$ sudo netplan apply
Error in network definition /etc/netplan/50-cloud-init.yaml line 6 column 4: unknown key xversion

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.

Other bug subscribers