Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add availability_zone to the HELLO response #1487

Merged
merged 4 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/networking.c
Original file line number Diff line number Diff line change
Expand Up @@ -4195,7 +4195,7 @@ void helloCommand(client *c) {

/* Let's switch to the specified RESP mode. */
if (ver) c->resp = ver;
addReplyMapLen(c, 6 + !server.sentinel_mode);
addReplyMapLen(c, 6 + !server.sentinel_mode + (sdslen(server.availability_zone) != 0));

addReplyBulkCString(c, "server");
addReplyBulkCString(c, server.extended_redis_compat ? "redis" : SERVER_NAME);
Expand Down Expand Up @@ -4224,6 +4224,11 @@ void helloCommand(client *c) {

addReplyBulkCString(c, "modules");
addReplyLoadedModules(c);

if (sdslen(server.availability_zone) != 0) {
addReplyBulkCString(c, "availability_zone");
addReplyBulkCBuffer(c, server.availability_zone, sdslen(server.availability_zone));
}
hpatro marked this conversation as resolved.
Show resolved Hide resolved
}

/* This callback is bound to POST and "Host:" command names. Those are not
Expand Down
26 changes: 26 additions & 0 deletions tests/unit/protocol.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,32 @@ start_server {tags {"protocol network"}} {

}

start_server {tags {"protocol hello"}} {
test {HELLO without protover} {
set reply [r HELLO 3]
assert_equal [dict get $reply proto] 3

set reply [r HELLO]
assert_equal [dict get $reply proto] 3

set reply [r HELLO 2]
enjoy-binbin marked this conversation as resolved.
Show resolved Hide resolved
assert_equal [dict get $reply proto] 2

set reply [r HELLO]
assert_equal [dict get $reply proto] 2
}

test {HELLO and availability-zone} {
r CONFIG SET availability-zone myzone

set reply [r HELLO 3]
assert_equal [dict get $reply availability_zone] myzone

set reply [r HELLO 2]
assert_equal [dict get $reply availability_zone] myzone
enjoy-binbin marked this conversation as resolved.
Show resolved Hide resolved
}
}

start_server {tags {"regression"}} {
test "Regression for a crash with blocking ops and pipelining" {
set rd [valkey_deferring_client]
Expand Down
17 changes: 0 additions & 17 deletions tests/unit/tracking.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -154,23 +154,6 @@ start_server {tags {"tracking network logreqres:skip"}} {
assert_equal [dict get $reply proto] 3
}

test {HELLO without protover} {
set reply [r HELLO 3]
assert_equal [dict get $reply proto] 3

set reply [r HELLO]
assert_equal [dict get $reply proto] 3

set reply [r HELLO 2]
assert_equal [dict get $reply proto] 2

set reply [r HELLO]
assert_equal [dict get $reply proto] 2

# restore RESP3 for next test
r HELLO 3
}

test {RESP3 based basic invalidation} {
r CLIENT TRACKING off
r CLIENT TRACKING on
Expand Down
Loading