]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: cfgparse: call some parsers only in MODE_DISCOVERY
authorValentine Krasnobaeva <vkrasnobaeva@haproxy.com>
Tue, 1 Oct 2024 14:09:29 +0000 (16:09 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 16 Oct 2024 20:02:39 +0000 (22:02 +0200)
This commit is a part of the series to add a support of discovery mode in the
configuration parser and in initialization sequence.

Some keyword parsers tagged with KWF_DISCOVERY (for example those, which parse
runtime modes, poller types, pidfile), should not be called twice when
the configuration will be read the second time after the discovery mode.
It's redundant and could trigger parser's errors in standalone mode. In
master-worker mode the worker process inherits parsed settings from the master.

src/cfgparse-global.c
src/mworker.c

index 825bc4c9341d5cb0810ec9ebbcc31f27246b3531..87adf1b8928bfdfe4cf900d6a612df1de81b7626 100644 (file)
@@ -977,6 +977,9 @@ static int cfg_parse_global_master_worker(char **args, int section_type,
                                          struct proxy *curpx, const struct proxy *defpx,
                                          const char *file, int line, char **err)
 {
+       if (!(global.mode & MODE_DISCOVERY))
+               return 0;
+
        if (too_many_args(1, args, err, NULL))
                return -1;
 
@@ -999,6 +1002,9 @@ static int cfg_parse_global_mode(char **args, int section_type,
                                 struct proxy *curpx, const struct proxy *defpx,
                                 const char *file, int line, char **err)
 {
+       if (!(global.mode & MODE_DISCOVERY))
+               return 0;
+
        if (too_many_args(0, args, err, NULL))
                return -1;
 
@@ -1024,6 +1030,9 @@ static int cfg_parse_global_disable_poller(char **args, int section_type,
                                           struct proxy *curpx, const struct proxy *defpx,
                                           const char *file, int line, char **err)
 {
+       if (!(global.mode & MODE_DISCOVERY))
+               return 0;
+
        if (too_many_args(0, args, err, NULL))
                return -1;
 
@@ -1051,6 +1060,9 @@ static int cfg_parse_global_pidfile(char **args, int section_type,
                                    struct proxy *curpx, const struct proxy *defpx,
                                    const char *file, int line, char **err)
 {
+       if (!(global.mode & MODE_DISCOVERY))
+               return 0;
+
        if (too_many_args(1, args, err, NULL))
                return -1;
 
index 90caed279a17e9413050ce9a57abc61ab61ea026..c47625c7614c673b89b89b7a068157e24cafb79d 100644 (file)
@@ -751,6 +751,8 @@ static int mworker_parse_global_max_reloads(char **args, int section_type, struc
 {
 
        int err_code = 0;
+       if (!(global.mode & MODE_DISCOVERY))
+               return 0;
 
        if (alertif_too_many_args(1, file, linenum, args, &err_code))
                goto out;