From 7dacaed98368ec0790c9e18a63dfa0035a31fcff Mon Sep 17 00:00:00 2001 From: Nim Wijetunga Date: Fri, 21 Oct 2022 17:24:27 -0700 Subject: [PATCH] add domain name asserts (#8534) --- .../include/fdbclient/GetEncryptCipherKeys.actor.h | 7 ++++++- fdbserver/EncryptKeyProxy.actor.cpp | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/fdbclient/include/fdbclient/GetEncryptCipherKeys.actor.h b/fdbclient/include/fdbclient/GetEncryptCipherKeys.actor.h index 257aeea723..6f82b3bba1 100644 --- a/fdbclient/include/fdbclient/GetEncryptCipherKeys.actor.h +++ b/fdbclient/include/fdbclient/GetEncryptCipherKeys.actor.h @@ -104,6 +104,11 @@ Future>> getL // Collect cached cipher keys. for (auto& domain : domains) { + if (domain.first == FDB_DEFAULT_ENCRYPT_DOMAIN_ID) { + ASSERT(domain.second == FDB_DEFAULT_ENCRYPT_DOMAIN_NAME); + } else if (domain.first == SYSTEM_KEYSPACE_ENCRYPT_DOMAIN_ID) { + ASSERT(domain.second == FDB_SYSTEM_KEYSPACE_ENCRYPT_DOMAIN_NAME); + } Reference cachedCipherKey = cipherKeyCache->getLatestCipherKey(domain.first /*domainId*/); if (cachedCipherKey.isValid()) { cipherKeys[domain.first] = cachedCipherKey; @@ -301,7 +306,7 @@ template Future getLatestSystemEncryptCipherKeys(const Reference const>& db, BlobCipherMetrics::UsageType usageType) { return getLatestEncryptCipherKeysForDomain( - db, SYSTEM_KEYSPACE_ENCRYPT_DOMAIN_ID, FDB_DEFAULT_ENCRYPT_DOMAIN_NAME, usageType); + db, SYSTEM_KEYSPACE_ENCRYPT_DOMAIN_ID, FDB_SYSTEM_KEYSPACE_ENCRYPT_DOMAIN_NAME, usageType); } ACTOR template diff --git a/fdbserver/EncryptKeyProxy.actor.cpp b/fdbserver/EncryptKeyProxy.actor.cpp index 9556c86fdc..095f3fb386 100644 --- a/fdbserver/EncryptKeyProxy.actor.cpp +++ b/fdbserver/EncryptKeyProxy.actor.cpp @@ -388,6 +388,15 @@ ACTOR Future getCipherKeysByBaseCipherKeyIds(Reference getLatestCipherKeys(Reference ekpProxyDa try { KmsConnLookupEKsByDomainIdsReq keysByDomainIdReq; for (const auto& item : lookupCipherDomains) { + if (item.second.domainId == FDB_DEFAULT_ENCRYPT_DOMAIN_ID) { + ASSERT(item.second.domainName == FDB_DEFAULT_ENCRYPT_DOMAIN_NAME); + } else if (item.second.domainId == SYSTEM_KEYSPACE_ENCRYPT_DOMAIN_ID) { + ASSERT(item.second.domainName == FDB_SYSTEM_KEYSPACE_ENCRYPT_DOMAIN_NAME); + } keysByDomainIdReq.encryptDomainInfos.emplace_back_deep( keysByDomainIdReq.arena, item.second.domainId, item.second.domainName); }