Comment 0 for bug 1771440

Revision history for this message
Eric Desrochers (slashd) wrote :

When performing "netplan try" or "netplan apply" on a network configuration with errors, netplan error out and 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
---------------------

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

Modifying "src/generate.c" by as follow :
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);

remove the double slashes "//" :

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

$ 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

Obviously, more testing need to be done, but this indicate where the "//" come from.