Skip to content

Commit

Permalink
Support auto regist
Browse files Browse the repository at this point in the history
  • Loading branch information
darionyaphet committed Dec 24, 2021
1 parent 5d5f841 commit 3af8b80
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/meta/processors/admin/HBProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions src/meta/processors/admin/HBProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include "common/stats/StatsManager.h"
#include "meta/processors/BaseProcessor.h"

DECLARE_bool(hosts_whitelist_enabled);

namespace nebula {
namespace meta {

Expand Down
1 change: 1 addition & 0 deletions src/meta/test/HBProcessorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<kvstore::KVStore> kv(MockCluster::initMetaKV(rootPath.path()));

Expand Down
4 changes: 4 additions & 0 deletions src/meta/test/ProcessorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
{
Expand Down Expand Up @@ -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());
{
Expand Down Expand Up @@ -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());
{
Expand Down Expand Up @@ -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());
{
Expand Down

0 comments on commit 3af8b80

Please sign in to comment.