Skip to content

Commit

Permalink
Replace masteruser and masterauth with primaryuser and primaryauth (v…
Browse files Browse the repository at this point in the history
…alkey-io#598)

Make the one backwards compatible config change we are allowed to
replace for removing master from our API.

`masterauth` and `masteruser` are still used as an alias, but aren't
explicitly referenced. As an addendum to
valkey-io#591, it would be good to have
this in 8. Given the related PR for updated other references for master,
I just updated the ones around this specific change.

Signed-off-by: Madelyn Olson <[email protected]>
  • Loading branch information
madolson authored Jun 7, 2024
1 parent ad5fd5b commit bce240e
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 24 deletions.
4 changes: 2 additions & 2 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -3059,7 +3059,7 @@ standardConfig static_configs[] = {
createStringConfig("unixsocket", NULL, IMMUTABLE_CONFIG, EMPTY_STRING_IS_NULL, server.unixsocket, NULL, NULL, NULL),
createStringConfig("pidfile", NULL, IMMUTABLE_CONFIG, EMPTY_STRING_IS_NULL, server.pidfile, NULL, NULL, NULL),
createStringConfig("replica-announce-ip", "slave-announce-ip", MODIFIABLE_CONFIG, EMPTY_STRING_IS_NULL, server.slave_announce_ip, NULL, NULL, NULL),
createStringConfig("masteruser", NULL, MODIFIABLE_CONFIG | SENSITIVE_CONFIG, EMPTY_STRING_IS_NULL, server.masteruser, NULL, NULL, NULL),
createStringConfig("primaryuser", "masteruser", MODIFIABLE_CONFIG | SENSITIVE_CONFIG, EMPTY_STRING_IS_NULL, server.masteruser, NULL, NULL, NULL),
createStringConfig("cluster-announce-ip", NULL, MODIFIABLE_CONFIG, EMPTY_STRING_IS_NULL, server.cluster_announce_ip, NULL, NULL, updateClusterIp),
createStringConfig("cluster-config-file", NULL, IMMUTABLE_CONFIG, ALLOW_EMPTY_STRING, server.cluster_configfile, "nodes.conf", NULL, NULL),
createStringConfig("cluster-announce-hostname", NULL, MODIFIABLE_CONFIG, EMPTY_STRING_IS_NULL, server.cluster_announce_hostname, NULL, isValidAnnouncedHostname, updateClusterHostname),
Expand All @@ -3082,7 +3082,7 @@ standardConfig static_configs[] = {
createStringConfig("locale-collate", NULL, MODIFIABLE_CONFIG, ALLOW_EMPTY_STRING, server.locale_collate, "", NULL, updateLocaleCollate),

/* SDS Configs */
createSDSConfig("masterauth", NULL, MODIFIABLE_CONFIG | SENSITIVE_CONFIG, EMPTY_STRING_IS_NULL, server.masterauth, NULL, NULL, NULL),
createSDSConfig("primaryauth", "masterauth", MODIFIABLE_CONFIG | SENSITIVE_CONFIG, EMPTY_STRING_IS_NULL, server.masterauth, NULL, NULL, NULL),
createSDSConfig("requirepass", NULL, MODIFIABLE_CONFIG | SENSITIVE_CONFIG, EMPTY_STRING_IS_NULL, server.requirepass, NULL, NULL, updateRequirePass),

/* Enum Configs */
Expand Down
1 change: 1 addition & 0 deletions src/valkey-cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -3161,6 +3161,7 @@ static int isSensitiveCommand(int argc, char **argv) {
} else if (argc > 2 && !strcasecmp(argv[0], "config") && !strcasecmp(argv[1], "set")) {
for (int j = 2; j < argc; j = j + 2) {
if (!strcasecmp(argv[j], "masterauth") || !strcasecmp(argv[j], "masteruser") ||
!strcasecmp(argv[j], "primaryuser") || !strcasecmp(argv[j], "primaryauth") ||
!strcasecmp(argv[j], "tls-key-file-pass") || !strcasecmp(argv[j], "tls-client-key-file-pass") ||
!strcasecmp(argv[j], "requirepass")) {
return 1;
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/valkey-benchmark.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ tags {"benchmark network external:skip logreqres:skip"} {
}

test {benchmark: connecting using URI with authentication set,get} {
r config set masterauth pass
r config set primaryauth pass
set cmd [valkeybenchmarkuriuserpass $master_host $master_port "default" pass "-c 5 -n 10 -t set,get"]
common_bench_setup $cmd
default_set_get_checks
Expand Down Expand Up @@ -145,7 +145,7 @@ tags {"benchmark network external:skip logreqres:skip"} {
}

test {benchmark: tls connecting using URI with authentication set,get} {
r config set masterauth pass
r config set primaryauth pass
set cmd [valkeybenchmarkuriuserpass $master_host $master_port "default" pass "-c 5 -n 10 -t set,get"]
common_bench_setup $cmd
default_set_get_checks
Expand Down
12 changes: 6 additions & 6 deletions tests/sentinel/tests/03-runtime-reconf.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ proc server_set_password {} {
foreach_valkey_id id {
assert_equal {OK} [R $id CONFIG SET requirepass $::password]
assert_equal {OK} [R $id AUTH $::password]
assert_equal {OK} [R $id CONFIG SET masterauth $::password]
assert_equal {OK} [R $id CONFIG SET primaryauth $::password]
}
}

proc server_reset_password {} {
foreach_valkey_id id {
assert_equal {OK} [R $id CONFIG SET requirepass ""]
assert_equal {OK} [R $id CONFIG SET masterauth ""]
assert_equal {OK} [R $id CONFIG SET primaryauth ""]
}
}

Expand All @@ -26,16 +26,16 @@ proc server_set_acl {id} {

R $id CLIENT KILL USER default SKIPME no
assert_equal {OK} [R $id AUTH $::user $::password]
assert_equal {OK} [R $id CONFIG SET masteruser $::user]
assert_equal {OK} [R $id CONFIG SET masterauth $::password]
assert_equal {OK} [R $id CONFIG SET primaryuser $::user]
assert_equal {OK} [R $id CONFIG SET primaryauth $::password]
}

proc server_reset_acl {id} {
assert_equal {OK} [R $id ACL SETUSER default on]
assert_equal {1} [R $id ACL DELUSER $::user]

assert_equal {OK} [R $id CONFIG SET masteruser ""]
assert_equal {OK} [R $id CONFIG SET masterauth ""]
assert_equal {OK} [R $id CONFIG SET primaryuser ""]
assert_equal {OK} [R $id CONFIG SET primaryauth ""]
}

proc verify_sentinel_connect_replicas {id} {
Expand Down
12 changes: 6 additions & 6 deletions tests/unit/auth.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -59,26 +59,26 @@ start_server {tags {"auth_binary_password external:skip"}} {
r auth "abc\x00def"
} {OK}

start_server {tags {"masterauth"}} {
start_server {tags {"primaryauth"}} {
set master [srv -1 client]
set master_host [srv -1 host]
set master_port [srv -1 port]
set slave [srv 0 client]

test {MASTERAUTH test with binary password} {
test {primaryauth test with binary password} {
$master config set requirepass "abc\x00def"

# Configure the replica with masterauth
# Configure the replica with primaryauth
set loglines [count_log_lines 0]
$slave config set masterauth "abc"
$slave config set primaryauth "abc"
$slave slaveof $master_host $master_port

# Verify replica is not able to sync with master
wait_for_log_messages 0 {"*Unable to AUTH to MASTER*"} $loglines 1000 10
assert_equal {down} [s 0 master_link_status]

# Test replica with the correct masterauth
$slave config set masterauth "abc\x00def"
# Test replica with the correct primaryauth
$slave config set primaryauth "abc\x00def"
wait_for_condition 50 100 {
[s 0 master_link_status] eq {up}
} else {
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/slowlog.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ start_server {tags {"slowlog"} overrides {slowlog-log-slower-than 1000000}} {
r config set slowlog-log-slower-than 0
r slowlog reset
catch {r acl setuser "slowlog test user" +get +set} _
r config set masteruser ""
r config set masterauth ""
r config set primaryuser ""
r config set primaryauth ""
r config set requirepass ""
r config set tls-key-file-pass ""
r config set tls-client-key-file-pass ""
Expand All @@ -81,8 +81,8 @@ start_server {tags {"slowlog"} overrides {slowlog-log-slower-than 1000000}} {
assert_equal 11 [llength $slowlog_resp]
assert_equal {slowlog reset} [lindex [lindex $slowlog_resp 10] 3]
assert_equal {acl setuser (redacted) (redacted) (redacted)} [lindex [lindex $slowlog_resp 9] 3]
assert_equal {config set masteruser (redacted)} [lindex [lindex $slowlog_resp 8] 3]
assert_equal {config set masterauth (redacted)} [lindex [lindex $slowlog_resp 7] 3]
assert_equal {config set primaryuser (redacted)} [lindex [lindex $slowlog_resp 8] 3]
assert_equal {config set primaryauth (redacted)} [lindex [lindex $slowlog_resp 7] 3]
assert_equal {config set requirepass (redacted)} [lindex [lindex $slowlog_resp 6] 3]
assert_equal {config set tls-key-file-pass (redacted)} [lindex [lindex $slowlog_resp 5] 3]
assert_equal {config set tls-client-key-file-pass (redacted)} [lindex [lindex $slowlog_resp 4] 3]
Expand Down
8 changes: 4 additions & 4 deletions valkey.conf
Original file line number Diff line number Diff line change
Expand Up @@ -544,17 +544,17 @@ dir ./
# starting the replication synchronization process, otherwise the master will
# refuse the replica request.
#
# masterauth <master-password>
# primaryauth <primary-password>
#
# However this is not enough if you are using ACLs
# and the default user is not capable of running the PSYNC
# command and/or other commands needed for replication. In this case it's
# better to configure a special user to use with replication, and specify the
# masteruser configuration as such:
# primaryuser configuration as such:
#
# masteruser <username>
# primaryuser <username>
#
# When masteruser is specified, the replica will authenticate against its
# When primaryuser is specified, the replica will authenticate against its
# master using the new AUTH form: AUTH <username> <password>.

# When a replica loses its connection with the master, or when the replication
Expand Down

0 comments on commit bce240e

Please sign in to comment.