Browse Source

MT#61556 redis: use hostname for logging where makes sense

When re-establishing connection to redis via hostname,
at a point of time upon new re-resolve hasn't been done yet,
use a hostname for logging of failing attempts to connect,
so that it doesn't confuse users with the older IP.

For the backwards compatibility, this will still log an IP
for those setups using the IP address and not a hostname.

Change-Id: I28f9a2a194b5009040ac8ed909a65fec1f199663
pull/1880/head
Donat Zenichev 1 year ago
parent
commit
d9ae6c57cd
1 changed files with 5 additions and 5 deletions
  1. +5
    -5
      daemon/redis.c

+ 5
- 5
daemon/redis.c View File

@ -966,13 +966,13 @@ static int redis_check_conn(struct redis *r) {
gettimeofday(&rtpe_now, NULL); gettimeofday(&rtpe_now, NULL);
if ((r->state == REDIS_STATE_DISCONNECTED) && (r->restore_tick > rtpe_now.tv_sec)) { if ((r->state == REDIS_STATE_DISCONNECTED) && (r->restore_tick > rtpe_now.tv_sec)) {
ilog(LOG_WARNING, "Redis server %s is disabled. Don't try RE-Establishing for %" TIME_T_INT_FMT " more seconds",
endpoint_print_buf(&r->endpoint),r->restore_tick - rtpe_now.tv_sec);
ilog(LOG_WARNING, "Redis server '%s' is disabled. Don't try RE-Establishing for %" TIME_T_INT_FMT " more seconds",
r->hostname, r->restore_tick - rtpe_now.tv_sec);
return REDIS_STATE_DISCONNECTED; return REDIS_STATE_DISCONNECTED;
} }
if (r->state == REDIS_STATE_DISCONNECTED) if (r->state == REDIS_STATE_DISCONNECTED)
ilog(LOG_INFO, "RE-Establishing connection for Redis server %s",endpoint_print_buf(&r->endpoint));
ilog(LOG_INFO, "RE-Establishing connection for Redis server '%s'", r->hostname);
// try redis connection // try redis connection
if (r->ctx && redisCommandNR(r->ctx, "PING") == 0) { if (r->ctx && redisCommandNR(r->ctx, "PING") == 0) {
@ -987,8 +987,8 @@ static int redis_check_conn(struct redis *r) {
// redis is disconnected // redis is disconnected
if (r->state == REDIS_STATE_CONNECTED) { if (r->state == REDIS_STATE_CONNECTED) {
rlog(LOG_ERR, "Lost connection to Redis %s",
endpoint_print_buf(&r->endpoint));
rlog(LOG_ERR, "Lost connection to Redis '%s'",
r->hostname);
r->state = REDIS_STATE_DISCONNECTED; r->state = REDIS_STATE_DISCONNECTED;
} }


Loading…
Cancel
Save