BUG/MINOR: check: consitent way to set agentaddr
small consistency problem with `addr` and `agent-addr` options:
for the both options, the last one parsed is always used to set the
agent-check addr. Thus these two lines don't have the same behavior:
server ... addr <addr1> agent-addr <addr2>
server ... agent-addr <addr2> addr <addr1>
After this patch `agent-addr` will always be the priority option over
`addr`. It means we test the flag before setting agentaddr.
We also fix all the places where we did not set the flag to be coherent
everywhere.
I was not really able to determine where this issue is coming from. So
it is probable we may backport it to all stable version where the agent
is supported.
Signed-off-by: William Dauchy <wdauchy@gmail.com>
diff --git a/src/server.c b/src/server.c
index 8019dd1..ba85bb8 100644
--- a/src/server.c
+++ b/src/server.c
@@ -4383,9 +4383,14 @@
cli_err(appctx, "'set server <srv> agent' expects 'up' or 'down'.\n");
}
else if (strcmp(args[3], "agent-addr") == 0) {
+ struct sockaddr_storage sk;
+
+ memset(&sk, 0, sizeof(sk));
if (!(sv->agent.state & CHK_ST_ENABLED))
cli_err(appctx, "agent checks are not enabled on this server.\n");
- else if (str2ip(args[4], &sv->agent.addr) == NULL)
+ else if (str2ip(args[4], &sk))
+ set_srv_agent_addr(sv, &sk);
+ else
cli_err(appctx, "incorrect addr address given for agent.\n");
}
else if (strcmp(args[3], "agent-send") == 0) {