]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: config: support "all" and "none" on "tune.defaults.purge"
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 6 Aug 2026 07:20:29 +0000 (09:20 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 6 Aug 2026 07:40:47 +0000 (09:40 +0200)
Extends "tune.defaults.purge" to support new arguments value. The values
"all" is equivalent to "proxies,servers".

The value "none" instructs to preserve all instances, which is similar
to the default behavior when the keyword is absent. It is added mainly
to simplify configuration by external APIs.

Both these values are exclusive : they cannot be mixed into the
comma-delimited list of tokens.

doc/configuration.txt
src/cfgparse-global.c

index 270fe5b78ccddf6ea7b38c9dfb2d76a36b6f6dca..0656a778394e72552ac7f7a4e3de2cca95cdb517 100644 (file)
@@ -4225,16 +4225,9 @@ tune.comp.maxlevel <number>
   Each stream using compression initializes the compression algorithm with
   this value. The default value is 1.
 
-tune.defaults.purge [<element[,...]>]
+tune.defaults.purge [{ all | none | <element[,...]> }]
   Define what default instances to purge after configuration parsing.
 
-  The elements to be purged are defined by a comma-delimited list of tokens.
-  The currently supported entries are :
-    - "proxies" to purge "defaults" sections
-    - "servers" to purge "default-server" instances
-
-  If the list is empty, only proxies "defaults" sections will be purged.
-
   Default-server instances are kept in memory after parsing as they may be
   reused for dynamic servers added at runtime. Similarly, named defaults
   proxies sections are preserved as dynamic backends rely on them. The command
@@ -4248,8 +4241,22 @@ tune.defaults.purge [<element[,...]>]
   cannot be copied by their referencing proxies (e.g. TCP/HTTP rules or
   tcpcheck ruleset) will be preserved, regardless of the global purge setting.
 
+  Here are the values supported as argument :
+  - "all" to purge "defaults" sections and "default-server" instances
+  - "none" to keep these elements, which is also the default behavior when the
+    setting is absent
+
+  Alternatively, a comma-delimited list of tokens can be used for fine-grained
+  control. The currently supported entries are :
+    - "proxies" to purge "defaults" sections
+    - "servers" to purge "default-server" instances
+
+  If no argument is specified, only proxies "defaults" sections will be purged.
+
   Example:
       # reclaim the maximum memory possible
+      # both syntax are equivalent
+      tune.defaults.purge all
       tune.defaults.purge proxies,servers
 
       # purge proxies defaults sections
index e0b12f29e24e3763f49132b349ed9c41354d2c0d..d2eb94b7d855ae63923e9d12ba6c1d63870bc248 100644 (file)
@@ -1435,20 +1435,35 @@ static int cfg_parse_global_tune_opts(char **args, int section_type,
        else if (strcmp(args[0], "tune.defaults.purge") == 0) {
                if (args[1]) {
                        struct ist arg = ist(args[1]);
-                       do {
-                               struct ist token = istsplit(&arg, ',');
+                       /* First check exclusive values "all" and "none". */
+                       if (isteq(arg, ist("all"))) {
+                               global.tune.options |= GTUNE_PURGE_DEFAULTS|GTUNE_PURGE_DEF_SRV;
+                       }
+                       else if (isteq(arg, ist("none"))) {
+                               global.tune.options &= ~(GTUNE_PURGE_DEFAULTS|GTUNE_PURGE_DEF_SRV);
+                       }
+                       else {
+                               /* Treat argument value as a comma separated list. */
+                               do {
+                                       struct ist token = istsplit(&arg, ',');
 
-                               if (isteq(token, ist("proxies"))) {
-                                       global.tune.options |= GTUNE_PURGE_DEFAULTS;
-                               }
-                               else if (isteq(token, ist("servers"))) {
-                                       global.tune.options |= GTUNE_PURGE_DEF_SRV;
-                               }
-                               else {
-                                       memprintf(err, "'%s' unknown directive '%s'.", args[0], ist0(token));
-                                       return -1;
-                               }
-                       } while (istlen(arg));
+                                       if (isteq(token, ist("proxies"))) {
+                                               global.tune.options |= GTUNE_PURGE_DEFAULTS;
+                                       }
+                                       else if (isteq(token, ist("servers"))) {
+                                               global.tune.options |= GTUNE_PURGE_DEF_SRV;
+                                       }
+                                       else if (isteq(token, ist("all")) ||
+                                                isteq(token, ist("none"))) {
+                                               memprintf(err, "'%s' value '%s' is exclusive.", args[0], ist0(token));
+                                               return -1;
+                                       }
+                                       else {
+                                               memprintf(err, "'%s' unknown directive '%s'.", args[0], ist0(token));
+                                               return -1;
+                                       }
+                               } while (istlen(arg));
+                       }
                }
                else {
                        /* default value if no argument : purge defaults proxies. */