Skip to content

Commit

Permalink
Find old external-vhost-servers and terminate it when running new (#1561
Browse files Browse the repository at this point in the history
)

* Find old external-vhost-servers and terminate it when running new

* New config parameter VhostServerTimeoutAfterParentExit

* Fix test

* Try fix test

* Fix review issues

* Kill instead of terminate.

* Fix test

* It is possible that several endpoints for one diskId

* Ignore all params before --disk-id

* Make parsing disk-id simple
  • Loading branch information
drbasic committed Jul 15, 2024
1 parent 4dc6df5 commit 7204cdf
Show file tree
Hide file tree
Showing 11 changed files with 456 additions and 91 deletions.
7 changes: 7 additions & 0 deletions cloud/blockstore/config/server.proto
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,13 @@ message TServerConfig

// Causes E_NOT_IMPLEMENTED errors in endpoint storages to be logged.
optional bool EndpointStorageNotImplementedErrorIsFatal = 116;

// auth token for node registration via ydb discovery api.
optional string NodeRegistrationToken = 117;

// How many seconds will the external vhost server continue to work after
// the parent process die.
optional uint32 VhostServerTimeoutAfterParentExit = 118;
}

////////////////////////////////////////////////////////////////////////////////
Expand Down
1 change: 1 addition & 0 deletions cloud/blockstore/libs/daemon/common/bootstrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ void TBootstrapBase::Init()
? TString {}
: FQDNHostName(),
Configs->ServerConfig->GetSocketAccessMode(),
Configs->ServerConfig->GetVhostServerTimeoutAfterParentExit(),
std::move(vhostEndpointListener));

STORAGE_INFO("VHOST External Vhost EndpointListener initialized");
Expand Down
47 changes: 47 additions & 0 deletions cloud/blockstore/libs/endpoints_vhost/cont_io_with_timeout.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#pragma once

#include <library/cpp/coroutine/engine/sockpool.h>

#include <util/stream/input.h>
#include <util/stream/output.h>

namespace NCloud::NBlockStore::NServer {

///////////////////////////////////////////////////////////////////////////////

// Similar to TContIO, but DoWrite() and DoRead() operations are executed with a
// timeout.
class TContIOWithTimeout
: public IInputStream
, public IOutputStream
{
SOCKET Fd_;
TCont* Cont_;
TDuration Timeout;

public:
TContIOWithTimeout(SOCKET fd, TCont* cont, TDuration timeout)
: Fd_(fd)
, Cont_(cont)
, Timeout(timeout)
{}

void DoWrite(const void* buf, size_t len) override
{
NCoro::WriteD(Cont_, Fd_, buf, len, TInstant::Now() + Timeout)
.Checked();
}

size_t DoRead(void* buf, size_t len) override
{
return NCoro::ReadD(Cont_, Fd_, buf, len, TInstant::Now() + Timeout)
.Checked();
}

SOCKET Fd() const noexcept
{
return Fd_;
}
};

} // namespace NCloud::NBlockStore::NServer
Loading

0 comments on commit 7204cdf

Please sign in to comment.