]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: check: remove checkport checkaddr flag
authorWilliam Dauchy <wdauchy@gmail.com>
Wed, 3 Feb 2021 21:30:07 +0000 (22:30 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 4 Feb 2021 09:43:00 +0000 (10:43 +0100)
While trying to fix some consistency problem with the config file/cli
(e.g. check-port cli command does not set the flag), we realised
checkport flag was not necessarily needed. Indeed tcpcheck uses service
port as the last choice if check.port is zero. So we can assume if
check.port is zero, it means it was never set by the user, regardless if
it is by the cli or config file.  In the longterm this will avoid to
introduce a new consistency issue if we forget to set the flag.

in the same manner of checkport flag, we don't really need checkaddr
flag. We can assume if checkaddr is not set, it means it was never set
by the user or config.

Signed-off-by: William Dauchy <wdauchy@gmail.com>
include/haproxy/server-t.h
src/check.c
src/server.c

index b29c75c0b9fb493a525ef9f45fe2e5ce8253c5dd..96816e178abee902106873c1c6bd448a2c746f53 100644 (file)
@@ -137,8 +137,6 @@ enum srv_initaddr {
 #define SRV_F_NON_STICK    0x0004        /* never add connections allocated to this server to a stick table */
 #define SRV_F_USE_NS_FROM_PP 0x0008      /* use namespace associated with connection if present */
 #define SRV_F_FORCED_ID    0x0010        /* server's ID was forced in the configuration */
-#define SRV_F_CHECKADDR    0x0020        /* this server has a check addr configured */
-#define SRV_F_CHECKPORT    0x0040        /* this server has a check port configured */
 #define SRV_F_AGENTADDR    0x0080        /* this server has a agent addr configured */
 #define SRV_F_COOKIESET    0x0100        /* this server has a cookie configured, so don't generate dynamic cookies */
 #define SRV_F_FASTOPEN     0x0200        /* Use TCP Fast Open to connect to server */
index 879fe84ce2fa2d9c31442357f908929e775f8ad5..e24050ff24b5b844914f4919a24e6dfbb190807b 100644 (file)
@@ -1527,7 +1527,6 @@ static int srv_parse_addr(char **args, int *cur_arg, struct proxy *curpx, struct
        }
 
        srv->check.addr = srv->agent.addr = *sk;
-       srv->flags |= SRV_F_CHECKADDR;
        srv->flags |= SRV_F_AGENTADDR;
 
   out:
@@ -2050,7 +2049,6 @@ static int srv_parse_check_port(char **args, int *cur_arg, struct proxy *curpx,
 
        global.maxsock++;
        srv->check.port = atol(args[*cur_arg+1]);
-       srv->flags |= SRV_F_CHECKPORT;
 
   out:
        return err_code;
index 04e00d54a7fcb52be788a2e5d567dc0bf8941a05..76bd49fb109dc6d5e649811189bdd73126e703c8 100644 (file)
@@ -1660,8 +1660,6 @@ static void srv_settings_cpy(struct server *srv, struct server *src, int srv_tmp
        srv->flags                   |= src->flags;
        srv->do_check                 = src->do_check;
        srv->do_agent                 = src->do_agent;
-       if (srv->check.port)
-               srv->flags |= SRV_F_CHECKPORT;
        srv->check.inter              = src->check.inter;
        srv->check.fastinter          = src->check.fastinter;
        srv->check.downinter          = src->check.downinter;
@@ -3657,7 +3655,7 @@ const char *update_server_addr_port(struct server *s, const char *addr, const ch
                                 * we're switching from a fixed port to a SRV_F_MAPPORTS (mapped) port
                                 * prevent PORT change if check doesn't have it's dedicated port while switching
                                 * to port mapping */
-                               if ((s->check.state & CHK_ST_CONFIGURED) && !(s->flags & SRV_F_CHECKPORT)) {
+                               if (!s->check.port) {
                                        chunk_appendf(msg, "can't change <port> to port map because it is incompatible with current health check port configuration (use 'port' statement from the 'server' directive.");
                                        goto out;
                                }