not met. If everything is OK before the delay, a success is returned and
the operation is terminated.
+ - be-unknown <proxy> : this will wait for the specified backend name to be
+ available for a new instance to be created. This will fail if a proxy with
+ this name already exists, unless if this is a backend flagged for
+ background deletion, in which case a success will be returned if the
+ deletion is completed before the delay.
+
- srv-removable <proxy>/<server> : this will wait for the specified server to
be removable by the "del server" command, i.e. be in maintenance and no
longer have any connection on it (neither active or idle). Some conditions
else if (strcmp(args[2], "be-removable") == 0) {
ctx->cond = CLI_WAIT_COND_BE_UNUSED;
}
+ else if (strcmp(args[2], "be-unknown") == 0) {
+ ctx->cond = CLI_WAIT_COND_BE_UNKNWN;
+ }
else if (*args[2]) {
/* show the command's help either upon request (-h) or error */
err = "Usage: wait {-h|<duration>} [condition [args...]]\n"
" - srv-removable <px>/<sv> : wait for this server to become removable.\n"
" - srv-unknown <px>/<sv> : wait for this server name to be available.\n"
" - be-removable <px> : wait for this backend to become removable.\n"
+ " - be-unknown <px> : wait for this backend name to become available.\n"
"";
if (strcmp(args[2], "-h") == 0)
}
case CLI_WAIT_COND_BE_UNUSED:
+ case CLI_WAIT_COND_BE_UNKNWN:
if (!*args[3])
return cli_err(appctx, "Missing backend name.\n");
ctx->args[0] = strdup(args[3]);
return 1;
}
}
+ else if (ctx->cond == CLI_WAIT_COND_BE_UNKNWN) {
+ struct proxy *px;
+
+ if (proxy_find_by_name(ctx->args[0], PR_CAP_DEF, 0)) {
+ ctx->error = CLI_WAIT_ERR_FAIL;
+ ctx->msg = "Name already used by a default instance.\n";
+ return 1;
+ }
+
+ px = proxy_find_by_name(ctx->args[0], PR_CAP_NONE, 0);
+ if (!px) {
+ /* immediate success */
+ ctx->error = CLI_WAIT_ERR_DONE;
+ return 1;
+ }
+ else if (px->cap & PR_CAP_FE) {
+ ctx->error = CLI_WAIT_ERR_FAIL;
+ ctx->msg = "Name already used by a frontend/listen instance.\n";
+ return 1;
+ }
+ else if (!(px->flags & PR_FL_TO_PURGE)) {
+ /* unrecoverable failure */
+ ctx->error = CLI_WAIT_ERR_FAIL;
+ ctx->msg = "Backend not scheduled for purge.\n";
+ return 1;
+ }
+ }
/* and here we recalculate the new wait time or abort */
left = tick_remain(now_ms, ctx->deadline);