]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: proxy: remove obsolete "mode health"
authorWilly Tarreau <w@1wt.eu>
Wed, 14 Oct 2020 13:44:27 +0000 (15:44 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 15 Oct 2020 19:47:04 +0000 (21:47 +0200)
As discussed here during 2.1-dev, "mode health" is totally obsolete:

   https://www.mail-archive.com/haproxy@formilux.org/msg35204.html

It's fundamentally incompatible with usage of SSL, doesn't support
source filtering, and imposes the presence of file descriptors with
hard-coded syscalls directly in the generic accept path.

It's very unlikely that anyone has used it in the last 10 years for
anything beyond testing. In the worst case if anyone would depend
on it, replacing it with "http-request return status 200" and "mode
http" would certainly do the trick.

The keyword is still detected as special by the config parser to help
users update their configurations appropriately.

doc/configuration.txt
include/haproxy/proxy-t.h
src/cfgparse-listen.c
src/cfgparse.c
src/proxy.c
src/session.c

index a1a743f0b9ad0d5f825b87339593afc37de5af1c..b55a8077e14b9d4862ff69810acca484c9628db9 100644 (file)
@@ -7099,7 +7099,7 @@ maxconn <conns>
   See also : "server", global section's "maxconn", "fullconn"
 
 
-mode { tcp|http|health }
+mode { tcp|http }
   Set the running mode or protocol of the instance
   May be used in sections :   defaults | frontend | listen | backend
                                  yes   |    yes   |   yes  |   yes
@@ -7115,15 +7115,6 @@ mode { tcp|http|health }
               processing and switching will be possible. This is the mode which
               brings HAProxy most of its value.
 
-    health    The instance will work in "health" mode. It will just reply "OK"
-              to incoming connections and close the connection. Alternatively,
-              If the "httpchk" option is set, "HTTP/1.0 200 OK" will be sent
-              instead. Nothing will be logged in either case. This mode is used
-              to reply to external components health checks. This mode is
-              deprecated and should not be used anymore as it is possible to do
-              the same and even better by combining TCP or HTTP modes with the
-              "monitor" keyword.
-
   When doing content switching, it is mandatory that the frontend and the
   backend are in the same mode (generally HTTP), otherwise the configuration
   will be refused.
@@ -7132,8 +7123,6 @@ mode { tcp|http|health }
      defaults http_instances
          mode http
 
-  See also : "monitor", "monitor-net"
-
 
 monitor fail { if | unless } <condition>
   Add a condition to report a failure to a monitor HTTP request.
index da728a37ed4ed772dc8e7905de5cf8ae2234ecc3..18f6d554f1c3ce608290ea5e4f1983d6d6ee9db0 100644 (file)
@@ -46,7 +46,6 @@
 enum pr_mode {
        PR_MODE_TCP = 0,
        PR_MODE_HTTP,
-       PR_MODE_HEALTH,
        PR_MODE_CLI,
        PR_MODE_SYSLOG,
        PR_MODE_PEERS,
@@ -247,7 +246,7 @@ struct error_snapshot {
 struct proxy {
        enum obj_type obj_type;                 /* object type == OBJ_TYPE_PROXY */
        char disabled;                          /* non-zero if disabled or shutdown */
-       enum pr_mode mode;                      /* mode = PR_MODE_TCP, PR_MODE_HTTP or PR_MODE_HEALTH */
+       enum pr_mode mode;                      /* mode = PR_MODE_TCP, PR_MODE_HTTP, ... */
        char cap;                               /* supported capabilities (PR_CAP_*) */
        unsigned int maxconn;                   /* max # of active streams on the frontend */
 
index 6f324fafa112cfa51d7030d7b3be1637f5b1d335..211c4b605523bc5a05addaeb8094bcc446fe64f4 100644 (file)
@@ -703,7 +703,11 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
 
                if (!strcmp(args[1], "http")) curproxy->mode = PR_MODE_HTTP;
                else if (!strcmp(args[1], "tcp")) curproxy->mode = PR_MODE_TCP;
-               else if (!strcmp(args[1], "health")) curproxy->mode = PR_MODE_HEALTH;
+               else if (!strcmp(args[1], "health")) {
+                       ha_alert("parsing [%s:%d] : 'mode health' doesn't exist anymore. Please use 'http-request return status 200' instead.\n", file, linenum);
+                       err_code |= ERR_ALERT | ERR_FATAL;
+                       goto out;
+               }
                else {
                        ha_alert("parsing [%s:%d] : unknown proxy mode '%s'.\n", file, linenum, args[1]);
                        err_code |= ERR_ALERT | ERR_FATAL;
index 12585d0618f527b2c1a06494b2f53001cb36d9d1..902fc0e14950c566dd6906a78cf0d914ab392a98 100644 (file)
@@ -2330,19 +2330,6 @@ int check_config_validity()
                }
 
                switch (curproxy->mode) {
-               case PR_MODE_HEALTH:
-                       cfgerr += proxy_cfg_ensure_no_http(curproxy);
-                       if (!(curproxy->cap & PR_CAP_FE)) {
-                               ha_alert("config : %s '%s' cannot be in health mode as it has no frontend capability.\n",
-                                        proxy_type_str(curproxy), curproxy->id);
-                               cfgerr++;
-                       }
-
-                       if (curproxy->srv != NULL)
-                               ha_warning("config : servers will be ignored for %s '%s'.\n",
-                                          proxy_type_str(curproxy), curproxy->id);
-                       break;
-
                case PR_MODE_TCP:
                        cfgerr += proxy_cfg_ensure_no_http(curproxy);
                        break;
@@ -2370,7 +2357,7 @@ int check_config_validity()
                        err_code |= ERR_WARN;
                }
 
-               if ((curproxy->cap & PR_CAP_BE) && (curproxy->mode != PR_MODE_HEALTH)) {
+               if (curproxy->cap & PR_CAP_BE) {
                        if (curproxy->lbprm.algo & BE_LB_KIND) {
                                if (curproxy->options & PR_O_TRANSP) {
                                        ha_alert("config : %s '%s' cannot use both transparent and balance mode.\n",
index 79ba5a679b172f44065490f715711e47b14eff18..43c2362285c00ab5b1ecdd1014b07a881fc580f3 100644 (file)
@@ -138,8 +138,6 @@ const char *proxy_mode_str(int mode) {
                return "tcp";
        else if (mode == PR_MODE_HTTP)
                return "http";
-       else if (mode == PR_MODE_HEALTH)
-               return "health";
        else if (mode == PR_MODE_CLI)
                return "cli";
        else
index c5af3c40a10d6c52bfdae270b00edd8f70785297..ab023b448d87fcecdac84582b6eca1da664726ef 100644 (file)
@@ -197,8 +197,7 @@ int session_accept_fd(struct listener *l, int cfd, struct sockaddr_storage *addr
         * in order to avoid emission of an RST by the system. We ignore any
         * error.
         */
-       if (unlikely((p->mode == PR_MODE_HEALTH) ||
-                    ((l->options & LI_O_CHK_MONNET) &&
+       if (unlikely(((l->options & LI_O_CHK_MONNET) &&
                      addr->ss_family == AF_INET &&
                      (((struct sockaddr_in *)addr)->sin_addr.s_addr & p->mon_mask.s_addr) == p->mon_net.s_addr))) {
                /* we have 4 possibilities here :
@@ -209,12 +208,8 @@ int session_accept_fd(struct listener *l, int cfd, struct sockaddr_storage *addr
                 */
                if (l->rx.proto->drain)
                        l->rx.proto->drain(cfd);
-               if (p->mode == PR_MODE_HTTP ||
-                   (p->mode == PR_MODE_HEALTH && (p->options2 & PR_O2_CHK_ANY) == PR_O2_TCPCHK_CHK &&
-                    (p->tcpcheck_rules.flags & TCPCHK_RULES_PROTO_CHK) == TCPCHK_RULES_HTTP_CHK))
+               if (p->mode == PR_MODE_HTTP)
                        send(cfd, "HTTP/1.0 200 OK\r\n\r\n", 19, MSG_DONTWAIT|MSG_NOSIGNAL|MSG_MORE);
-               else if (p->mode == PR_MODE_HEALTH)
-                       send(cfd, "OK\n", 3, MSG_DONTWAIT|MSG_NOSIGNAL|MSG_MORE);
                ret = 0;
                goto out_free_sess;
        }