everything is OK before the delay, a success is returned and the operation
is terminated.
+ - srv-unknown <proxy>/<server> : this will wait for the specified server name
+ to be available for a new instance to be created. This will fail if the
+ server already exists, unless if it is flagged for background deletion, in
+ which case a success will be returned if the deletion is completed before
+ the delay.
+
The default unit for the delay is milliseconds, though other units are
accepted if suffixed with the usual timer units (us, ms, s, m, h, d). When
used with the 'socat' utility, do not forget to extend socat's close timeout
enum cli_wait_cond {
CLI_WAIT_COND_NONE, // no condition to wait on
CLI_WAIT_COND_SRV_UNUSED,// wait for server to become unused
+ CLI_WAIT_COND_SRV_UNKNWN,// wait for server name to be available
CLI_WAIT_COND_BE_UNUSED, // wait for backend to become unused
};
if (strcmp(args[2], "srv-removable") == 0) {
ctx->cond = CLI_WAIT_COND_SRV_UNUSED;
}
+ else if (strcmp(args[2], "srv-unknown") == 0) {
+ ctx->cond = CLI_WAIT_COND_SRV_UNKNWN;
+ }
else if (strcmp(args[2], "be-removable") == 0) {
ctx->cond = CLI_WAIT_COND_BE_UNUSED;
}
" duration. Supported conditions are:\n"
" - <none> : by default, just sleep for the specified duration.\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"
"";
}
switch (ctx->cond) {
- case CLI_WAIT_COND_SRV_UNUSED: {
+ case CLI_WAIT_COND_SRV_UNUSED:
+ case CLI_WAIT_COND_SRV_UNKNWN: {
const char *bename, *svname;
if (!*args[3])
}
/* let's check the timer */
}
+ else if (ctx->cond == CLI_WAIT_COND_SRV_UNKNWN) {
+ struct proxy *px;
+ struct server *srv;
+
+ px = proxy_be_by_name(ctx->args[0]);
+ srv = px ? server_find(px, ctx->args[1]) : NULL;
+ if (!px || !srv) {
+ /* immediate success */
+ ctx->error = CLI_WAIT_ERR_DONE;
+ return 1;
+ }
+ else if (!(srv->flags & SRV_F_TO_PURGE)) {
+ /* unrecoverable failure */
+ ctx->error = CLI_WAIT_ERR_FAIL;
+ ctx->msg = "Server not scheduled for purge.\n";
+ return 1;
+ }
+ }
/* and here we recalculate the new wait time or abort */
left = tick_remain(now_ms, ctx->deadline);