diff --git a/src/meta/processors/admin/HBProcessor.cpp b/src/meta/processors/admin/HBProcessor.cpp index ef2e05c5e6c..8ea50161c68 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 12313ad9090..82c98b8fdbb 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 77a4d515e44..cdaea37a938 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 417e279f9ea..b05e0c16e1e 100644 --- a/src/meta/test/ProcessorTest.cpp +++ b/src/meta/test/ProcessorTest.cpp @@ -2677,6 +2677,7 @@ TEST(ProcessorTest, TagIdAndEdgeTypeInSpaceRangeTest) { } TEST(ProcessorTest, HostsTest) { + FLAGS_hosts_whitelist_enabled = false; fs::TempDir rootPath("/tmp/HostsTest.XXXXXX"); auto kv = MockCluster::initMetaKV(rootPath.path()); { @@ -2878,6 +2879,7 @@ TEST(ProcessorTest, HostsTest) { } TEST(ProcessorTest, AddHostsIntoNewZoneTest) { + FLAGS_hosts_whitelist_enabled = false; fs::TempDir rootPath("/tmp/AddHostsIntoZoneTest.XXXXXX"); auto kv = MockCluster::initMetaKV(rootPath.path()); { @@ -2979,6 +2981,7 @@ TEST(ProcessorTest, AddHostsIntoNewZoneTest) { } TEST(ProcessorTest, AddHostsIntoZoneTest) { + FLAGS_hosts_whitelist_enabled = false; fs::TempDir rootPath("/tmp/AddHostsIntoZoneTest.XXXXXX"); auto kv = MockCluster::initMetaKV(rootPath.path()); { @@ -3149,6 +3152,7 @@ TEST(ProcessorTest, AddHostsIntoZoneTest) { } TEST(ProcessorTest, DropHostsTest) { + FLAGS_hosts_whitelist_enabled = false; fs::TempDir rootPath("/tmp/DropHostsTest.XXXXXX"); auto kv = MockCluster::initMetaKV(rootPath.path()); {