mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2024-12-14 11:58:02 +00:00
chore: Split --cluster_announce_ip
and --replica_announce_ip
(#3615)
chore: Split `cluster_announce_ip` and `replica_announce_ip` This PR partially reverts #3421 Fixes #3541
This commit is contained in:
parent
10de338926
commit
de5ecc7447
10 changed files with 15 additions and 26 deletions
|
@ -113,7 +113,7 @@ Dragonfly 特有の議論もある:
|
|||
* `admin_bind`: 管理コンソールの TCP 接続を指定されたアドレスにバインドする(`default: any`)。HTTP と RESP の両方のプロトコルをサポートする。
|
||||
* `admin_nopass`: 割り当てられたポートで、認証トークンなしでコンソールへのオープン管理アクセスを有効にする (`default: false`)。HTTP と RESP の両方のプロトコルをサポートする。
|
||||
* `cluster_mode`: サポートするクラスターモード (`default: ""`)。現在は `emulated` のみをサポートしている。
|
||||
* `announce_ip`: クラスタコマンドがクライアントにアナウンスする IP。
|
||||
* `cluster_announce_ip`: クラスタコマンドがクライアントにアナウンスする IP。
|
||||
|
||||
### 一般的なオプションを使用した開始スクリプトの例:
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ Dragonfly는 현재 아래와 같은 Redis 인수들을 지원합니다 :
|
|||
* `admin_bind`: 주어진 주소에 관리자 콘솔 TCP 연결을 바인딩합니다. (`기본값: any`). HTTP와 RESP 프로토콜 모두를 지원합니다.
|
||||
* `admin_nopass`: 할당된 포트에 대해서 인증 토큰 없이 관리자 콘솔 접근을 활성화합니다. (`default: false`). HTTP와 RESP 프로토콜 모두를 지원합니다.
|
||||
* `cluster_mode`: 클러스터 모드가 지원됩니다. (`기본값: ""`). 현재는`emulated` 만 지원합니다.
|
||||
* `announce_ip`: 클러스터 명령을 클라이언트에게 알리는 IP 주소.
|
||||
* `cluster_announce_ip`: 클러스터 명령을 클라이언트에게 알리는 IP 주소.
|
||||
|
||||
|
||||
### 주요 옵션을 활용한 실행 스크립트 예시:
|
||||
|
|
|
@ -166,7 +166,7 @@ There are also some Dragonfly-specific arguments:
|
|||
* `admin_bind`: To bind the admin console TCP connection to a given address (`default: any`). Supports both HTTP and RESP protocols.
|
||||
* `admin_nopass`: To enable open admin access to console on the assigned port, without auth token needed (`default: false`). Supports both HTTP and RESP protocols.
|
||||
* `cluster_mode`: Cluster mode supported (`default: ""`). Currently supports only `emulated`.
|
||||
* `announce_ip`: The IP that cluster commands announce to the client, and to replication master.
|
||||
* `cluster_announce_ip`: The IP that cluster commands announce to the client.
|
||||
* `announce_port`: The port that cluster commands announce to the client, and to replication master.
|
||||
|
||||
### Example start script with popular options:
|
||||
|
|
|
@ -135,7 +135,7 @@ Dragonfly 支持 Redis 的常见参数。
|
|||
|
||||
* `cluster_mode`:支持集群模式。目前仅支持 `emulated`。默认为空 `""`。
|
||||
|
||||
* `announce_ip`:集群模式下向客户端公开的 IP。
|
||||
* `cluster_announce_ip`:集群模式下向客户端公开的 IP。
|
||||
|
||||
### 启动脚本示例,包含常用选项:
|
||||
|
||||
|
|
|
@ -26,14 +26,14 @@
|
|||
#include "server/server_state.h"
|
||||
#include "util/fibers/synchronization.h"
|
||||
|
||||
ABSL_FLAG(std::string, cluster_announce_ip, "", "DEPRECATED: use --announce_ip");
|
||||
ABSL_FLAG(std::string, cluster_announce_ip, "",
|
||||
"IP address that Dragonfly announces to cluster clients");
|
||||
|
||||
ABSL_FLAG(std::string, cluster_node_id, "",
|
||||
"ID within a cluster, used for slot assignment. MUST be unique. If empty, uses master "
|
||||
"replication ID (random string)");
|
||||
|
||||
ABSL_DECLARE_FLAG(int32_t, port);
|
||||
ABSL_DECLARE_FLAG(std::string, announce_ip);
|
||||
ABSL_DECLARE_FLAG(uint16_t, announce_port);
|
||||
|
||||
namespace dfly {
|
||||
|
@ -70,16 +70,6 @@ ClusterFamily::ClusterFamily(ServerFamily* server_family) : server_family_(serve
|
|||
|
||||
InitializeCluster();
|
||||
|
||||
// TODO: Remove flag cluster_announce_ip in v1.23+
|
||||
if (!absl::GetFlag(FLAGS_cluster_announce_ip).empty()) {
|
||||
CHECK(absl::GetFlag(FLAGS_announce_ip).empty())
|
||||
<< "Can't use both --cluster_announce_ip and --announce_ip";
|
||||
|
||||
LOG(WARNING) << "WARNING: Flag --cluster_announce_ip is deprecated in favor of --announce_ip. "
|
||||
"Use the latter, as the former will be removed in a future release.";
|
||||
absl::SetFlag(&FLAGS_announce_ip, absl::GetFlag(FLAGS_cluster_announce_ip));
|
||||
}
|
||||
|
||||
id_ = absl::GetFlag(FLAGS_cluster_node_id);
|
||||
if (id_.empty()) {
|
||||
id_ = server_family_->master_replid();
|
||||
|
@ -119,7 +109,7 @@ ClusterShardInfo ClusterFamily::GetEmulatedShardInfo(ConnectionContext* cntx) co
|
|||
ServerState& etl = *ServerState::tlocal();
|
||||
if (!replication_info.has_value()) {
|
||||
DCHECK(etl.is_master);
|
||||
std::string cluster_announce_ip = absl::GetFlag(FLAGS_announce_ip);
|
||||
std::string cluster_announce_ip = absl::GetFlag(FLAGS_cluster_announce_ip);
|
||||
std::string preferred_endpoint =
|
||||
cluster_announce_ip.empty() ? cntx->conn()->LocalBindAddress() : cluster_announce_ip;
|
||||
uint16_t cluster_announce_port = absl::GetFlag(FLAGS_announce_port);
|
||||
|
|
|
@ -696,7 +696,7 @@ class ClusterFamilyEmulatedTest : public ClusterFamilyTest {
|
|||
public:
|
||||
ClusterFamilyEmulatedTest() {
|
||||
SetTestFlag("cluster_mode", "emulated");
|
||||
SetTestFlag("announce_ip", "fake-host");
|
||||
SetTestFlag("cluster_announce_ip", "fake-host");
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -68,8 +68,6 @@ using facade::ErrorReply;
|
|||
ABSL_FLAG(int32_t, port, 6379,
|
||||
"Redis port. 0 disables the port, -1 will bind on a random available port.");
|
||||
|
||||
ABSL_FLAG(std::string, announce_ip, "",
|
||||
"IP address that Dragonfly announces to cluster clients and replication master");
|
||||
ABSL_FLAG(uint16_t, announce_port, 0,
|
||||
"Port that Dragonfly announces to cluster clients and replication master");
|
||||
|
||||
|
|
|
@ -41,9 +41,10 @@ ABSL_FLAG(bool, replica_partial_sync, true,
|
|||
ABSL_FLAG(bool, break_replication_on_master_restart, false,
|
||||
"When in replica mode, and master restarts, break replication from master to avoid "
|
||||
"flushing the replica's data.");
|
||||
ABSL_FLAG(std::string, replica_announce_ip, "",
|
||||
"IP address that Dragonfly announces to replication master");
|
||||
ABSL_DECLARE_FLAG(int32_t, port);
|
||||
ABSL_DECLARE_FLAG(uint16_t, announce_port);
|
||||
ABSL_DECLARE_FLAG(std::string, announce_ip);
|
||||
ABSL_FLAG(
|
||||
int, replica_priority, 100,
|
||||
"Published by info command for sentinel to pick replica based on score during a failover");
|
||||
|
@ -287,7 +288,7 @@ error_code Replica::Greet() {
|
|||
RETURN_ON_ERR(SendCommandAndReadResponse(StrCat("REPLCONF listening-port ", port)));
|
||||
PC_RETURN_ON_BAD_RESPONSE(CheckRespIsSimpleReply("OK"));
|
||||
|
||||
auto announce_ip = absl::GetFlag(FLAGS_announce_ip);
|
||||
auto announce_ip = absl::GetFlag(FLAGS_replica_announce_ip);
|
||||
if (!announce_ip.empty()) {
|
||||
RETURN_ON_ERR(SendCommandAndReadResponse(StrCat("REPLCONF ip-address ", announce_ip)));
|
||||
LOG_IF(WARNING, !CheckRespIsSimpleReply("OK"))
|
||||
|
|
|
@ -213,7 +213,7 @@ class TestEmulated:
|
|||
|
||||
# Unfortunately we can't test --announce_port here because that causes the Python Cluster client to
|
||||
# throw if it can't access the port in `CLUSTER SLOTS` :|
|
||||
@dfly_args({"cluster_mode": "emulated", "announce_ip": "127.0.0.2"})
|
||||
@dfly_args({"cluster_mode": "emulated", "cluster_announce_ip": "127.0.0.2"})
|
||||
class TestEmulatedWithAnnounceIp:
|
||||
def test_cluster_slots_command(self, df_server, cluster_client: redis.RedisCluster):
|
||||
expected = {(0, 16383): {"primary": ("127.0.0.2", df_server.port), "replicas": []}}
|
||||
|
@ -361,7 +361,7 @@ async def test_cluster_info(async_client):
|
|||
}
|
||||
|
||||
|
||||
@dfly_args({"cluster_mode": "emulated", "announce_ip": "127.0.0.2"})
|
||||
@dfly_args({"cluster_mode": "emulated", "cluster_announce_ip": "127.0.0.2"})
|
||||
@pytest.mark.asyncio
|
||||
async def test_cluster_nodes(df_server, async_client):
|
||||
res = await async_client.execute_command("CLUSTER NODES")
|
||||
|
|
|
@ -2321,7 +2321,7 @@ async def test_replica_reconnect(df_factory, break_conn):
|
|||
@pytest.mark.asyncio
|
||||
async def test_announce_ip_port(df_factory):
|
||||
master = df_factory.create()
|
||||
replica = df_factory.create(announce_ip="overrode-host", announce_port="1337")
|
||||
replica = df_factory.create(replica_announce_ip="overrode-host", announce_port="1337")
|
||||
|
||||
master.start()
|
||||
replica.start()
|
||||
|
@ -2418,7 +2418,7 @@ async def test_replicate_old_master(
|
|||
released_dfly_path = download_dragonfly_release(dfly_version)
|
||||
master = df_factory.create(version=1.19, path=released_dfly_path, cluster_mode=cluster_mode)
|
||||
replica = df_factory.create(
|
||||
cluster_mode=cluster_mode, announce_ip=announce_ip, announce_port=announce_port
|
||||
cluster_mode=cluster_mode, cluster_announce_ip=announce_ip, announce_port=announce_port
|
||||
)
|
||||
|
||||
df_factory.start_all([master, replica])
|
||||
|
|
Loading…
Reference in a new issue