diff options
author | Vitalii Gridnev <gridnevvvit@gmail.com> | 2022-05-25 14:48:14 +0300 |
---|---|---|
committer | Vitalii Gridnev <gridnevvvit@gmail.com> | 2022-05-25 14:48:14 +0300 |
commit | a25da15cf6dbdf1966fa910ed67aadad39bb4735 (patch) | |
tree | 53649aa5270f5df8794860ea274c6720d405775c | |
parent | 803656542095cbb4c59293e740c0abc1cad37706 (diff) | |
download | ydb-a25da15cf6dbdf1966fa910ed67aadad39bb4735.tar.gz |
add program name to version info in node whiteboard KIKIMR-14877
ref:35df528e1afef928e26df1332acea616e2b58526
-rw-r--r-- | ydb/core/tablet/node_whiteboard.cpp | 56 |
1 files changed, 43 insertions, 13 deletions
diff --git a/ydb/core/tablet/node_whiteboard.cpp b/ydb/core/tablet/node_whiteboard.cpp index 783758e99d1..43ddac370fd 100644 --- a/ydb/core/tablet/node_whiteboard.cpp +++ b/ydb/core/tablet/node_whiteboard.cpp @@ -12,6 +12,8 @@ #include <ydb/core/base/counters.h> #include <ydb/core/util/tuples.h> +#include <util/string/split.h> + using namespace NActors; namespace NKikimr { @@ -41,20 +43,8 @@ public: TabletIntrospectionData.Reset(NTracing::CreateTraceCollection(introspectionGroup)); SystemStateInfo.SetNumberOfCpus(NSystemInfo::NumberOfCpus()); - TString branch = GetTag(); - if (branch.empty()) { - branch = GetBranch(); - } - auto pos = branch.rfind('/'); - if (pos != TString::npos) { // only the part after the last slash is used - branch = branch.substr(pos + 1); - } - TString version = GetProgramCommitId(); + auto version = GetProgramRevision(); if (!version.empty()) { - if (version.size() > 7) { // we limit the version size to 7 characters (the same way as in Arcanum) - version = version.substr(0, 7); - } - version = branch + '.' + version; SystemStateInfo.SetVersion(version); auto versionCounter = GetServiceCounters(AppData(ctx)->Counters, "utils")->GetSubgroup("revision", version); *versionCounter->GetCounter("version", false) = 1; @@ -85,6 +75,46 @@ protected: static_cast<std::make_signed_t<PropertyType>>(a))); } + static TString GetProgramRevision() { + TString version = GetTag(); + if (version.empty()) { + version = GetBranch(); + } + + if (!version.empty() && version.StartsWith("tags/releases/")) { + TVector<TString> parts = StringSplitter(version).Split('/'); + auto rIt = parts.rbegin(); + if (rIt == parts.rend()) + return {}; + + version = *rIt; + rIt++; + + if (rIt != parts.rend() && !rIt->empty()) { + version = (*rIt) + '-' + version; + } + + return version; + } + + version = GetBranch(); + auto pos = version.rfind('/'); + if (pos != TString::npos) { + version = version.substr(pos + 1); + } + + TString commitId = GetProgramCommitId(); + if (!commitId.empty()) { + if (commitId.size() > 7) { + commitId = commitId.substr(0, 7); + } + + version = version + '.' + commitId; + } + + return version; + } + static ui64 GetDifference(double a, double b) { return static_cast<ui64>(std::fabs(b - a)); } |