]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MAJOR: cfgparse: make sure server names are unique within a backend
authorWilly Tarreau <w@1wt.eu>
Mon, 23 Jun 2025 13:42:32 +0000 (15:42 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 23 Jun 2025 13:42:32 +0000 (15:42 +0200)
There was already a check for this but there used to be an exception
that allowed duplicate server names only in case where their IDs were
explicit and different. This has been emitting a warning since 3.1 and
planned for removal in 3.3, so let's do it now. The doc was updated,
though it never mentioned this unicity constraint, so that was added.

Only the check for the exception was removed, the rest of the code
that is currently made to deal with duplicate server names was not
cleaned yet (e.g. the tree doesn't need to support dups anymore, and
this could be done at insertion time). This may be a subject for future
cleanups.

doc/configuration.txt
src/cfgparse.c

index 74cd880985e65abca75cf14e9713989d6d1e1480..4dfd53bc248dd7d2c753d335a08a816531d2ae09 100644 (file)
@@ -11722,6 +11722,7 @@ server <name> <address>[:[port]] [param*]
     <name>    is the internal name assigned to this server. This name will
               appear in logs and alerts. If "http-send-name-header" is
               set, it will be added to the request header sent to the server.
+              This name must be unique within the backend section.
 
     <address> is the IPv4 or IPv6 address of the server. Alternatively, a
               resolvable hostname is supported, but this name will be resolved
index 3b8eedcfb5146597fe1f44016316c5195c951596..a1ea79c5ca84d7ee4b78ffc71e60d334c69ad22b 100644 (file)
@@ -3691,13 +3691,11 @@ out_uri_auth_compat:
                }
 
                /* Check that no server name conflicts. This causes trouble in the stats.
-                * We only emit a warning for the first conflict affecting each server,
+                * We only emit an error for the first conflict affecting each server,
                 * in order to avoid combinatory explosion if all servers have the same
-                * name. We do that only for servers which do not have an explicit ID,
-                * because these IDs were made also for distinguishing them and we don't
-                * want to annoy people who correctly manage them. Since servers names
-                * are stored in a tree before landing here, we simply have to check for
-                * the current server's duplicates to spot conflicts.
+                * name. Since servers names are stored in a tree before landing here,
+                * we simply have to check for the current server's duplicates to spot
+                * conflicts.
                 */
                for (newsrv = curproxy->srv; newsrv; newsrv = newsrv->next) {
                        struct server *other_srv;
@@ -3711,19 +3709,12 @@ out_uri_auth_compat:
                        for (other_srv = newsrv;
                             (other_srv = container_of_safe(ebpt_prev_dup(&other_srv->conf.name),
                                                            struct server, conf.name)); ) {
-                               if (!newsrv->puid && !other_srv->puid) {
-                                       ha_alert("parsing [%s:%d] : %s '%s', another server named '%s' was already defined at line %d, please use distinct names.\n",
-                                                  newsrv->conf.file, newsrv->conf.line,
-                                                  proxy_type_str(curproxy), curproxy->id,
-                                                  newsrv->id, other_srv->conf.line);
-                                       cfgerr++;
-                                       break;
-                               }
-
-                               ha_warning("parsing [%s:%d] : %s '%s', another server named '%s' was already defined at line %d. This is dangerous and will not be supported anymore in version 3.3. Please use distinct names.\n",
-                                          newsrv->conf.file, newsrv->conf.line,
-                                          proxy_type_str(curproxy), curproxy->id,
-                                          newsrv->id, other_srv->conf.line);
+                               ha_alert("parsing [%s:%d] : %s '%s', another server named '%s' was already defined at line %d, please use distinct names.\n",
+                                        newsrv->conf.file, newsrv->conf.line,
+                                        proxy_type_str(curproxy), curproxy->id,
+                                        newsrv->id, other_srv->conf.line);
+                               cfgerr++;
+                               break;
                        }
                }