]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: server: do not emit warnings/logs/alerts on server state changes at boot
authorWilly Tarreau <w@1wt.eu>
Thu, 3 Nov 2016 18:42:36 +0000 (19:42 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 7 Nov 2016 13:31:45 +0000 (14:31 +0100)
We'll have to use srv_set_admin_flag() to propagate some server flags
during the startup, and we don't want the resulting actions to cause
warnings, logs nor e-mail alerts to be generated since we're just applying
the config or a state file. So let's condition these notifications to the
fact that we're starting.

src/backend.c
src/server.c

index 573f054dc7a72a555bdec199a3890f7bb59fa5c5..176a10a4b819872e6ccf288e30da073accf4b987 100644 (file)
@@ -1326,8 +1326,10 @@ void set_backend_down(struct proxy *be)
        be->last_change = now.tv_sec;
        be->down_trans++;
 
-       Alert("%s '%s' has no server available!\n", proxy_type_str(be), be->id);
-       send_log(be, LOG_EMERG, "%s %s has no server available!\n", proxy_type_str(be), be->id);
+       if (!(global.mode & MODE_STARTING)) {
+               Alert("%s '%s' has no server available!\n", proxy_type_str(be), be->id);
+               send_log(be, LOG_EMERG, "%s %s has no server available!\n", proxy_type_str(be), be->id);
+       }
 }
 
 /* Apply RDP cookie persistence to the current stream. For this, the function
index 3be2bc82912dc5145f4942531d807b7772d0869c..cc1f0d10ab0bd127b0bdcd59a112497cd5c47184 100644 (file)
@@ -430,8 +430,10 @@ void srv_set_admin_flag(struct server *s, enum srv_admin mode)
 
                        srv_append_status(&trash, s, NULL, -1, (mode & SRV_ADMF_FMAINT));
 
-                       Warning("%s.\n", trash.str);
-                       send_log(s->proxy, LOG_NOTICE, "%s.\n", trash.str);
+                       if (!(global.mode & MODE_STARTING)) {
+                               Warning("%s.\n", trash.str);
+                               send_log(s->proxy, LOG_NOTICE, "%s.\n", trash.str);
+                       }
                }
                else {  /* server was still running */
                        int srv_was_stopping = (s->state == SRV_ST_STOPPING) || (s->admin & SRV_ADMF_DRAIN);
@@ -459,8 +461,10 @@ void srv_set_admin_flag(struct server *s, enum srv_admin mode)
 
                        srv_append_status(&trash, s, NULL, xferred, (mode & SRV_ADMF_FMAINT));
 
-                       Warning("%s.\n", trash.str);
-                       send_log(s->proxy, srv_was_stopping ? LOG_NOTICE : LOG_ALERT, "%s.\n", trash.str);
+                       if (!(global.mode & MODE_STARTING)) {
+                               Warning("%s.\n", trash.str);
+                               send_log(s->proxy, srv_was_stopping ? LOG_NOTICE : LOG_ALERT, "%s.\n", trash.str);
+                       }
 
                        if (prev_srv_count && s->proxy->srv_bck == 0 && s->proxy->srv_act == 0)
                                set_backend_down(s->proxy);
@@ -488,10 +492,11 @@ void srv_set_admin_flag(struct server *s, enum srv_admin mode)
 
                srv_append_status(&trash, s, NULL, xferred, (mode & SRV_ADMF_FDRAIN));
 
-               Warning("%s.\n", trash.str);
-               send_log(s->proxy, LOG_NOTICE, "%s.\n", trash.str);
-               send_email_alert(s, LOG_NOTICE, "%s", trash.str);
-
+               if (!(global.mode & MODE_STARTING)) {
+                       Warning("%s.\n", trash.str);
+                       send_log(s->proxy, LOG_NOTICE, "%s.\n", trash.str);
+                       send_email_alert(s, LOG_NOTICE, "%s", trash.str);
+               }
                if (prev_srv_count && s->proxy->srv_bck == 0 && s->proxy->srv_act == 0)
                        set_backend_down(s->proxy);
        }