Skip to content

Commit a16b622

Browse files
committed
Make VERIFY more verbose
1 parent 57845e2 commit a16b622

File tree

3 files changed

+60
-4
lines changed

3 files changed

+60
-4
lines changed

ydb/core/blobstorage/dsproxy/dsproxy_state.cpp

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,33 @@ namespace NKikimr {
122122

123123
Send(MonActor, new TEvBlobStorage::TEvConfigureProxy(Info, nullptr));
124124
if (Info) {
125-
Y_ABORT_UNLESS(!EncryptionMode || *EncryptionMode == Info->GetEncryptionMode());
126-
Y_ABORT_UNLESS(!LifeCyclePhase || *LifeCyclePhase == Info->GetLifeCyclePhase());
127-
Y_ABORT_UNLESS(!GroupKeyNonce || *GroupKeyNonce == Info->GetGroupKeyNonce());
128-
Y_ABORT_UNLESS(!CypherKey || *CypherKey == *Info->GetCypherKey());
125+
auto printOptional = [&](const auto& val) -> TString {
126+
using T = std::decay_t<decltype(*val)>;
127+
if (!val) {
128+
return "<nullopt>";
129+
} else {
130+
if constexpr(std::is_same_v<T, ui64>) {
131+
return IntToString<10>(*val);
132+
}
133+
if constexpr(std::is_same_v<T, TBlobStorageGroupInfo::EEncryptionMode>) {
134+
return TBlobStorageGroupInfo::PrintEncryptionMode(*val);
135+
}
136+
if constexpr(std::is_same_v<T, TBlobStorageGroupInfo::ELifeCyclePhase>) {
137+
return TBlobStorageGroupInfo::PrintLifeCyclePhase(*val);
138+
}
139+
// we don't want to print CypherKey value!
140+
return "<value>";
141+
}
142+
};
143+
144+
Y_VERIFY_S(!EncryptionMode || *EncryptionMode == Info->GetEncryptionMode(),
145+
"EncryptionMode# " << printOptional(EncryptionMode) << " Info# " << Info->ToString());
146+
Y_VERIFY_S(!LifeCyclePhase || *LifeCyclePhase == Info->GetLifeCyclePhase(),
147+
"LifeCyclePhase# " << printOptional(LifeCyclePhase) << " Info# " << Info->ToString());
148+
Y_VERIFY_S(!GroupKeyNonce || *GroupKeyNonce == Info->GetGroupKeyNonce(),
149+
"GroupKeyNonce# " << printOptional(GroupKeyNonce) << " Info# " << Info->ToString());
150+
Y_VERIFY_S(!CypherKey || *CypherKey == *Info->GetCypherKey(),
151+
"CypherKey# " << printOptional(CypherKey) << " Info# " << Info->ToString());
129152
EncryptionMode = Info->GetEncryptionMode();
130153
LifeCyclePhase = Info->GetLifeCyclePhase();
131154
GroupKeyNonce = Info->GetGroupKeyNonce();

ydb/core/blobstorage/groupinfo/blobstorage_groupinfo.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -977,6 +977,9 @@ TString TBlobStorageGroupInfo::ToString() const {
977977
str << " GroupGeneration# " << GroupGeneration;
978978
str << " Type# " << Type.ToString();
979979
str << " SizeInUnits# " << GroupSizeInUnits;
980+
str << " EncryptionMode# " << PrintEncryptionMode(EncryptionMode) << Endl;
981+
str << " LifeCyclePhase# " << PrintLifeCyclePhase(LifeCyclePhase) << Endl;
982+
str << " GroupKeyNonce# " << GroupKeyNonce << Endl;
980983
str << " FailRealms# {";
981984
for (ui32 realmIdx = 0; realmIdx < Topology->FailRealms.size(); ++realmIdx) {
982985
const TFailRealm& realm = Topology->FailRealms[realmIdx];

ydb/core/blobstorage/groupinfo/blobstorage_groupinfo.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,15 @@ class TBlobStorageGroupInfo : public TThrRefBase {
106106
EEM_ENC_V1 = 1 // Encryption at proxy level, no MAC, no CRC
107107
};
108108

109+
static TString PrintEncryptionMode(EEncryptionMode mode) {
110+
switch (mode) {
111+
case EEncryptionMode::EEM_NONE:
112+
return "NONE";
113+
case EEncryptionMode::EEM_ENC_V1:
114+
return "ENC_V1";
115+
}
116+
}
117+
109118
// INITIAL upon group creation in base and in memory
110119
// PROPOSE comes from the node warden when it proposes after getting INITIAL
111120
// INITIAL -> IN_TRANSITION in memory state from transaction start to transaction end
@@ -121,6 +130,27 @@ class TBlobStorageGroupInfo : public TThrRefBase {
121130
ELCP_KEY_NOT_LOADED = 703,
122131
};
123132

133+
static TString PrintLifeCyclePhase(ELifeCyclePhase phase) {
134+
switch (phase) {
135+
case ELifeCyclePhase::ELCP_INITIAL:
136+
return "INITIAL";
137+
case ELifeCyclePhase::ELCP_PROPOSE:
138+
return "PROPOSE";
139+
case ELifeCyclePhase::ELCP_IN_TRANSITION:
140+
return "IN_TRANSITION";
141+
case ELifeCyclePhase::ELCP_IN_USE:
142+
return "IN_USE";
143+
case ELifeCyclePhase::ELCP_KEY_CRC_ERROR:
144+
return "KEY_CRC_ERROR";
145+
case ELifeCyclePhase::ELCP_KEY_VERSION_ERROR:
146+
return "KEY_VERSION_ERROR";
147+
case ELifeCyclePhase::ELCP_KEY_ID_ERROR:
148+
return "KEY_ID_ERROR";
149+
case ELifeCyclePhase::ELCP_KEY_NOT_LOADED:
150+
return "KEY_NOT_LOADED";
151+
}
152+
}
153+
124154
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
125155
// SUBSET HELPER CLASSES
126156
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)