[Bug 1771440] Re: "//" at beginning of YAML file path when error in network config found

Steve Langasek steve.langasek at canonical.com
Thu Nov 8 17:06:00 UTC 2018


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

-- 
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/1771440

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

Status in netplan:
  Fix Released
Status in netplan.io package in Ubuntu:
  Fix Released
Status in netplan.io source package in Bionic:
  Fix Committed

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

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



More information about the foundations-bugs mailing list