diff mbox series

[lttng-tools] Fix: cmd line options overwrite env variable config options

Message ID 20180518214557.6933-1-jonathan.rajotte-julien@efficios.com
State Accepted, archived
Delegated to: Jérémie Galarneau
Headers show
Series [lttng-tools] Fix: cmd line options overwrite env variable config options | expand

Commit Message

Jonathan Rajotte May 18, 2018, 9:45 p.m. UTC
The doc is clear about the order of precedence regarding configuration.

The command line options always override any config file or
configuration by environment variables.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien at efficios.com>
---
 src/bin/lttng-sessiond/main.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Comments

Jérémie Galarneau May 26, 2018, 8:43 a.m. UTC | #1
Merged in master and stable-2.10 with a minor fix.

Thanks!
Jérémie


On 18 May 2018 at 17:45, Jonathan Rajotte <
jonathan.rajotte-julien at efficios.com> wrote:

> The doc is clear about the order of precedence regarding configuration.
>
> The command line options always override any config file or
> configuration by environment variables.
>
> Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien at efficios.com>
> ---
>  src/bin/lttng-sessiond/main.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c
> index 37c0a932..de8df2e0 100644
> --- a/src/bin/lttng-sessiond/main.c
> +++ b/src/bin/lttng-sessiond/main.c
> @@ -5775,6 +5775,12 @@ int main(int argc, char **argv)
>                 goto exit_set_signal_handler;
>         }
>
> +       /*
>

There's a trailing whitespace here ^.


> +        * Init config from environment variables.
> +        * Command line option override env configuration per-doc. Do env
> first.
> +        */
> +       sessiond_config_apply_env_config(&config);
> +
>         /*
>          * Parse arguments and load the daemon configuration file.
>          *
> @@ -5789,9 +5795,6 @@ int main(int argc, char **argv)
>                 goto exit_options;
>         }
>
> -       /* Init config from environment variables. */
> -       sessiond_config_apply_env_config(&config);
> -
>         /*
>          * Resolve all paths received as arguments, configuration option,
> or
>          * through environment variable as absolute paths. This is
> necessary
> --
> 2.17.0
>
>
diff mbox series

Patch

diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c
index 37c0a932..de8df2e0 100644
--- a/src/bin/lttng-sessiond/main.c
+++ b/src/bin/lttng-sessiond/main.c
@@ -5775,6 +5775,12 @@  int main(int argc, char **argv)
 		goto exit_set_signal_handler;
 	}
 
+	/* 
+	 * Init config from environment variables.
+	 * Command line option override env configuration per-doc. Do env first.
+	 */
+	sessiond_config_apply_env_config(&config);
+
 	/*
 	 * Parse arguments and load the daemon configuration file.
 	 *
@@ -5789,9 +5795,6 @@  int main(int argc, char **argv)
 		goto exit_options;
 	}
 
-	/* Init config from environment variables. */
-	sessiond_config_apply_env_config(&config);
-
 	/*
 	 * Resolve all paths received as arguments, configuration option, or
 	 * through environment variable as absolute paths. This is necessary