From 2beee553da7f2b98b1702f5fd16523c14f16eea9 Mon Sep 17 00:00:00 2001 From: "endy.li" <25311962+heroicNeZha@users.noreply.github.com> Date: Thu, 16 Dec 2021 22:15:46 +0800 Subject: [PATCH] save client version (#3483) --- src/clients/meta/MetaClient.cpp | 1 + src/interface/meta.thrift | 3 ++- .../processors/admin/VerifyClientVersionProcessor.cpp | 9 +++++---- src/meta/test/VerifyClientVersionTest.cpp | 3 ++- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/clients/meta/MetaClient.cpp b/src/clients/meta/MetaClient.cpp index 98504ab0782..89d53914aa6 100644 --- a/src/clients/meta/MetaClient.cpp +++ b/src/clients/meta/MetaClient.cpp @@ -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> promise; auto future = promise.getFuture(); diff --git a/src/interface/meta.thrift b/src/interface/meta.thrift index 6b3fe96a08c..353940088b8 100644 --- a/src/interface/meta.thrift +++ b/src/interface/meta.thrift @@ -1123,8 +1123,9 @@ struct VerifyClientVersionResp { struct VerifyClientVersionReq { - 1: required binary version = common.version; + 1: required binary client_version = common.version; 2: common.HostAddr host; + 3: binary build_version; } service MetaService { diff --git a/src/meta/processors/admin/VerifyClientVersionProcessor.cpp b/src/meta/processors/admin/VerifyClientVersionProcessor.cpp index d7328b5b145..84b84141fff 100644 --- a/src/meta/processors/admin/VerifyClientVersionProcessor.cpp +++ b/src/meta/processors/admin/VerifyClientVersionProcessor.cpp @@ -18,16 +18,17 @@ void VerifyClientVersionProcessor::process(const cpp2::VerifyClientVersionReq& r std::unordered_set whiteList; folly::splitTo( ":", 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_client_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_client_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 versionData; versionData.emplace_back(std::move(versionKey), std::move(versionVal)); doSyncPut(versionData); diff --git a/src/meta/test/VerifyClientVersionTest.cpp b/src/meta/test/VerifyClientVersionTest.cpp index 9f72f559e00..a72d6757ffa 100644 --- a/src/meta/test/VerifyClientVersionTest.cpp +++ b/src/meta/test/VerifyClientVersionTest.cpp @@ -20,7 +20,8 @@ TEST(VerifyClientVersionTest, VersionTest) { std::unique_ptr kv(MockCluster::initMetaKV(rootPath.path())); { auto req = cpp2::VerifyClientVersionReq(); - req.set_version("1.0.1"); + req.set_client_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);