]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: cli/wait: also support an unrecoverable failure status
authorWilly Tarreau <w@1wt.eu>
Fri, 9 Feb 2024 19:05:14 +0000 (20:05 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 9 Feb 2024 19:38:08 +0000 (20:38 +0100)
Since we'll support waiting for an action to succeed or permanently
fail, we need the ability to return an unrecoverable failure. Let's
add CLI_WAIT_ERR_FAIL for this. A static error message may be placed
into ctx->msg to report to the user why the failure is unrecoverable.

include/haproxy/cli-t.h
src/cli.c

index 9334fcd9f01c160c54d5bfbb87797300c23a5abd..bc868683cf14366dbac6d0e85261ee7b65f58c45 100644 (file)
@@ -90,6 +90,7 @@ enum cli_wait_err {
        CLI_WAIT_ERR_DONE,       // condition satisfied
        CLI_WAIT_ERR_INTR,       // interrupted
        CLI_WAIT_ERR_EXP,        // finished on wait expiration
+       CLI_WAIT_ERR_FAIL,       // finished early (unrecoverable)
 };
 
 enum cli_wait_cond {
@@ -100,6 +101,7 @@ struct cli_wait_ctx {
        uint start, deadline;    // both are in ticks.
        enum cli_wait_cond cond; // CLI_WAIT_COND_*
        enum cli_wait_err error; // CLI_WAIT_ERR_*
+       const char *msg;         // static error message for failures if not NULL
 };
 
 struct cli_kw {
index 7c88917a70761c74d5bf88403436ea99effed47d..1cede7729ea2b4e985c191b5538c52392edc3969 100644 (file)
--- a/src/cli.c
+++ b/src/cli.c
@@ -2120,6 +2120,7 @@ static void cli_release_wait(struct appctx *appctx)
        switch (ctx->error) {
        case CLI_WAIT_ERR_EXP:      msg = "Wait delay expired.\n"; break;
        case CLI_WAIT_ERR_INTR:     msg = "Interrupted.\n"; break;
+       case CLI_WAIT_ERR_FAIL:     msg = ctx->msg ? ctx->msg : "Failed.\n"; break;
        default:                    msg = "Done.\n"; break;
        }