Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

save client version #3483

Merged
merged 2 commits into from
Dec 16, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
3 changes: 2 additions & 1 deletion 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;
1: required binary client_version = common.version;
2: common.HostAddr host;
3: binary build_version;
HarrisChu marked this conversation as resolved.
Show resolved Hide resolved
}

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_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<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_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);
Expand Down