summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilly Tarreau <w@1wt.eu>2020-09-24 08:04:27 +0200
committerWilly Tarreau <w@1wt.eu>2020-10-07 18:44:08 +0200
commitde9dd7947334fe325936e76b7a21abcdd641b7b3 (patch)
treeec06f74ebc4739650da1945df14099145ce2dfa6
parent6932af3229cb630bdba017d9988669b70eee7887 (diff)
downloadhaproxy-de9dd7947334fe325936e76b7a21abcdd641b7b3.tar.gz
MEDIUM: proxy: remove state PR_STPAUSED
This state was used to mention that a proxy was in PAUSED state, as opposed to the READY state. This was causing some trouble because if a listener failed to resume (e.g. because its port was temporarily in use during the resume), it was not possible to retry the operation later. Now by checking the number of READY or PAUSED listeners instead, we can accurately know if something went bad and try to fix it again later. The case of the temporary port conflict during resume now works well: $ socat readline /tmp/sock1 prompt > disable frontend testme3 > disable frontend testme3 All sockets are already disabled. > enable frontend testme3 Failed to resume frontend, check logs for precise cause (port conflict?). > enable frontend testme3 > enable frontend testme3 All sockets are already enabled.
-rw-r--r--include/haproxy/proxy-t.h1
-rw-r--r--src/proxy.c16
2 files changed, 6 insertions, 11 deletions
diff --git a/include/haproxy/proxy-t.h b/include/haproxy/proxy-t.h
index f2fdf01d5..aa8038dd1 100644
--- a/include/haproxy/proxy-t.h
+++ b/include/haproxy/proxy-t.h
@@ -46,7 +46,6 @@
enum pr_state {
PR_STNEW = 0, /* proxy has not been initialized yet */
PR_STREADY, /* proxy has been initialized and is ready */
- PR_STPAUSED, /* frontend is paused (during hot restart) */
PR_STSTOPPED, /* proxy is stopped (end of a restart) */
} __attribute__((packed));
diff --git a/src/proxy.c b/src/proxy.c
index 06fb0d9f6..bae8c1410 100644
--- a/src/proxy.c
+++ b/src/proxy.c
@@ -1288,8 +1288,7 @@ int pause_proxy(struct proxy *p)
{
struct listener *l;
- if (!(p->cap & PR_CAP_FE) ||
- p->state == PR_STSTOPPED || p->state == PR_STPAUSED)
+ if (!(p->cap & PR_CAP_FE) || p->state == PR_STSTOPPED || !p->li_ready)
return 1;
ha_warning("Pausing %s %s.\n", proxy_cap_str(p->cap), p->id);
@@ -1303,8 +1302,6 @@ int pause_proxy(struct proxy *p)
send_log(p, LOG_WARNING, "%s %s failed to enter pause mode.\n", proxy_cap_str(p->cap), p->id);
return 0;
}
-
- p->state = PR_STPAUSED;
return 1;
}
@@ -1370,7 +1367,7 @@ int resume_proxy(struct proxy *p)
struct listener *l;
int fail;
- if (p->state != PR_STPAUSED)
+ if (p->state == PR_STSTOPPED || !p->li_paused)
return 1;
ha_warning("Enabling %s %s.\n", proxy_cap_str(p->cap), p->id);
@@ -1401,7 +1398,6 @@ int resume_proxy(struct proxy *p)
}
}
- p->state = PR_STREADY;
if (fail) {
pause_proxy(p);
return 0;
@@ -2222,8 +2218,8 @@ static int cli_parse_disable_frontend(char **args, char *payload, struct appctx
if (px->state == PR_STSTOPPED)
return cli_msg(appctx, LOG_NOTICE, "Frontend was previously shut down, cannot disable.\n");
- if (px->state == PR_STPAUSED)
- return cli_msg(appctx, LOG_NOTICE, "Frontend is already disabled.\n");
+ if (!px->li_ready)
+ return cli_msg(appctx, LOG_NOTICE, "All sockets are already disabled.\n");
HA_SPIN_LOCK(PROXY_LOCK, &px->lock);
ret = pause_proxy(px);
@@ -2254,8 +2250,8 @@ static int cli_parse_enable_frontend(char **args, char *payload, struct appctx *
if (px->state == PR_STSTOPPED)
return cli_err(appctx, "Frontend was previously shut down, cannot enable.\n");
- if (px->state != PR_STPAUSED)
- return cli_msg(appctx, LOG_NOTICE, "Frontend is already enabled.\n");
+ if (px->li_ready == px->li_all)
+ return cli_msg(appctx, LOG_NOTICE, "All sockets are already enabled.\n");
HA_SPIN_LOCK(PROXY_LOCK, &px->lock);
ret = resume_proxy(px);