From: Amaury Denoyelle Date: Tue, 13 Jul 2021 08:35:50 +0000 (+0200) Subject: MINOR: srv: do not allow to track a dynamic server X-Git-Tag: v2.5-dev2~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=79f68be20771f8ca4034a19f041cb86372470ce1;p=thirdparty%2Fhaproxy.git MINOR: srv: do not allow to track a dynamic server 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. --- diff --git a/src/server.c b/src/server.c index 1ad4c2e6ab..664e2f4ec5 100644 --- a/src/server.c +++ b/src/server.c @@ -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 "