]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: server: startup slowstart task when using seamless reload of HAProxy
authorBaptiste Assmann <bedis9@gmail.com>
Thu, 17 Sep 2015 20:53:59 +0000 (22:53 +0200)
committerWilly Tarreau <w@1wt.eu>
Sat, 19 Sep 2015 15:05:28 +0000 (17:05 +0200)
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.

src/checks.c
src/server.c

index eeff4eaacc80e78bc855037a927d88f315485b6e..ade2428a8c625dfc3f19e5f1ed24ea46f7da4f9f 100644 (file)
@@ -2295,6 +2295,9 @@ int start_checks() {
                                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) {
index 070cde3bf883063536726541cdd259a560094345..a34b850b6d04f6f5072ad95875414432b9281629 100644 (file)
@@ -2125,23 +2125,18 @@ static void srv_update_state(struct server *srv, int version, char **params)
                            !(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 */