Add hostname support in Sentinel.#8282
Conversation
This is both a bugfix and an enhancement. Internally, Sentinel relies entirely on IP addressess to identify instances. When configured with a new master, it also requires users to specify and IP and not hostname. However, replicas may use the replica-announce-ip configuration to announce a hostname. When that happens, Sentinel fails to match the announced hostname with the expected IP and considers that a different instance, trigerring reconfiguration, etc. Another use case is where TLS is used and clients are expected to match the hostname to connect to with the certificate's SAN attribute. To properly implement this configuration, it is necessary for Sentinel to redirect clients to a hostname rather than an IP address. The new 'resolve-hostnames' configuration parameter determines if Sentinel is willing to accept hostnames. It is set by default to no, which maintains backwards compatibility and avoids unexpected DNS resolution delays on systems with DNS configuration issues. Internally, Sentinel contineus to identify instances by their resolved IP address and will also report the IP by default. The new 'announce-hostnames' parameter determines if Sentinel should prefer to announce a hostname, when available, rather than an IP address. This applies to addresses returned to clients, as well as their representation in the configuration file, REPLICAOF configuration commands, etc. This commit also introduces SENTINEL CONFIG GET and SENTINEL CONFIG SET which can be used to introspect or configure global Sentinel configuration that was previously was only possible by directly accessing the configuration file and possibly restarting the instance. Co-authored-by: myl1024 <myl92916@qq.com>
|
Pinging @hwware, would really appreciate your review on this one. I had limited bandwidth to promote this and don't feel familiar enough with all potential aspects of Sentinel. Thank you! |
|
I haven't reviewed the code, but i noticed that sentinel.conf is unmodified (that's where the new config, and it's implications (DNS resolution delays?) should be mentioned) |
|
Hi @yossigo i will take look the code and help for reviewing this one, thanks! |
* Fix messed up formatting * Use dupSentinelAddr where possible
Also, adds tests for sentinel-user and sentinel-pass usage with Sentinel ACL configuration.
Co-authored-by: sundb <sundbcn@gmail.com>
oranagra
left a comment
There was a problem hiding this comment.
This is both a bugfix and an enhancement.
is there a simple bug fix here that can be separated from the big feature? or is the big feature what's fixing the bug? if there is, i think we may want to first make a PR with the bugfix so that it can be cherry picked to 6.0?
|
|
||
| test "SENTINEL CONFIG SET handles on-the-fly credentials reconfiguration" { | ||
| # Make sure we're starting with a broken state... | ||
| after 5000 |
There was a problem hiding this comment.
these long sleeps (the one below too) are not a wise idea, they'll slow down the whole test suite by 10 seconds.
if we keep adding more more of these we'll eventually suffer greatly.
i think we need to work hard to resist these and find other solutions.
can't that be changed to some wait_for that will usually exit a lot sooner?
There was a problem hiding this comment.
I agree, I think this comment is true in general for both sentinel and cluster tests but it'll require some tinkering.
|
@oranagra regarding your other comment, the bug is the fact that Redis instances themselves may use hostnames and Sentinel will do the wrong thing. There's no way to fix that without adding this capability. A potential backport could be to just produce a big error and bail out but I don't consider this a better experience. |
|
@redis/core-team Please approve.
|
madolson
left a comment
There was a problem hiding this comment.
Interface LGTM, did not look through the code.
|
@itamarhaber @yossigo who's making a doc PR? |
|
@oranagra I'll do that |
|
Hi @yossigo, Am I correct assuming that this PR is going to be included into Redis 6.2 release? |
|
@mabrarov yes. |
|
Hi. I just tested The setup is 3 pairs of redis + sentinel. Each pair is on a separate host. Initial config:
Also, on each sentinel I set: No IP addresses are mentioned in config files. Only hostnames. After the startup redis2 and redis3 are successfully become replicas of redis1, perform a full sync. So the startup seems OK. Then I execute Redis1 is not switched to replica. |
|
@bofm Do you see anything in the logfiles of |
The last messages are these ones from the moment when redis1 woke up from that 30 seconds sleep.
Yes. Redis-cli-pinging redis2 and redis3 works on redis1:
Every time sentinel1 is logging It looks like something is missing inside the MULTI-EXEC. |
|
Another thing I noticed is that config rewrite on sentinel generates duplicated lines related to resolve-hostnames and announce-hostnames parameters in the config: |
|
The problem was that maxmemory was 100mb and every command resulted in OOM error. I'm sorry. Though it is quite surprising that 100mb is not enough for an empty Redis to work properly. |
|
@bofm It should be enough, perhaps you should include the output of |
This is both a bugfix and an enhancement. Internally, Sentinel relies entirely on IP addresses to identify instances. When configured with a new master, it also requires users to specify and IP and not hostname. However, replicas may use the replica-announce-ip configuration to announce a hostname. When that happens, Sentinel fails to match the announced hostname with the expected IP and considers that a different instance, triggering reconfiguration, etc. Another use case is where TLS is used and clients are expected to match the hostname to connect to with the certificate's SAN attribute. To properly implement this configuration, it is necessary for Sentinel to redirect clients to a hostname rather than an IP address. The new 'resolve-hostnames' configuration parameter determines if Sentinel is willing to accept hostnames. It is set by default to no, which maintains backwards compatibility and avoids unexpected DNS resolution delays on systems with DNS configuration issues. Internally, Sentinel continues to identify instances by their resolved IP address and will also report the IP by default. The new 'announce-hostnames' parameter determines if Sentinel should prefer to announce a hostname, when available, rather than an IP address. This applies to addresses returned to clients, as well as their representation in the configuration file, REPLICAOF configuration commands, etc. This commit also introduces SENTINEL CONFIG GET and SENTINEL CONFIG SET which can be used to introspect or configure global Sentinel configuration that was previously was only possible by directly accessing the configuration file and possibly restarting the instance. Co-authored-by: myl1024 <myl92916@qq.com> Co-authored-by: sundb <sundbcn@gmail.com>
|
This test failed tonight on MacOS: @hwware maybe you can look into it. |
|
@oranagra ack |
This is both a bugfix and an enhancement.
Internally, Sentinel relies entirely on IP addressess to identify
instances. When configured with a new master, it also requires users to
specify and IP and not hostname.
However, replicas may use the replica-announce-ip configuration to
announce a hostname. When that happens, Sentinel fails to match the
announced hostname with the expected IP and considers that a different
instance, trigerring reconfiguration, etc.
Another use case is where TLS is used and clients are expected to match
the hostname to connect to with the certificate's SAN attribute. To
properly implement this configuration, it is necessary for Sentinel to
redirect clients to a hostname rather than an IP address.
The new 'resolve-hostnames' configuration parameter determines if
Sentinel is willing to accept hostnames. It is set by default to no,
which maintains backwards compatibility and avoids unexpected DNS
resolution delays on systems with DNS configuration issues.
Internally, Sentinel contineus to identify instances by their resolved
IP address and will also report the IP by default. The new
'announce-hostnames' parameter determines if Sentinel should prefer to
announce a hostname, when available, rather than an IP address. This
applies to addresses returned to clients, as well as their
representation in the configuration file, REPLICAOF configuration
commands, etc.
This commit also introduces SENTINEL CONFIG GET and SENTINEL CONFIG SET
which can be used to introspect or configure global Sentinel
configuration that was previously was only possible by directly
accessing the configuration file and possibly restarting the instance.
Fixes #7758, #7393, #2118, #7928
Co-authored-by: myl1024 myl92916@qq.com