diff options
author | yuryalekseev <yuryalekseev@yandex-team.com> | 2023-08-10 12:00:37 +0300 |
---|---|---|
committer | yuryalekseev <yuryalekseev@yandex-team.com> | 2023-08-10 13:05:03 +0300 |
commit | 11287eab3867f6c4cc913f8b8e1155ece43e8fa5 (patch) | |
tree | d2855210d55b55e05b892ab75376c88ac811b4e5 | |
parent | 3925c5ded74412ba0e463d5a433fb35a3479640e (diff) | |
download | ydb-11287eab3867f6c4cc913f8b8e1155ece43e8fa5.tar.gz |
YT-17268: Address review comments.
-rw-r--r-- | yt/yt/core/bus/tcp/config.cpp | 8 | ||||
-rw-r--r-- | yt/yt/core/bus/tcp/config.h | 6 | ||||
-rw-r--r-- | yt/yt/core/bus/tcp/connection.cpp | 12 | ||||
-rw-r--r-- | yt/yt/core/bus/tcp/dispatcher_impl.cpp | 4 | ||||
-rw-r--r-- | yt/yt/core/bus/tcp/dispatcher_impl.h | 2 | ||||
-rw-r--r-- | yt/yt/core/bus/tcp/ssl_context.cpp | 14 | ||||
-rw-r--r-- | yt/yt/core/rpc/bus/channel.cpp | 2 |
7 files changed, 25 insertions, 23 deletions
diff --git a/yt/yt/core/bus/tcp/config.cpp b/yt/yt/core/bus/tcp/config.cpp index 8b3f715a99..3e8efbca12 100644 --- a/yt/yt/core/bus/tcp/config.cpp +++ b/yt/yt/core/bus/tcp/config.cpp @@ -33,7 +33,7 @@ void TTcpDispatcherConfig::Register(TRegistrar registrar) registrar.Parameter("multiplexing_bands", &TThis::MultiplexingBands) .Default(); - registrar.Parameter("bus_certs_dir", &TThis::BusCertsDir) + registrar.Parameter("bus_certs_directory_path", &TThis::BusCertsDirectoryPath) .Default(); } @@ -44,7 +44,7 @@ TTcpDispatcherConfigPtr TTcpDispatcherConfig::ApplyDynamic( UpdateYsonStructField(mergedConfig->ThreadPoolSize, dynamicConfig->ThreadPoolSize); UpdateYsonStructField(mergedConfig->Networks, dynamicConfig->Networks); UpdateYsonStructField(mergedConfig->MultiplexingBands, dynamicConfig->MultiplexingBands); - UpdateYsonStructField(mergedConfig->BusCertsDir, dynamicConfig->BusCertsDir); + UpdateYsonStructField(mergedConfig->BusCertsDirectoryPath, dynamicConfig->BusCertsDirectoryPath); mergedConfig->Postprocess(); return mergedConfig; } @@ -66,7 +66,7 @@ void TTcpDispatcherDynamicConfig::Register(TRegistrar registrar) registrar.Parameter("multiplexing_bands", &TThis::MultiplexingBands) .Optional(); - registrar.Parameter("bus_certs_dir", &TThis::BusCertsDir) + registrar.Parameter("bus_certs_directory_path", &TThis::BusCertsDirectoryPath) .Default(); } @@ -130,7 +130,7 @@ void TBusConfig::Register(TRegistrar registrar) .Default(); registrar.Parameter("use_key_pair_from_ssl_context", &TThis::UseKeyPairFromSslContext) .Default(false); - registrar.Parameter("load_from_certs_dir", &TThis::LoadFromCertsDir) + registrar.Parameter("load_certs_from_bus_certs_directory", &TThis::LoadCertsFromBusCertsDirectory) .Default(false); } diff --git a/yt/yt/core/bus/tcp/config.h b/yt/yt/core/bus/tcp/config.h index a5257d5b90..881dd40933 100644 --- a/yt/yt/core/bus/tcp/config.h +++ b/yt/yt/core/bus/tcp/config.h @@ -43,7 +43,7 @@ public: TTcpDispatcherConfigPtr ApplyDynamic(const TTcpDispatcherDynamicConfigPtr& dynamicConfig) const; //! Used to store TLS/SSL certificate files. - std::optional<TString> BusCertsDir; + std::optional<TString> BusCertsDirectoryPath; REGISTER_YSON_STRUCT(TTcpDispatcherConfig); @@ -67,7 +67,7 @@ public: std::optional<TEnumIndexedVector<EMultiplexingBand, TMultiplexingBandConfigPtr>> MultiplexingBands; //! Used to store TLS/SSL certificate files. - std::optional<TString> BusCertsDir; + std::optional<TString> BusCertsDirectoryPath; REGISTER_YSON_STRUCT(TTcpDispatcherDynamicConfig); @@ -100,7 +100,7 @@ public: std::optional<TString> CertificateChainFile; std::optional<TString> PrivateKeyFile; std::optional<TString> CipherList; - bool LoadFromCertsDir; + bool LoadCertsFromBusCertsDirectory; // For testing purposes. bool UseKeyPairFromSslContext; diff --git a/yt/yt/core/bus/tcp/connection.cpp b/yt/yt/core/bus/tcp/connection.cpp index c11560617b..9a9b945234 100644 --- a/yt/yt/core/bus/tcp/connection.cpp +++ b/yt/yt/core/bus/tcp/connection.cpp @@ -1924,7 +1924,7 @@ void TTcpConnection::TryEnqueueSslAck() 0, SslAckPacketId); - YT_LOG_DEBUG("SslAck enqueued"); + YT_LOG_DEBUG("TLS/SSL acknowledgement enqueued"); } void TTcpConnection::TryEstablishSslSession() @@ -1935,8 +1935,8 @@ void TTcpConnection::TryEstablishSslSession() YT_LOG_DEBUG("Starting TLS/SSL connection (VerificationMode: %v)", VerificationMode_); - if (Config_->LoadFromCertsDir && !TTcpDispatcher::TImpl::Get()->GetBusCertsDir()) { - Abort(TError(NBus::EErrorCode::SslError, "The bus_certs_dir is not set in static tcp dispatcher config")); + if (Config_->LoadCertsFromBusCertsDirectory && !TTcpDispatcher::TImpl::Get()->GetBusCertsDirectoryPath()) { + Abort(TError(NBus::EErrorCode::SslError, "bus_certs_directory_path is not set in tcp_dispatcher config")); return; } @@ -1959,14 +1959,14 @@ void TTcpConnection::TryEstablishSslSession() } #define GET_CERT_FILE_PATH(file) \ - (Config_->LoadFromCertsDir ? JoinPaths(*TTcpDispatcher::TImpl::Get()->GetBusCertsDir(), (file)) : (file)) + (Config_->LoadCertsFromBusCertsDirectory ? JoinPaths(*TTcpDispatcher::TImpl::Get()->GetBusCertsDirectoryPath(), (file)) : (file)) if (ConnectionType_ == EConnectionType::Server) { SSL_set_accept_state(Ssl_.get()); if (!Config_->UseKeyPairFromSslContext) { if (!Config_->CertificateChainFile) { - Abort(TError(NBus::EErrorCode::SslError, "The certificate chain file is not set in bus config")); + Abort(TError(NBus::EErrorCode::SslError, "Certificate chain file is not set in bus config")); return; } @@ -2006,7 +2006,7 @@ void TTcpConnection::TryEstablishSslSession() [[fallthrough]]; case EVerificationMode::Ca: { if (!Config_->CAFile) { - Abort(TError(NBus::EErrorCode::SslError, "The CA file is not set in bus config")); + Abort(TError(NBus::EErrorCode::SslError, "CA file is not set in bus config")); return; } diff --git a/yt/yt/core/bus/tcp/dispatcher_impl.cpp b/yt/yt/core/bus/tcp/dispatcher_impl.cpp index eafc309b93..5c0bf871ea 100644 --- a/yt/yt/core/bus/tcp/dispatcher_impl.cpp +++ b/yt/yt/core/bus/tcp/dispatcher_impl.cpp @@ -321,10 +321,10 @@ void TTcpDispatcher::TImpl::OnPeriodicCheck() } } -std::optional<TString> TTcpDispatcher::TImpl::GetBusCertsDir() const +std::optional<TString> TTcpDispatcher::TImpl::GetBusCertsDirectoryPath() const { auto guard = ReaderGuard(PollerLock_); - return Config_->BusCertsDir; + return Config_->BusCertsDirectoryPath; } //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/core/bus/tcp/dispatcher_impl.h b/yt/yt/core/bus/tcp/dispatcher_impl.h index e82ea17ef8..80495eaa65 100644 --- a/yt/yt/core/bus/tcp/dispatcher_impl.h +++ b/yt/yt/core/bus/tcp/dispatcher_impl.h @@ -53,7 +53,7 @@ public: NYTree::IYPathServicePtr GetOrchidService(); - std::optional<TString> GetBusCertsDir() const; + std::optional<TString> GetBusCertsDirectoryPath() const; private: friend class TTcpDispatcher; diff --git a/yt/yt/core/bus/tcp/ssl_context.cpp b/yt/yt/core/bus/tcp/ssl_context.cpp index 56494d8ea7..bd1cdfb1d5 100644 --- a/yt/yt/core/bus/tcp/ssl_context.cpp +++ b/yt/yt/core/bus/tcp/ssl_context.cpp @@ -5,6 +5,8 @@ #include <library/cpp/openssl/init/init.h> +#include <library/cpp/yt/threading/spin_lock.h> + #include <util/system/mutex.h> #include <openssl/err.h> @@ -80,7 +82,7 @@ public: //! This function is for testing purposes. void LoadCAFile(const TString& filePath) { - TGuard<TMutex> guard(Mutex_); + auto guard = Guard(SpinLock_); LoadCAFileUnlocked(filePath); @@ -93,7 +95,7 @@ public: return; } - TGuard<TMutex> guard(Mutex_); + auto guard = Guard(SpinLock_); if (CAIsLoaded_) { return; @@ -123,7 +125,7 @@ public: //! This function is for testing purposes. void UseCA(const TString& ca) { - TGuard<TMutex> guard(Mutex_); + auto guard = Guard(SpinLock_); UseCAUnlocked(ca); @@ -179,7 +181,7 @@ public: return; } - TGuard<TMutex> guard(Mutex_); + auto guard = Guard(SpinLock_); if (CipherListIsSet_) { return; @@ -193,7 +195,7 @@ public: //! This function is for testing purposes. void SetCipherList(const TString& cipherList) { - TGuard<TMutex> guard(Mutex_); + auto guard = Guard(SpinLock_); SetCipherListUnlocked(cipherList); @@ -244,7 +246,7 @@ private: } private: - TMutex Mutex_; + YT_DECLARE_SPIN_LOCK(NThreading::TSpinLock, SpinLock_); std::atomic<bool> CAIsLoaded_ = false; std::atomic<bool> CipherListIsSet_ = false; std::unique_ptr<SSL_CTX, TDeleter> SslCtx_; diff --git a/yt/yt/core/rpc/bus/channel.cpp b/yt/yt/core/rpc/bus/channel.cpp index eaf04705b0..57bb875a00 100644 --- a/yt/yt/core/rpc/bus/channel.cpp +++ b/yt/yt/core/rpc/bus/channel.cpp @@ -191,7 +191,7 @@ private: .MultiplexingBand = options.MultiplexingBand }); - auto& attrs = bus->GetEndpointAttributes(); + const auto& attrs = bus->GetEndpointAttributes(); YT_LOG_DEBUG("Created bus (ConnectionType: Client, VerificationMode: %v, EncryptionMode: %v, Endpoint: %v)", attrs.Get<EVerificationMode>("verification_mode"), attrs.Get<EEncryptionMode>("encryption_mode"), |