]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: proxy: prevent backend deletion if server still exists in it
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 12 Jan 2026 14:26:45 +0000 (15:26 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 2 Mar 2026 13:08:30 +0000 (14:08 +0100)
Ensure a backend instance cannot be removed if there is still server in
it. This is checked via be_check_for_deletion() to ensure "del backend"
cannot be executed. The only solution is to use "del server" to remove
on the servers instances.

This check only covers servers not yet targetted via "del server". For
deleted servers not yet purged (due to their refcount), the proxy
refcount is incremented but this does not block "del backend"
invokation.

doc/management.txt
src/proxy.c

index f83afbe03832ae7f8756b5d085d794bd2468f28d..7a7c84869057b2fdbd67cfe592c1202cc60730a6 100644 (file)
@@ -2128,7 +2128,8 @@ del backend <name>
   Removes the backend proxy with the name <name>.
 
   This operation is only possible for TCP or HTTP proxies. To succeed, the
-  backend instance must have been first unpublished.
+  backend instance must have been first unpublished. Also, all of its servers
+  must first be removed (via "del server" CLI).
 
   There is additional restrictions which prevent backend removal. First, a
   backend cannot be removed if it is explicitely referenced by config elements,
index 1e5a168b2c4038243bf252bc5d265c55e55fe90b..b70c70b0017a1743e355c98a31bef70e1049039f 100644 (file)
@@ -5048,6 +5048,11 @@ int be_check_for_deletion(const char *bename, struct proxy **pb, const char **pm
                goto out;
        }
 
+       if (be->srv) {
+               msg = "Only a backend without server can be deleted.";
+               goto out;
+       }
+
        /* Second, conditions that may change over time */
        ret = 0;