From d9ae6c57cde849476a295593c98f675714145097 Mon Sep 17 00:00:00 2001 From: Donat Zenichev Date: Wed, 27 Nov 2024 09:49:30 +0100 Subject: [PATCH] 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 --- daemon/redis.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/daemon/redis.c b/daemon/redis.c index b626a502a..0abd1603e 100644 --- a/daemon/redis.c +++ b/daemon/redis.c @@ -966,13 +966,13 @@ static int redis_check_conn(struct redis *r) { gettimeofday(&rtpe_now, NULL); 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; } 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 if (r->ctx && redisCommandNR(r->ctx, "PING") == 0) { @@ -987,8 +987,8 @@ static int redis_check_conn(struct redis *r) { // redis is disconnected 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; }