Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sharpeye committed Dec 6, 2024
1 parent f9b68c1 commit 6d6be47
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 19 deletions.
27 changes: 11 additions & 16 deletions cloud/blockstore/libs/storage/service/service_actor_create.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
#include <util/generic/size_literals.h>
#include <util/string/ascii.h>

#include <optional>

namespace NCloud::NBlockStore::NStorage {

using namespace NActors;
Expand Down Expand Up @@ -58,7 +56,7 @@ class TCreateVolumeActor final
void CreateVolume(const TActorContext& ctx);
void CreateVolumeImpl(
const TActorContext& ctx,
std::optional<NKikimrBlockStore::TEncryptionDesc> encryptionDesc);
NKikimrBlockStore::TEncryptionDesc encryptionDesc);

void HandleDescribeVolumeResponse(
const TEvSSProxy::TEvDescribeVolumeResponse::TPtr& ev,
Expand Down Expand Up @@ -179,21 +177,20 @@ void TCreateVolumeActor::CreateVolume(const TActorContext& ctx)
return;
}

std::optional<NKikimrBlockStore::TEncryptionDesc> encryptionDesc;
NKikimrBlockStore::TEncryptionDesc encryptionDesc;

const auto& encryptionSpec = Request.GetEncryptionSpec();
if (encryptionSpec.GetMode() != NProto::NO_ENCRYPTION) {
auto& desc = encryptionDesc.emplace();
desc.SetMode(encryptionSpec.GetMode());
desc.SetKeyHash(encryptionSpec.GetKeyHash());
encryptionDesc.SetMode(encryptionSpec.GetMode());
encryptionDesc.SetKeyHash(encryptionSpec.GetKeyHash());
}

CreateVolumeImpl(ctx, std::move(encryptionDesc));
}

void TCreateVolumeActor::CreateVolumeImpl(
const TActorContext& ctx,
std::optional<NKikimrBlockStore::TEncryptionDesc> encryptionDesc)
NKikimrBlockStore::TEncryptionDesc encryptionDesc)
{
NKikimrBlockStore::TVolumeConfig config;

Expand Down Expand Up @@ -285,14 +282,14 @@ void TCreateVolumeActor::CreateVolumeImpl(
}
config.MutableAgentIds()->CopyFrom(Request.GetAgentIds());

if (encryptionDesc) {
if (encryptionDesc.GetMode() != NProto::NO_ENCRYPTION) {
LOG_DEBUG_S(
ctx,
TBlockStoreComponents::SERVICE,
"Creating volume with an encryption: "
<< NProto::EEncryptionMode_Name(encryptionDesc->GetMode()));
<< NProto::EEncryptionMode_Name(encryptionDesc.GetMode()));

*config.MutableEncryptionDesc() = std::move(*encryptionDesc);
*config.MutableEncryptionDesc() = std::move(encryptionDesc);
}

auto request = std::make_unique<TEvSSProxy::TEvCreateVolumeRequest>(
Expand All @@ -315,8 +312,6 @@ void TCreateVolumeActor::HandleCreateEncryptionKeyResponse(
{
const auto& msg = *ev->Get();

std::optional<NKikimrBlockStore::TEncryptionDesc> encryptionDesc;

if (const auto& error = msg.GetError(); HasError(error)) {
LOG_ERROR_S(
ctx,
Expand All @@ -335,10 +330,10 @@ void TCreateVolumeActor::HandleCreateEncryptionKeyResponse(
"Create volume " << Request.GetDiskId().Quote()
<< " with default AES XTS encryption");

auto& desc = encryptionDesc.emplace();
desc.SetMode(NProto::ENCRYPTION_DEFAULT_AES_XTS);
NKikimrBlockStore::TEncryptionDesc encryptionDesc;
encryptionDesc.SetMode(NProto::ENCRYPTION_DEFAULT_AES_XTS);

auto& dek = *desc.MutableEncryptedDataKey();
auto& dek = *encryptionDesc.MutableEncryptedDataKey();
dek.SetKekId(msg.KmsKey.GetKekId());
dek.SetCiphertext(msg.KmsKey.GetEncryptedDEK());

Expand Down
4 changes: 1 addition & 3 deletions cloud/blockstore/tests/python/lib/nbs_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ def __init__(
if self.__server_app_config is None or self.__server_app_config.HasField('KikimrServiceConfig'):
self.init_scheme()

self.__has_root_kms = False
root_kms_port = os.environ.get("FAKE_ROOT_KMS_PORT")
if root_kms_port is not None:
root_kms = TRootKmsConfig()
Expand All @@ -157,7 +156,6 @@ def __init__(
root_kms.CertChainFile = os.environ.get("FAKE_ROOT_KMS_CLIENT_CRT")
root_kms.PrivateKeyFile = os.environ.get("FAKE_ROOT_KMS_CLIENT_KEY")
self.__proto_configs['root-kms.txt'] = root_kms
self.__has_root_kms = True

self.__access_service = None
if enable_access_service:
Expand Down Expand Up @@ -595,7 +593,7 @@ def append_conf_file_arg(command, config_path, option_name, conf_file):
if self.kms_config is not None:
command += ["--kms-file", os.path.join(self.config_path(), "kms.txt")]

if self.__has_root_kms:
if 'root-kms.txt' in self.__proto_configs:
command += ["--root-kms-file", os.path.join(self.config_path(), "root-kms.txt")]

append_conf_file_arg(command, self.config_path(),
Expand Down

0 comments on commit 6d6be47

Please sign in to comment.