diff options
author | serg-belyakov <[email protected]> | 2023-09-03 01:57:31 +0300 |
---|---|---|
committer | serg-belyakov <[email protected]> | 2023-09-03 02:25:28 +0300 |
commit | 0531e5183a5b52efaed1637b34bec77b7685e971 (patch) | |
tree | 35679e6dcc83d4d98f6600d4a9828215ef1e72ab | |
parent | be3c963ebd666dd5265ad5750187b833f22b4045 (diff) |
Allow compatibility between non-stable versions of different applications, KIKIMR-19228
Fix PDisk UT
Allow compatibility between non-stable versions of different applications
-rw-r--r-- | ydb/core/blobstorage/pdisk/blobstorage_pdisk_ut.cpp | 4 | ||||
-rw-r--r-- | ydb/core/driver_lib/version/ut/version_ut.cpp | 28 | ||||
-rw-r--r-- | ydb/core/driver_lib/version/version.cpp | 35 |
3 files changed, 47 insertions, 20 deletions
diff --git a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_ut.cpp b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_ut.cpp index 315e5991456..db94a5dd9a1 100644 --- a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_ut.cpp +++ b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_ut.cpp @@ -957,10 +957,10 @@ Y_UNIT_TEST_SUITE(TPDiskTest) { Y_UNIT_TEST(YdbVersionTrunk) { TestRestartWithDifferentVersion( TCompatibilityInfo::TProtoConstructor::TCurrentCompatibilityInfo{ - .Application = "trunk", + .Application = "ydb", }.ToPB(), TCompatibilityInfo::TProtoConstructor::TCurrentCompatibilityInfo{ - .Application = "trunk", + .Application = "ydb", }.ToPB(), true ); diff --git a/ydb/core/driver_lib/version/ut/version_ut.cpp b/ydb/core/driver_lib/version/ut/version_ut.cpp index 4b013f56a9a..883484e9aa8 100644 --- a/ydb/core/driver_lib/version/ut/version_ut.cpp +++ b/ydb/core/driver_lib/version/ut/version_ut.cpp @@ -603,7 +603,6 @@ Y_UNIT_TEST_SUITE(YdbVersion) { ); } - Y_UNIT_TEST(YDBAndNbs) { Test( TCurrentCompatibilityInfo{ @@ -669,6 +668,31 @@ Y_UNIT_TEST_SUITE(YdbVersion) { ); } + Y_UNIT_TEST(TrunkYDBAndNbs) { + Test( + TCurrentCompatibilityInfo{ + .Application = "ydb", + }, + TCurrentCompatibilityInfo{ + .Application = "nbs", + }, + true, + EComponentId::Interconnect + ); + } + Y_UNIT_TEST(TrunkAndStable) { + Test( + TCurrentCompatibilityInfo{ + .Application = "ydb", + }, + TCurrentCompatibilityInfo{ + .Application = "ydb", + .Version = TVersion{ .Year = 24, .Major = 3, .Minor = 1, .Hotfix = 0 }, + }, + false + ); + } + Y_UNIT_TEST(CompatibleWithSelf) { auto stored = CompatibilityInfo.MakeStored(EComponentId::Test1); TString errorReason; @@ -753,7 +777,7 @@ Y_UNIT_TEST_SUITE(OldFormat) { Y_UNIT_TEST(Trunk) { TestOldFormat( TCurrentCompatibilityInfo{ - .Application = "trunk" + .Application = "ydb" }, TOldFormat{ .Tag = "trunk", diff --git a/ydb/core/driver_lib/version/version.cpp b/ydb/core/driver_lib/version/version.cpp index a1acbb84674..4d38e3b91d4 100644 --- a/ydb/core/driver_lib/version/version.cpp +++ b/ydb/core/driver_lib/version/version.cpp @@ -23,7 +23,7 @@ TCompatibilityInfo::TCompatibilityInfo() { // Current CompatibilityInfo ///////////////////////////////////////////////////////// auto current = TCurrentConstructor{ - .Application = "trunk" + .Application = "ydb" }.ToPB(); // bool success = CompleteFromTag(current); @@ -226,14 +226,13 @@ bool CheckNonPresent(const TCurrent* current, TComponentId componentId, TString& } } -// By default two stable versions are considered compatible, if their Year is the same -// and Major differ for no more, than 1, regardless of their Application -// Two unstable versions are compatible only if they have the same Application -// Stable and non-stable versions are not compatible by default -bool CheckDefaultRules(TString currentApplication, const NKikimrConfig::TYdbVersion* currentVersion, - TString storedApplication, const NKikimrConfig::TYdbVersion* storedVersion) { +// Default rules: +// Two stable versions are compatible if their Year's are the same and their Major's differ for no more, than 1. +// Two unstable versions are compatible. +// Stable and non-stable versions are not compatible. +bool CheckDefaultRules(const NKikimrConfig::TYdbVersion* currentVersion, const NKikimrConfig::TYdbVersion* storedVersion) { if (!currentVersion && !storedVersion) { - return currentApplication == storedApplication; + return true; } if (currentVersion && storedVersion) { if (!currentVersion->HasYear() || !storedVersion->HasYear()) { @@ -255,22 +254,26 @@ bool CheckRule(std::optional<TString> app, const NKikimrConfig::TYdbVersion* ver if (app) { if (rule.HasApplication()) { if (rule.GetApplication() != *app) { + // this rule is not applicable to different application return false; } - if (version == nullptr) { + if (!version) { + // rule for stable versions is not applicable to trunk return true; } } else { - // non-stable app is incompatible with stable - if (version == nullptr) { + if (!version) { + // rule for stable versions is not applicable to trunk return false; } } } else { - if (version == nullptr) { + if (!version) { + // neither application nor version is set, should not reach here return false; } if (rule.HasApplication()) { + // only rules, which are common to all applications, apply to version with no application info return false; } } @@ -281,7 +284,7 @@ bool CheckRule(std::optional<TString> app, const NKikimrConfig::TYdbVersion* ver bool TCompatibilityInfo::CheckCompatibility(const TCurrent* current, const TStored* stored, TComponentId componentId, TString& errorReason) const { Y_VERIFY(current); - if (stored == nullptr) { + if (!stored) { // version record is not found return CheckNonPresent(current, componentId, errorReason); } @@ -326,7 +329,7 @@ bool TCompatibilityInfo::CheckCompatibility(const TCurrent* current, const TStor if (permitted) { return true; } else { - if (CheckDefaultRules(currentApplication, currentVersion, storedApplication, storedVersion)) { + if (CheckDefaultRules(currentVersion, storedVersion)) { return true; } else { errorReason = "Versions are not compatible neither by common rule nor by provided rule sets, " @@ -564,8 +567,8 @@ bool TCompatibilityInfo::CheckCompatibility(const TCurrent* current, const TOldF auto peerVersion = ParseVersionFromTag(peer.Tag); if (!peerVersion) { - // non-stable version is peer - if (current->GetApplication() == peer.Tag) { + if (!current->HasVersion()) { + // both peer and current versions are non-stable return true; } peerApplication = peer.Tag; |