]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: srv: do not allow to track a dynamic server
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 13 Jul 2021 08:35:50 +0000 (10:35 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 16 Jul 2021 08:08:55 +0000 (10:08 +0200)
Prevents the use of the "track" keyword for a dynamic server. This
simplifies the deletion of a dynamic server, without having to worry
about servers which might tracked it.

A BUG_ON is present in the dynamic server delete function to validate
this assertion.

src/server.c

index 1ad4c2e6ab1cb0cbd7b6ea71d9142a14360b9136..664e2f4ec563e8453c05e4ca420e8288be34c9fd 100644 (file)
@@ -4627,6 +4627,9 @@ static int cli_parse_delete_server(char **args, char *payload, struct appctx *ap
                goto out;
        }
 
+       /* A dynamic server cannot be tracked. */
+       BUG_ON(srv->trackers);
+
        /* Only servers in maintenance can be deleted. This ensures that the
         * server is not present anymore in the lb structures (through
         * lbprm.set_server_status_down).
@@ -4764,6 +4767,12 @@ int srv_apply_track(struct server *srv, struct proxy *curproxy)
                return 1;
        }
 
+       if (strack->flags & SRV_F_DYNAMIC) {
+               ha_alert("unable to use %s/%s for tracking as it is a dynamic server.\n",
+                        px->id, strack->id);
+               return 1;
+       }
+
        if (!strack->do_check && !strack->do_agent && !strack->track &&
            !strack->trackit) {
                ha_alert("unable to use %s/%s for "