MEDIUM: cli: add support for enabling/disabling health checks.
"enable health" and "disable health" are introduced to manipulate the
health check subsystem.
diff --git a/doc/configuration.txt b/doc/configuration.txt
index 2308c5c..c565389 100644
--- a/doc/configuration.txt
+++ b/doc/configuration.txt
@@ -13154,6 +13154,15 @@
This command is restricted and can only be issued on sockets configured for
level "admin".
+disable health <backend>/<server>
+ Mark the primary health check as temporarily stopped. This will disable
+ sending of health checks, and the last health check result will be ignored.
+ The server will be in unchecked state and considered UP unless an auxiliary
+ agent check forces it down.
+
+ This command is restricted and can only be issued on sockets configured for
+ level "admin".
+
disable server <backend>/<server>
Mark the server DOWN for maintenance. In this mode, no more checks will be
performed on the server until it leaves maintenance.
@@ -13191,6 +13200,13 @@
This command is restricted and can only be issued on sockets configured for
level "admin".
+enable health <backend>/<server>
+ Resume a primary health check that was temporarily stopped. This will enable
+ sending of health checks again. Please see "disable health" for details.
+
+ This command is restricted and can only be issued on sockets configured for
+ level "admin".
+
enable server <backend>/<server>
If the server was previously marked as DOWN for maintenance, this marks the
server UP and checks are re-enabled.
diff --git a/src/dumpstats.c b/src/dumpstats.c
index 63a615a..7cfe2d0 100644
--- a/src/dumpstats.c
+++ b/src/dumpstats.c
@@ -1791,13 +1791,29 @@
sv->agent.state |= CHK_ST_ENABLED;
return 1;
}
- if (strcmp(args[1], "server") == 0) {
+ else if (strcmp(args[1], "health") == 0) {
struct server *sv;
sv = expect_server_admin(s, si, args[2]);
if (!sv)
return 1;
+ if (!(sv->check.state & CHK_ST_CONFIGURED)) {
+ appctx->ctx.cli.msg = "Health checks are not configured on this server, cannot enable.\n";
+ appctx->st0 = STAT_CLI_PRINT;
+ return 1;
+ }
+
+ sv->check.state |= CHK_ST_ENABLED;
+ return 1;
+ }
+ else if (strcmp(args[1], "server") == 0) {
+ struct server *sv;
+
+ sv = expect_server_admin(s, si, args[2]);
+ if (!sv)
+ return 1;
+
srv_adm_set_ready(sv);
return 1;
}
@@ -1828,7 +1844,7 @@
return 1;
}
else { /* unknown "enable" parameter */
- appctx->ctx.cli.msg = "'enable' only supports 'agent', 'frontend' and 'server'.\n";
+ appctx->ctx.cli.msg = "'enable' only supports 'agent', 'frontend', 'health', and 'server'.\n";
appctx->st0 = STAT_CLI_PRINT;
return 1;
}
@@ -1844,6 +1860,16 @@
sv->agent.state &= ~CHK_ST_ENABLED;
return 1;
}
+ else if (strcmp(args[1], "health") == 0) {
+ struct server *sv;
+
+ sv = expect_server_admin(s, si, args[2]);
+ if (!sv)
+ return 1;
+
+ sv->check.state &= ~CHK_ST_ENABLED;
+ return 1;
+ }
else if (strcmp(args[1], "server") == 0) {
struct server *sv;
@@ -1881,7 +1907,7 @@
return 1;
}
else { /* unknown "disable" parameter */
- appctx->ctx.cli.msg = "'disable' only supports 'agent', 'frontend' and 'server'.\n";
+ appctx->ctx.cli.msg = "'disable' only supports 'agent', 'frontend', 'health', and 'server'.\n";
appctx->st0 = STAT_CLI_PRINT;
return 1;
}