From 1da28773a039f4bbabf6bab919e108129e5f808c Mon Sep 17 00:00:00 2001 From: Amaury Denoyelle Date: Tue, 21 Sep 2021 10:29:09 +0200 Subject: [PATCH] BUG/MINOR: server: allow 'enable health' only if check configured Test that checks have been configured on the server before enabling via the 'enable health' CLI. This mirrors the 'enable agent' command. Without this, a user can use the command on the server without checks. This leaves the server in an undefined state. Notably, the stat page reports the server in check transition. This condition was left on the following reorg commit. 2c04eda8b58636ad2ae44e42b1f50f3b5a24a642 REORG: cli: move "{enable|disable} health" to server.c This should be backported up to 1.8. (cherry picked from commit 0f456d502963f3555552d4b3d5f97ed504353d85) Signed-off-by: Christopher Faulet (cherry picked from commit e636a1106961ea0a0986657fc9943b03eb6f531a) Signed-off-by: Christopher Faulet --- src/server.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/server.c b/src/server.c index 911085e..7cd0821 100644 --- a/src/server.c +++ b/src/server.c @@ -4755,6 +4755,9 @@ static int cli_parse_enable_health(char **args, char *payload, struct appctx *ap if (!sv) return 1; + if (!(sv->check.state & CHK_ST_CONFIGURED)) + return cli_err(appctx, "Health check was not configured on this server, cannot enable.\n"); + HA_SPIN_LOCK(SERVER_LOCK, &sv->lock); sv->check.state |= CHK_ST_ENABLED; HA_SPIN_UNLOCK(SERVER_LOCK, &sv->lock); -- 1.7.10.4