Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
e8771efd
Unverified
Commit
e8771efd
authored
Mar 16, 2022
by
Madelyn Olson
Committed by
GitHub
Mar 16, 2022
Browse files
Fixed incorrect parsing of hostname information from nodes.conf (#10435)
parent
69017fa2
Changes
2
Show whitespace changes
Inline
Side-by-side
src/cluster.c
View file @
e8771efd
...
...
@@ -219,6 +219,17 @@ int clusterLoadConfig(char *filename) {
/* Format for the node address information:
* ip:port[@cport][,hostname] */
/* Hostname is an optional argument that defines the endpoint
* that can be reported to clients instead of IP. */
char
*
hostname
=
strchr
(
argv
[
1
],
','
);
if
(
hostname
)
{
*
hostname
=
'\0'
;
hostname
++
;
n
->
hostname
=
sdscpy
(
n
->
hostname
,
hostname
);
}
else
if
(
sdslen
(
n
->
hostname
)
!=
0
)
{
sdsclear
(
n
->
hostname
);
}
/* Address and port */
if
((
p
=
strrchr
(
argv
[
1
],
':'
))
==
NULL
)
{
sdsfreesplitres
(
argv
,
argc
);
...
...
@@ -238,17 +249,6 @@ int clusterLoadConfig(char *filename) {
* base port. */
n
->
cport
=
busp
?
atoi
(
busp
)
:
n
->
port
+
CLUSTER_PORT_INCR
;
/* Hostname is an optional argument that defines the endpoint
* that can be reported to clients instead of IP. */
char
*
hostname
=
strchr
(
p
,
','
);
if
(
hostname
)
{
*
hostname
=
'\0'
;
hostname
++
;
n
->
hostname
=
sdscpy
(
n
->
hostname
,
hostname
);
}
else
if
(
sdslen
(
n
->
hostname
)
!=
0
)
{
sdsclear
(
n
->
hostname
);
}
/* The plaintext port for client in a TLS cluster (n->pport) is not
* stored in nodes.conf. It is received later over the bus protocol. */
...
...
tests/cluster/tests/27-endpoints.tcl
View file @
e8771efd
...
...
@@ -197,6 +197,9 @@ test "Verify the nodes configured with prefer hostname only show hostname for ne
test
"Test restart will keep hostname information"
{
# Set a new hostname, reboot and make sure it sticks
R 0 config set cluster-announce-hostname
"restart-1.com"
# Store the hostname in the config
R 0 config rewrite
kill_instance redis 0
restart_instance redis 0
set slot_result
[
R 0 CLUSTER SLOTS
]
assert_equal
[
lindex
[
get_slot_field $slot_result 0 2 3
]
1
]
"restart-1.com"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment