From 79f68be20771f8ca4034a19f041cb86372470ce1 Mon Sep 17 00:00:00 2001 From: Amaury Denoyelle Date: Tue, 13 Jul 2021 10:35:50 +0200 Subject: [PATCH] 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. --- src/server.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/server.c b/src/server.c index 1ad4c2e6a..664e2f4ec 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 "