Skip to content

Commit

Permalink
fix drop host from a zone
Browse files Browse the repository at this point in the history
  • Loading branch information
darionyaphet committed Sep 16, 2021
1 parent 5905860 commit 0064080
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/meta/processors/zone/UpdateZoneProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,43 @@ void DropHostFromZoneProcessor::process(const cpp2::DropHostFromZoneReq& req) {
return;
}

const auto& spacePrefix = MetaServiceUtils::spacePrefix();
auto spaceIterRet = doPrefix(spacePrefix);
auto spaceIter = nebula::value(spaceIterRet).get();
while (spaceIter->valid()) {
auto spaceId = MetaServiceUtils::spaceId(spaceIter->key());
auto spaceKey = MetaServiceUtils::spaceKey(spaceId);
auto ret = doGet(spaceKey);
if (!nebula::ok(ret)) {
auto retCode = nebula::error(ret);
LOG(ERROR) << "Get Space " << spaceId
<< " error: " << apache::thrift::util::enumNameSafe(retCode);
handleErrorCode(retCode);
onFinished();
return;
}

auto properties = MetaServiceUtils::parseSpace(nebula::value(ret));
if (!properties.group_name_ref().has_value()) {
continue;
}

const auto& partPrefix = MetaServiceUtils::partPrefix(spaceId);
auto partIterRet = doPrefix(partPrefix);
auto partIter = nebula::value(partIterRet).get();
while (partIter->valid()) {
auto partHosts = MetaServiceUtils::parsePartVal(partIter->val());
for (auto& h : partHosts) {
if (h == req.get_node()) {
LOG(ERROR) << h << " is related with partition";
handleErrorCode(nebula::cpp2::ErrorCode::E_CONFLICT);
onFinished();
return;
}
}
}
}

auto hosts = MetaServiceUtils::parseZoneHosts(std::move(nebula::value(zoneValueRet)));
auto host = req.get_node();
auto iter = std::find(hosts.begin(), hosts.end(), host);
Expand Down

0 comments on commit 0064080

Please sign in to comment.