There are some similarities between a weight of zero and the
administratively set drain state: both allow existing connections
to continue while not accepting any new ones.

However, when reporting a server state generally a distinction is made
between state=UP,weight=0 and state=DRAIN,weight=*. This patch makes
stats reporting consistent in this regard.

This patch does not alter the behaviour that if a server's weight
is zero then its stats row is blue when accessed via HTML. This remains
the case regardless of if the state is UP or DRAIN.

Signed-off-by: Simon Horman <[email protected]>

---
v2
* Reworked to use SRV_*
* Keep blue for zero weight regardless of state
---
 src/dumpstats.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/dumpstats.c b/src/dumpstats.c
index b505d4e2e172..5704fe4fdcf4 100644
--- a/src/dumpstats.c
+++ b/src/dumpstats.c
@@ -3906,13 +3906,14 @@ static int stats_dump_proxy_to_buffer(struct 
stream_interface *si, struct proxy
                                        sv_colour = SRV_STATS_COLOUR_UP;
                                }
 
-                               if (server_is_draining(sv)) {
-                                       if (sv_state == 
SRV_STATS_STATE_UP_GOING_DOWN) {
+                               if (sv_state == SRV_STATS_STATE_UP && 
!svs->uweight)
+                                       sv_colour = SRV_STATS_COLOUR_DRAINING;
+
+                               if (sv->admin & SRV_ADMF_DRAIN) {
+                                       if (sv_state == 
SRV_STATS_STATE_UP_GOING_DOWN)
                                                sv_state = 
SRV_STATS_STATE_DRAIN_GOING_DOWN;
-                                       } else {
+                                       else
                                                sv_state = 
SRV_STATS_STATE_DRAIN;
-                                               sv_colour = 
SRV_STATS_COLOUR_DRAINING;
-                                       }
                                }
 
                                if (sv_state == SRV_STATS_STATE_UP && 
!(svs->check.state & CHK_ST_ENABLED)) {
-- 
2.1.4


Reply via email to