From 053887cc98f180ea2c1456536a3888e3a612da69 Mon Sep 17 00:00:00 2001 From: Amaury Denoyelle Date: Mon, 12 Jan 2026 15:26:45 +0100 Subject: [PATCH] MINOR: proxy: prevent backend deletion if server still exists in it 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 | 3 ++- src/proxy.c | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/doc/management.txt b/doc/management.txt index f83afbe03..7a7c84869 100644 --- a/doc/management.txt +++ b/doc/management.txt @@ -2128,7 +2128,8 @@ del backend Removes the backend proxy with the 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, diff --git a/src/proxy.c b/src/proxy.c index 1e5a168b2..b70c70b00 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -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;