MINOR: server: enhance error precision when applying server state

server health checks and agent parameters are written the same way as
others to be able to enahcne code reuse: basically we make use of
parsing and assignment at the same place. It makes it difficult for
error handling to know whether srv object was modified partially or not.
The problem was already present with SRV resolution though.

I was a bit puzzled about the approach to take to be honest, and I did
not wanted to go into a full refactor, so I assumed it was ok to simply
notify whether the line was failed or partially applied.

Signed-off-by: William Dauchy <wdauchy@gmail.com>
This commit is contained in:
William Dauchy 2021-02-11 22:51:27 +01:00 committed by Christopher Faulet
parent d1a7b85a40
commit ddc7ce9645
1 changed files with 8 additions and 3 deletions

View File

@ -2625,6 +2625,7 @@ static void srv_update_state(struct server *srv, int version, char **params)
unsigned int port_svc;
char *srvrecord;
char *addr;
int partial_apply = 0;
#ifdef USE_OPENSSL
int use_ssl;
#endif
@ -2795,6 +2796,7 @@ static void srv_update_state(struct server *srv, int version, char **params)
/* don't apply anything if one error has been detected */
if (msg->data)
goto out;
partial_apply = 1;
/* recover operational state and apply it to this server
* and all servers tracking this one */
@ -3031,8 +3033,11 @@ static void srv_update_state(struct server *srv, int version, char **params)
out:
HA_SPIN_UNLOCK(SERVER_LOCK, &srv->lock);
if (msg->data) {
chunk_appendf(msg, "\n");
ha_warning("server-state application failed for server '%s/%s'%s",
if (partial_apply == 1)
ha_warning("server-state partially applied for server '%s/%s'%s\n",
srv->proxy->id, srv->id, msg->area);
else
ha_warning("server-state application failed for server '%s/%s'%s\n",
srv->proxy->id, srv->id, msg->area);
}
end: