using dns address for the configuration of "sentinel announce-ip" and "replicaof"#7393
using dns address for the configuration of "sentinel announce-ip" and "replicaof"#7393myl1024 wants to merge 2 commits into
Conversation
…tname (or DNS address), the hostname should be converted to ip before searching for the sentinel instance or judging a slave`s master
|
Calling for review @yossigo @oranagra @itamarhaber @soloestoy @madolson |
|
@myl1024 thanks! Did you consider the alternative approach of retaining the hostname so it can be compared later on? This might prove to be a more robust approach in case of DNS hiccups, etc. |
|
@yossigo, thank you for your reply.
|
|
@myl1024 I had a quick look into this. I generally think the solution you're proposing is in the right direction, but it may not be enough -- I suspect the problem of mixing IPs and hostnames is more wide spread and has greater implications. For example, consider this snippet which I suspect could lead to having the same instance listed twice (if it was previously known by its hostname): /* Check if we already have this slave into our table,
* otherwise add it. */
if (sentinelRedisInstanceLookupSlave(ri,ip,atoi(port)) == NULL) {
if ((slave = createSentinelRedisInstance(NULL,SRI_SLAVE,ip,
atoi(port), ri->quorum, ri)) != NULL)
{
sentinelEvent(LL_NOTICE,"+slave",slave,"%@");
sentinelFlushConfig();
}
} I'd consider addressing this with these steps:
|
|
@yossigo I studied your reply carefully and did some experiments, and found that sentinel did list the redis slave instance twice after failover. I checked the code and found that it is caused by the following code: In the above code, when I use "replica-announce-ip redis-1-svc" to configure a redis instance, the key of this redis instance saved in sentinel is "redis-1-svc:6379" (hostname:port). When switching master, the "ip:port" of the redis slave instance is used as the key to recreate the slave of new master, the code is as follows. This causing sentinel lists the redis slave instance twice after failover. Based on the above problems, we re-modified the code to perform address conversion (hostname->ip) when saving the redis slave instance, uniformly use "ip:port" as the key of the slave instance, and also use "ip:port" as the key to search for the slave instance. We tested the modified code using the following cases:
We reorganized the code and submitted it with a new PR (#7758), looking forward to your review again. |
When we deploy redis in kubernetes, each pod corresponds to a redis instance or sentinel instance, using the dns address as the pod's fixed external address, we found:
So, in these scenarios, should first convert the dns address (or hostname) to the ip address.