Skip to content

Commit

Permalink
save client version
Browse files Browse the repository at this point in the history
  • Loading branch information
heroicNeZha committed Dec 16, 2021
1 parent 75f1112 commit ae5ae3e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/clients/meta/MetaClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3554,6 +3554,7 @@ bool MetaClient::checkIsPlanKilled(SessionID sessionId, ExecutionPlanID planId)

Status MetaClient::verifyVersion() {
auto req = cpp2::VerifyClientVersionReq();
req.set_build_version(getOriginVersion());
req.set_host(options_.localHost_);
folly::Promise<StatusOr<cpp2::VerifyClientVersionResp>> promise;
auto future = promise.getFuture();
Expand Down
5 changes: 3 additions & 2 deletions src/interface/meta.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -1123,8 +1123,9 @@ struct VerifyClientVersionResp {


struct VerifyClientVersionReq {
1: required binary version = common.version;
2: common.HostAddr host;
1: required binary thrift_version = common.version;
2: binary build_version;
3: common.HostAddr host;
}

service MetaService {
Expand Down
9 changes: 5 additions & 4 deletions src/meta/processors/admin/VerifyClientVersionProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,17 @@ void VerifyClientVersionProcessor::process(const cpp2::VerifyClientVersionReq& r
std::unordered_set<std::string> whiteList;
folly::splitTo<std::string>(
":", FLAGS_client_white_list, std::inserter(whiteList, whiteList.begin()));
if (FLAGS_enable_client_white_list && whiteList.find(req.get_version()) == whiteList.end()) {
if (FLAGS_enable_client_white_list &&
whiteList.find(req.get_thrift_version()) == whiteList.end()) {
resp_.set_code(nebula::cpp2::ErrorCode::E_CLIENT_SERVER_INCOMPATIBLE);
resp_.set_error_msg(folly::stringPrintf(
"Meta client version(%s) is not accepted, current meta client white list: %s.",
req.get_version().c_str(),
req.get_thrift_version().c_str(),
FLAGS_client_white_list.c_str()));
} else {
auto host = req.get_host();
const auto& host = req.get_host();
auto versionKey = MetaKeyUtils::versionKey(host);
auto versionVal = MetaKeyUtils::versionVal(req.get_version().c_str());
auto versionVal = MetaKeyUtils::versionVal(req.get_build_version().c_str());
std::vector<kvstore::KV> versionData;
versionData.emplace_back(std::move(versionKey), std::move(versionVal));
doSyncPut(versionData);
Expand Down
3 changes: 2 additions & 1 deletion src/meta/test/VerifyClientVersionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ TEST(VerifyClientVersionTest, VersionTest) {
std::unique_ptr<kvstore::KVStore> kv(MockCluster::initMetaKV(rootPath.path()));
{
auto req = cpp2::VerifyClientVersionReq();
req.set_version("1.0.1");
req.set_thrift_version("1.0.1");
req.set_build_version("1.0.1-nightly");
auto* processor = VerifyClientVersionProcessor::instance(kv.get());
auto f = processor->getFuture();
processor->process(req);
Expand Down

0 comments on commit ae5ae3e

Please sign in to comment.