From 68493839c619872725ba96388cca5c3e7792e8d4 Mon Sep 17 00:00:00 2001 From: yaphet <4414314+darionyaphet@users.noreply.github.com> Date: Wed, 29 Dec 2021 12:55:34 +0800 Subject: [PATCH] Support auto regist (#3548) Co-authored-by: shylock <33566796+Shylock-Hg@users.noreply.github.com> --- src/meta/processors/admin/HBProcessor.cpp | 4 +++- src/meta/processors/admin/HBProcessor.h | 2 ++ src/meta/test/HBProcessorTest.cpp | 1 + src/meta/test/ProcessorTest.cpp | 4 ++++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/meta/processors/admin/HBProcessor.cpp b/src/meta/processors/admin/HBProcessor.cpp index 7e78aba9732..2012e42e251 100644 --- a/src/meta/processors/admin/HBProcessor.cpp +++ b/src/meta/processors/admin/HBProcessor.cpp @@ -10,6 +10,8 @@ #include "meta/KVBasedClusterIdMan.h" #include "meta/MetaVersionMan.h" +DEFINE_bool(hosts_whitelist_enabled, true, "Automatically receive the heartbeat report"); + namespace nebula { namespace meta { @@ -34,7 +36,7 @@ void HBProcessor::process(const cpp2::HBReq& req) { << ", role = " << apache::thrift::util::enumNameSafe(role); if (role == cpp2::HostRole::STORAGE) { - if (!ActiveHostsMan::machineRegisted(kvstore_, host)) { + if (!FLAGS_hosts_whitelist_enabled && !ActiveHostsMan::machineRegisted(kvstore_, host)) { LOG(ERROR) << "Machine " << host << " is not registed"; handleErrorCode(nebula::cpp2::ErrorCode::E_MACHINE_NOT_FOUND); onFinished(); diff --git a/src/meta/processors/admin/HBProcessor.h b/src/meta/processors/admin/HBProcessor.h index 4fde1b03bac..4974f781c77 100644 --- a/src/meta/processors/admin/HBProcessor.h +++ b/src/meta/processors/admin/HBProcessor.h @@ -11,6 +11,8 @@ #include "common/stats/StatsManager.h" #include "meta/processors/BaseProcessor.h" +DECLARE_bool(hosts_whitelist_enabled); + namespace nebula { namespace meta { diff --git a/src/meta/test/HBProcessorTest.cpp b/src/meta/test/HBProcessorTest.cpp index bbd619d579a..0773294711a 100644 --- a/src/meta/test/HBProcessorTest.cpp +++ b/src/meta/test/HBProcessorTest.cpp @@ -15,6 +15,7 @@ namespace nebula { namespace meta { TEST(HBProcessorTest, HBTest) { + FLAGS_hosts_whitelist_enabled = false; fs::TempDir rootPath("/tmp/HBTest.XXXXXX"); std::unique_ptr kv(MockCluster::initMetaKV(rootPath.path())); diff --git a/src/meta/test/ProcessorTest.cpp b/src/meta/test/ProcessorTest.cpp index f2f5d918e3d..74e5cc092b4 100644 --- a/src/meta/test/ProcessorTest.cpp +++ b/src/meta/test/ProcessorTest.cpp @@ -2680,6 +2680,7 @@ TEST(ProcessorTest, TagIdAndEdgeTypeInSpaceRangeTest) { } TEST(ProcessorTest, HostsTest) { + FLAGS_hosts_whitelist_enabled = false; fs::TempDir rootPath("/tmp/HostsTest.XXXXXX"); auto kv = MockCluster::initMetaKV(rootPath.path()); { @@ -2881,6 +2882,7 @@ TEST(ProcessorTest, HostsTest) { } TEST(ProcessorTest, AddHostsIntoNewZoneTest) { + FLAGS_hosts_whitelist_enabled = false; fs::TempDir rootPath("/tmp/AddHostsIntoZoneTest.XXXXXX"); auto kv = MockCluster::initMetaKV(rootPath.path()); { @@ -2982,6 +2984,7 @@ TEST(ProcessorTest, AddHostsIntoNewZoneTest) { } TEST(ProcessorTest, AddHostsIntoZoneTest) { + FLAGS_hosts_whitelist_enabled = false; fs::TempDir rootPath("/tmp/AddHostsIntoZoneTest.XXXXXX"); auto kv = MockCluster::initMetaKV(rootPath.path()); { @@ -3152,6 +3155,7 @@ TEST(ProcessorTest, AddHostsIntoZoneTest) { } TEST(ProcessorTest, DropHostsTest) { + FLAGS_hosts_whitelist_enabled = false; fs::TempDir rootPath("/tmp/DropHostsTest.XXXXXX"); auto kv = MockCluster::initMetaKV(rootPath.path()); {