MINOR: server: startup slowstart task when using seamless reload of HAProxy
This patch uses the start up of the health check task to also start
the warmup task when required.
This is executed only once: when HAProxy has just started up and can
be started only if the load-server-state-from-file feature is enabled
and the server was in the warmup state before a reload occurs.
diff --git a/src/checks.c b/src/checks.c
index eeff4ea..ade2428 100644
--- a/src/checks.c
+++ b/src/checks.c
@@ -2295,6 +2295,9 @@
t->process = server_warmup;
t->context = s;
t->expire = TICK_ETERNITY;
+ /* server can be in this state only because of */
+ if (s->state == SRV_ST_STARTING)
+ task_schedule(s->warmup, tick_add(now_ms, MS_TO_TICKS(MAX(1000, (now.tv_sec - s->last_change)) / 20)));
}
if (s->check.state & CHK_ST_CONFIGURED) {
diff --git a/src/server.c b/src/server.c
index 070cde3..a34b850 100644
--- a/src/server.c
+++ b/src/server.c
@@ -2125,23 +2125,18 @@
!(srv_agent_state & CHK_ST_ENABLED))
srv->agent.state &= ~CHK_ST_ENABLED;
- /* by default, HAProxy applies the following weight when parsing the configuration
- * srv->uweight = srv_iweight.
+ /* We want to apply the previous 'running' weight (srv_uweight) only if there
+ * was no change in the configuration: both previous and new iweight are equals
*
- * We want to apply the previous 'running' weight (srv_uweight) in the following cases:
- * - previous uweight, iweight and iweight were set, whatever their values
- * - both previous and new iweight are equal but previous uweight is set, whatever
- * its value
- * - iweight has changed between previous and new configuration file but uweight
- * wasn't set to previous iweight value (basically, changed over the stats socket)
- * => basically, stats socket has precedence over configuration file in such case.
+ * It means that a configuration file change has precedence over a unix socket change
+ * for server's weight
+ *
+ * by default, HAProxy applies the following weight when parsing the configuration
+ * srv->uweight = srv->iweight
*/
- if ((srv_uweight > 0 && srv_iweight > 0 && srv->iweight > 0) ||
- (srv_iweight == srv->iweight && srv_uweight > 0) ||
- (srv_iweight != srv->iweight && srv_uweight != srv_iweight)) {
+ if (srv_iweight == srv->iweight) {
srv->uweight = srv_uweight;
}
-
server_recalc_eweight(srv);
/* update server IP only if DNS resolution is used on the server */