Unverified Commit 25af2ac7 by Christian Brauner Committed by Stéphane Graber

confile: make update warning opt-in

With the release LXC 2.1 we started warning users who use LXC through the API and users who use LXC through the tools equally about updating their config. This quickly got confusing and annoying to API users who e.g. generate configs on the fly (e.g. LXD). So instead of unconditionally warning users we make this opt-in. If LXC detects that the env variable LXC_UPDATE_CONFIG_FORMAT is set then it will warn the user if any legacy configuration keys are present. If it is not set however, it will not warn the user. This is ok, since the log will still log WARN()s for all legacy configuration keys. The tools will all set LXC_UPDATE_CONFIG_FORMAT since it is very much required that users update to the new configuration format pre-LXC 3.0. Signed-off-by: 's avatarChristian Brauner <christian.brauner@ubuntu.com>
parent 085efe8f
...@@ -1998,13 +1998,15 @@ static int parse_line(char *buffer, void *data) ...@@ -1998,13 +1998,15 @@ static int parse_line(char *buffer, void *data)
/* [START]: REMOVE IN LXC 3.0 */ /* [START]: REMOVE IN LXC 3.0 */
if (config->is_legacy_key && !plc->conf->contains_legacy_key) { if (config->is_legacy_key && !plc->conf->contains_legacy_key) {
plc->conf->contains_legacy_key = true; plc->conf->contains_legacy_key = true;
/* Warn the user once loud and clear that there is at least one if (getenv("LXC_UPDATE_CONFIG_FORMAT")) {
* legacy configuration item in the configuration file and then /* Warn the user once loud and clear that there is at
* an update is required. * least one legacy configuration item in the
*/ * configuration file and then an update is required.
fprintf(stderr, "The configuration file contains legacy " */
"configuration keys.\nPlease update your " fprintf(stderr, "The configuration file contains "
"configuration file!\n"); "legacy configuration keys.\nPlease "
"update your configuration file!\n");
}
} }
/* [END]: REMOVE IN LXC 3.0 */ /* [END]: REMOVE IN LXC 3.0 */
......
...@@ -406,6 +406,9 @@ int main(int argc, char *argv[]) ...@@ -406,6 +406,9 @@ int main(int argc, char *argv[])
} }
} }
/* REMOVE IN LXC 3.0 */
setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0);
struct lxc_container *c = lxc_container_new(my_args.name, my_args.lxcpath[0]); struct lxc_container *c = lxc_container_new(my_args.name, my_args.lxcpath[0]);
if (!c) if (!c)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
......
...@@ -368,6 +368,9 @@ int main(int argc, char *argv[]) ...@@ -368,6 +368,9 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
lxc_log_options_no_override(); lxc_log_options_no_override();
/* REMOVE IN LXC 3.0 */
setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0);
count = list_defined_containers(my_args.lxcpath[0], NULL, &containers); count = list_defined_containers(my_args.lxcpath[0], NULL, &containers);
if (count < 0) if (count < 0)
......
...@@ -21,16 +21,17 @@ ...@@ -21,16 +21,17 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#include <libgen.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <libgen.h>
#include <sys/types.h> #include <sys/types.h>
#include <lxc/lxccontainer.h> #include <lxc/lxccontainer.h>
#include "lxc.h"
#include "log.h"
#include "arguments.h" #include "arguments.h"
#include "log.h"
#include "lxc.h"
lxc_log_define(lxc_cgroup_ui, lxc); lxc_log_define(lxc_cgroup_ui, lxc);
...@@ -86,6 +87,9 @@ int main(int argc, char *argv[]) ...@@ -86,6 +87,9 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
lxc_log_options_no_override(); lxc_log_options_no_override();
/* REMOVE IN LXC 3.0 */
setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0);
state_object = my_args.argv[0]; state_object = my_args.argv[0];
c = lxc_container_new(my_args.name, my_args.lxcpath[0]); c = lxc_container_new(my_args.name, my_args.lxcpath[0]);
......
...@@ -255,6 +255,9 @@ int main(int argc, char *argv[]) ...@@ -255,6 +255,9 @@ int main(int argc, char *argv[])
lxc_log_options_no_override(); lxc_log_options_no_override();
/* REMOVE IN LXC 3.0 */
setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0);
c = lxc_container_new(my_args.name, my_args.lxcpath[0]); c = lxc_container_new(my_args.name, my_args.lxcpath[0]);
if (!c) { if (!c) {
fprintf(stderr, "System error loading %s\n", my_args.name); fprintf(stderr, "System error loading %s\n", my_args.name);
......
...@@ -176,6 +176,8 @@ int main(int argc, char *argv[]) ...@@ -176,6 +176,8 @@ int main(int argc, char *argv[])
usage(argv[0]); usage(argv[0]);
} }
setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0);
c1 = lxc_container_new(orig, lxcpath); c1 = lxc_container_new(orig, lxcpath);
if (!c1) if (!c1)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
......
...@@ -62,6 +62,8 @@ int main(int argc, char *argv[]) ...@@ -62,6 +62,8 @@ int main(int argc, char *argv[])
struct lxc_config_items *i; struct lxc_config_items *i;
const char *value; const char *value;
setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0);
if (argc < 2) if (argc < 2)
usage(argv[0]); usage(argv[0]);
if (strcmp(argv[1], "-l") == 0) if (strcmp(argv[1], "-l") == 0)
......
...@@ -119,6 +119,9 @@ int main(int argc, char *argv[]) ...@@ -119,6 +119,9 @@ int main(int argc, char *argv[])
return EXIT_FAILURE; return EXIT_FAILURE;
lxc_log_options_no_override(); lxc_log_options_no_override();
/* REMOVE IN LXC 3.0 */
setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0);
c = lxc_container_new(my_args.name, my_args.lxcpath[0]); c = lxc_container_new(my_args.name, my_args.lxcpath[0]);
if (!c) { if (!c) {
fprintf(stderr, "System error loading container\n"); fprintf(stderr, "System error loading container\n");
......
...@@ -190,6 +190,9 @@ int main(int argc, char *argv[]) ...@@ -190,6 +190,9 @@ int main(int argc, char *argv[])
exit(ret); exit(ret);
lxc_log_options_no_override(); lxc_log_options_no_override();
/* REMOVE IN LXC 3.0 */
setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0);
if (geteuid()) { if (geteuid()) {
if (access(my_args.lxcpath[0], O_RDONLY) < 0) { if (access(my_args.lxcpath[0], O_RDONLY) < 0) {
if (!my_args.quiet) if (!my_args.quiet)
......
...@@ -229,6 +229,9 @@ int main(int argc, char *argv[]) ...@@ -229,6 +229,9 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
lxc_log_options_no_override(); lxc_log_options_no_override();
/* REMOVE IN LXC 3.0 */
setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0);
if (!my_args.template) { if (!my_args.template) {
fprintf(stderr, "A template must be specified.\n"); fprintf(stderr, "A template must be specified.\n");
fprintf(stderr, "Use \"none\" if you really want a container without a rootfs.\n"); fprintf(stderr, "Use \"none\" if you really want a container without a rootfs.\n");
......
...@@ -89,6 +89,9 @@ int main(int argc, char *argv[]) ...@@ -89,6 +89,9 @@ int main(int argc, char *argv[])
if (my_args.quiet) if (my_args.quiet)
quiet = true; quiet = true;
/* REMOVE IN LXC 3.0 */
setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0);
c = lxc_container_new(my_args.name, my_args.lxcpath[0]); c = lxc_container_new(my_args.name, my_args.lxcpath[0]);
if (!c) { if (!c) {
if (!quiet) if (!quiet)
...@@ -278,4 +281,3 @@ static bool do_destroy_with_snapshots(struct lxc_container *c) ...@@ -278,4 +281,3 @@ static bool do_destroy_with_snapshots(struct lxc_container *c)
return bret; return bret;
} }
...@@ -127,6 +127,9 @@ int main(int argc, char *argv[]) ...@@ -127,6 +127,9 @@ int main(int argc, char *argv[])
goto err; goto err;
lxc_log_options_no_override(); lxc_log_options_no_override();
/* REMOVE IN LXC 3.0 */
setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0);
c = lxc_container_new(my_args.name, my_args.lxcpath[0]); c = lxc_container_new(my_args.name, my_args.lxcpath[0]);
if (!c) { if (!c) {
ERROR("%s doesn't exist", my_args.name); ERROR("%s doesn't exist", my_args.name);
......
...@@ -129,6 +129,9 @@ int main(int argc, char *argv[]) ...@@ -129,6 +129,9 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
lxc_log_options_no_override(); lxc_log_options_no_override();
/* REMOVE IN LXC 3.0 */
setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0);
c = lxc_container_new(my_args.name, my_args.lxcpath[0]); c = lxc_container_new(my_args.name, my_args.lxcpath[0]);
if (!c) { if (!c) {
ERROR("Failed to create lxc_container"); ERROR("Failed to create lxc_container");
......
...@@ -76,6 +76,9 @@ int main(int argc, char *argv[]) ...@@ -76,6 +76,9 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
lxc_log_options_no_override(); lxc_log_options_no_override();
/* REMOVE IN LXC 3.0 */
setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0);
c = lxc_container_new(my_args.name, my_args.lxcpath[0]); c = lxc_container_new(my_args.name, my_args.lxcpath[0]);
if (!c) { if (!c) {
ERROR("No such container: %s:%s", my_args.lxcpath[0], my_args.name); ERROR("No such container: %s:%s", my_args.lxcpath[0], my_args.name);
......
...@@ -413,6 +413,9 @@ int main(int argc, char *argv[]) ...@@ -413,6 +413,9 @@ int main(int argc, char *argv[])
exit(ret); exit(ret);
lxc_log_options_no_override(); lxc_log_options_no_override();
/* REMOVE IN LXC 3.0 */
setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0);
if (print_info(my_args.name, my_args.lxcpath[0]) == 0) if (print_info(my_args.name, my_args.lxcpath[0]) == 0)
ret = EXIT_SUCCESS; ret = EXIT_SUCCESS;
......
...@@ -233,6 +233,9 @@ int main(int argc, char *argv[]) ...@@ -233,6 +233,9 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
lxc_log_options_no_override(); lxc_log_options_no_override();
/* REMOVE IN LXC 3.0 */
setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0);
struct lengths max_len = { struct lengths max_len = {
/* default header length */ /* default header length */
.name_length = 4, /* NAME */ .name_length = 4, /* NAME */
......
...@@ -113,6 +113,9 @@ int main(int argc, char *argv[]) ...@@ -113,6 +113,9 @@ int main(int argc, char *argv[])
exit(rc_main); exit(rc_main);
lxc_log_options_no_override(); lxc_log_options_no_override();
/* REMOVE IN LXC 3.0 */
setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0);
if (quit_monitord) { if (quit_monitord) {
int ret = EXIT_SUCCESS; int ret = EXIT_SUCCESS;
for (i = 0; i < my_args.lxcpath_cnt; i++) { for (i = 0; i < my_args.lxcpath_cnt; i++) {
......
...@@ -101,6 +101,9 @@ int main(int argc, char *argv[]) ...@@ -101,6 +101,9 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
lxc_log_options_no_override(); lxc_log_options_no_override();
/* REMOVE IN LXC 3.0 */
setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0);
if (geteuid()) { if (geteuid()) {
if (access(my_args.lxcpath[0], O_RDONLY) < 0) { if (access(my_args.lxcpath[0], O_RDONLY) < 0) {
fprintf(stderr, "You lack access to %s\n", fprintf(stderr, "You lack access to %s\n",
...@@ -304,4 +307,3 @@ static void print_file(char *path) ...@@ -304,4 +307,3 @@ static void print_file(char *path)
free(line); free(line);
fclose(f); fclose(f);
} }
...@@ -241,6 +241,9 @@ int main(int argc, char *argv[]) ...@@ -241,6 +241,9 @@ int main(int argc, char *argv[])
const char *lxcpath = my_args.lxcpath[0]; const char *lxcpath = my_args.lxcpath[0];
/* REMOVE IN LXC 3.0 */
setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0);
/* /*
* rcfile possibilities: * rcfile possibilities:
* 1. rcfile from random path specified in cli option * 1. rcfile from random path specified in cli option
......
...@@ -173,6 +173,9 @@ int main(int argc, char *argv[]) ...@@ -173,6 +173,9 @@ int main(int argc, char *argv[])
exit(ret); exit(ret);
lxc_log_options_no_override(); lxc_log_options_no_override();
/* REMOVE IN LXC 3.0 */
setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0);
/* Set default timeout */ /* Set default timeout */
if (my_args.timeout == -2) { if (my_args.timeout == -2) {
if (my_args.hardstop) if (my_args.hardstop)
......
...@@ -75,6 +75,9 @@ int main(int argc, char *argv[]) ...@@ -75,6 +75,9 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
lxc_log_options_no_override(); lxc_log_options_no_override();
/* REMOVE IN LXC 3.0 */
setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0);
c = lxc_container_new(my_args.name, my_args.lxcpath[0]); c = lxc_container_new(my_args.name, my_args.lxcpath[0]);
if (!c) { if (!c) {
ERROR("No such container: %s:%s", my_args.lxcpath[0], my_args.name); ERROR("No such container: %s:%s", my_args.lxcpath[0], my_args.name);
......
...@@ -102,6 +102,9 @@ int main(int argc, char *argv[]) ...@@ -102,6 +102,9 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
lxc_log_options_no_override(); lxc_log_options_no_override();
/* REMOVE IN LXC 3.0 */
setenv("LXC_UPDATE_CONFIG_FORMAT", "1", 0);
c = lxc_container_new(my_args.name, my_args.lxcpath[0]); c = lxc_container_new(my_args.name, my_args.lxcpath[0]);
if (!c) if (!c)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment