From 26e63370b6820bf3e89826babeb57e37917a31cc Mon Sep 17 00:00:00 2001 From: Mikhail Montsev Date: Wed, 20 Nov 2024 21:50:37 +0000 Subject: [PATCH] [Blockstore] EndpointProxySocketPath option should have priority over NbdNetlink option, otherwise endpoint proxy may become accidentally disabled if someone enables NbdNetlink (#2543) --- .../libs/daemon/common/bootstrap.cpp | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/cloud/blockstore/libs/daemon/common/bootstrap.cpp b/cloud/blockstore/libs/daemon/common/bootstrap.cpp index 735c880d5a9..b4b7dda596c 100644 --- a/cloud/blockstore/libs/daemon/common/bootstrap.cpp +++ b/cloud/blockstore/libs/daemon/common/bootstrap.cpp @@ -526,6 +526,8 @@ void TBootstrapBase::Init() .NbdDevicePrefix = Configs->ServerConfig->GetNbdDevicePrefix(), }; + NBD::IDeviceFactoryPtr nbdDeviceFactory; + if (Configs->ServerConfig->GetEndpointProxySocketPath()) { EndpointProxyClient = NClient::CreateClient( { @@ -539,11 +541,15 @@ void TBootstrapBase::Init() Scheduler, Timer, Logging); - } - NBD::IDeviceFactoryPtr nbdDeviceFactory; + const ui32 defaultSectorSize = 4_KB; - if (Configs->ServerConfig->GetNbdNetlink()) { + nbdDeviceFactory = NClient::CreateProxyDeviceFactory( + {defaultSectorSize}, + EndpointProxyClient); + } + + if (!nbdDeviceFactory && Configs->ServerConfig->GetNbdNetlink()) { nbdDeviceFactory = NBD::CreateNetlinkDeviceFactory( Logging, Configs->ServerConfig->GetNbdRequestTimeout(), @@ -551,14 +557,6 @@ void TBootstrapBase::Init() true); // reconfigure } - if (!nbdDeviceFactory && EndpointProxyClient) { - const ui32 defaultSectorSize = 4_KB; - - nbdDeviceFactory = NClient::CreateProxyDeviceFactory( - {defaultSectorSize}, - EndpointProxyClient); - } - // The only case we want kernel to retry requests is when the socket is dead // due to nbd server restart. And since we can't configure ioctl device to // use a new socket, request timeout effectively becomes connection timeout