Skip to content

Commit

Permalink
Support auto regist (#3548)
Browse files Browse the repository at this point in the history
Co-authored-by: shylock <33566796+Shylock-Hg@users.noreply.github.com>
  • Loading branch information
darionyaphet and Shylock-Hg authored Dec 29, 2021
1 parent fedffc8 commit 6849383
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 @@ -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());
{
Expand Down Expand Up @@ -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());
{
Expand Down Expand Up @@ -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());
{
Expand Down Expand Up @@ -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());
{
Expand Down

0 comments on commit 6849383

Please sign in to comment.