Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Users/yegorskii/stable 23 3 #1725

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions cloud/filestore/config/storage.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ syntax = "proto2";
package NCloud.NFileStore.NProto;

import "cloud/storage/core/protos/authorization_mode.proto";
import "cloud/storage/core/protos/certificate.proto";

option go_package = "a.yandex-team.ru/cloud/filestore/config";

Expand Down Expand Up @@ -305,4 +306,17 @@ message TStorageConfig
// Enables usage of GetNodeAttrBatch requests instead of GetNodeAttr when
// appropriate.
optional bool GetNodeAttrBatchEnabled = 358;

// Max number of items to delete during TrimBytes.
optional uint64 TrimBytesItemCount = 359;

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

// Node type.
optional string NodeType = 361;

// TLS node registration details.
optional string NodeRegistrationRootCertsFile = 362;
optional NCloud.NProto.TCertificate NodeRegistrationCert = 363;
}
2 changes: 2 additions & 0 deletions cloud/filestore/libs/daemon/common/bootstrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,8 @@ void TBootstrapCommon::InitActorSystem()
registerOpts.RegistrationTimeout = Configs->Options->NodeRegistrationTimeout;
registerOpts.ErrorTimeout = Configs->Options->NodeRegistrationErrorTimeout;
registerOpts.LoadCmsConfigs = Configs->Options->LoadCmsConfigs;
registerOpts.UseNodeBrokerSsl = Configs->Options->UseNodeBrokerSsl,
registerOpts.Settings = Configs->GetNodeRegistrationSettings();

auto [nodeId, scopeId, cmsConfig] = RegisterDynamicNode(
Configs->KikimrConfig,
Expand Down
20 changes: 20 additions & 0 deletions cloud/filestore/libs/daemon/common/config_initializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

namespace NCloud::NFileStore::NDaemon {

using namespace NCloud::NStorage;

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

TConfigInitializerCommon::TConfigInitializerCommon(TOptionsCommonPtr options)
Expand Down Expand Up @@ -56,4 +58,22 @@ void TConfigInitializerCommon::InitFeaturesConfig()
std::move(featuresConfig));
}

TNodeRegistrationSettings
TConfigInitializerCommon::GetNodeRegistrationSettings()
{
TNodeRegistrationSettings settings;
settings.MaxAttempts = Options->NodeRegistrationMaxAttempts;
settings.RegistrationTimeout = Options->NodeRegistrationTimeout;
settings.ErrorTimeout = Options->NodeRegistrationErrorTimeout;
settings.PathToGrpcCaFile = StorageConfig->GetNodeRegistrationRootCertsFile();
settings.NodeRegistrationToken = StorageConfig->GetNodeRegistrationToken();
settings.NodeType = StorageConfig->GetNodeType();

const auto& cert = StorageConfig->GetNodeRegistrationCert();
settings.PathToGrpcCertFile = cert.CertFile;
settings.PathToGrpcPrivateKeyFile = cert.CertPrivateKeyFile;

return settings;
}

} // namespace NCloud::NFileStore::NDaemon
3 changes: 3 additions & 0 deletions cloud/filestore/libs/daemon/common/config_initializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <cloud/storage/core/libs/features/features_config.h>
#include <cloud/storage/core/libs/kikimr/config_initializer.h>
#include <cloud/storage/core/libs/kikimr/node_registration_settings.h>

namespace NCloud::NFileStore::NDaemon {

Expand All @@ -26,6 +27,8 @@ struct TConfigInitializerCommon
void InitDiagnosticsConfig();
void InitStorageConfig();
void InitFeaturesConfig();

NCloud::NStorage::TNodeRegistrationSettings GetNodeRegistrationSettings();
};

} // namespace NCloud::NFileStore::NDaemon
30 changes: 30 additions & 0 deletions cloud/filestore/libs/storage/core/config.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#include "config.h"

#include <cloud/storage/core/protos/certificate.pb.h>

#include <library/cpp/monlib/service/pages/templates.h>

#include <util/generic/size_literals.h>
#include <util/generic/vector.h>

#include <google/protobuf/text_format.h>

Expand Down Expand Up @@ -165,6 +168,11 @@ namespace {
xxx(MultiTabletForwardingEnabled, bool, false )\
xxx(GetNodeAttrBatchEnabled, bool, false )\
xxx(AllowFileStoreForceDestroy, bool, false )\
xxx(TrimBytesItemCount, ui64, 100'000 )\
xxx(NodeRegistrationRootCertsFile, TString, {} )\
xxx(NodeRegistrationCert, TCertificate, {} )\
xxx(NodeRegistrationToken, TString, "root@builtin")\
xxx(NodeType, TString, {} )\
// FILESTORE_STORAGE_CONFIG

#define FILESTORE_DECLARE_CONFIG(name, type, value) \
Expand All @@ -183,12 +191,24 @@ bool IsEmpty(const T& t)
return !t;
}

template <>
bool IsEmpty(const NCloud::NProto::TCertificate& value)
{
return !value.GetCertFile() && !value.GetCertPrivateKeyFile();
}

template <typename TTarget, typename TSource>
TTarget ConvertValue(const TSource& value)
{
return static_cast<TTarget>(value);
}

template <>
TCertificate ConvertValue(const NCloud::NProto::TCertificate& value)
{
return {value.GetCertFile(), value.GetCertPrivateKeyFile()};
}

template <>
TDuration ConvertValue<TDuration, ui32>(const ui32& value)
{
Expand All @@ -215,6 +235,16 @@ void DumpImpl(const T& t, IOutputStream& os)
os << t;
}

template <>
void DumpImpl(const TCertificate& value, IOutputStream& os)
{
os << "{ "
<< value.CertFile
<< ", "
<< value.CertPrivateKeyFile
<< " }";
}

} // namespace

////////////////////////////////////////////////////////////////////////////////
Expand Down
15 changes: 15 additions & 0 deletions cloud/filestore/libs/storage/core/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ namespace NCloud::NFileStore::NStorage {

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

struct TCertificate
{
TString CertFile;
TString CertPrivateKeyFile;
};

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

class TStorageConfig
{
private:
Expand Down Expand Up @@ -213,10 +221,17 @@ class TStorageConfig

bool GetAllowFileStoreForceDestroy() const;

ui64 GetTrimBytesItemCount() const;

void Dump(IOutputStream& out) const;
void DumpHtml(IOutputStream& out) const;
void DumpOverridesHtml(IOutputStream& out) const;

TString GetNodeRegistrationToken() const;
TString GetNodeType() const;
TString GetNodeRegistrationRootCertsFile() const;
TCertificate GetNodeRegistrationCert() const;

const NProto::TStorageConfig& GetStorageConfigProto() const;
};

Expand Down
60 changes: 47 additions & 13 deletions cloud/filestore/libs/storage/tablet/model/fresh_bytes.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "fresh_bytes.h"
#include "verify.h"

#include <cloud/storage/core/libs/tablet/model/commit.h>

Expand Down Expand Up @@ -44,14 +45,14 @@ void TFreshBytes::DeleteBytes(

if (lo->second.Offset < offset) {
// cutting lo from the right side
Y_DEBUG_ABORT_UNLESS(lo->second.CommitId < commitId);
TABLET_VERIFY_DEBUG(lo->second.CommitId < commitId);
auto& loRef = c.Refs[{nodeId, offset}];
loRef = lo->second;
loRef.Buf = loRef.Buf.substr(0, offset - loRef.Offset);

if (lo->first.End <= end) {
// blockRange is not contained strictly inside lo
Y_DEBUG_ABORT_UNLESS(lo != hi);
TABLET_VERIFY_DEBUG(lo != hi);
c.Refs.erase(lo++);
}
}
Expand All @@ -62,7 +63,7 @@ void TFreshBytes::DeleteBytes(
{
// cutting hi from the left side
// hi might be equal to lo - it's not a problem
Y_DEBUG_ABORT_UNLESS(hi->second.CommitId < commitId);
TABLET_VERIFY_DEBUG(hi->second.CommitId < commitId);
const auto shift = end - hi->second.Offset;
hi->second.Buf = hi->second.Buf.substr(
shift,
Expand All @@ -88,7 +89,7 @@ void TFreshBytes::AddBytes(
if (c.FirstCommitId == InvalidCommitId) {
c.FirstCommitId = commitId;
} else {
Y_ABORT_UNLESS(commitId >= c.FirstCommitId);
TABLET_VERIFY(commitId >= c.FirstCommitId);
}

TByteVector buffer(Reserve(data.size()), Allocator);
Expand Down Expand Up @@ -116,7 +117,7 @@ void TFreshBytes::AddDeletionMarker(
{
auto& c = Chunks.back();
if (c.FirstCommitId != InvalidCommitId) {
Y_ABORT_UNLESS(commitId >= c.FirstCommitId);
TABLET_VERIFY(commitId >= c.FirstCommitId);
}

c.TotalDeletedBytes += len;
Expand All @@ -132,15 +133,15 @@ void TFreshBytes::AddDeletionMarker(

void TFreshBytes::Barrier(ui64 commitId)
{
Y_ABORT_UNLESS(!Chunks.empty());
TABLET_VERIFY(!Chunks.empty());
auto& c = Chunks.back();

if (!c.Data.empty() || !c.DeletionMarkers.empty()) {
if (!c.Data.empty()) {
Y_ABORT_UNLESS(c.Data.back().Descriptor.MinCommitId <= commitId);
TABLET_VERIFY(c.Data.back().Descriptor.MinCommitId <= commitId);
}
if (!c.DeletionMarkers.empty()) {
Y_ABORT_UNLESS(c.DeletionMarkers.back().MinCommitId <= commitId);
TABLET_VERIFY(c.DeletionMarkers.back().MinCommitId <= commitId);
}
Chunks.back().ClosingCommitId = commitId;
Chunks.emplace_back(Allocator);
Expand Down Expand Up @@ -173,23 +174,56 @@ TFlushBytesCleanupInfo TFreshBytes::StartCleanup(
return {Chunks.front().Id, Chunks.front().ClosingCommitId};
}

void TFreshBytes::VisitTop(const TChunkVisitor& visitor)
void TFreshBytes::VisitTop(
ui64 itemLimit,
const TChunkVisitor& visitor)
{
ui64 cnt = 0;
for (const auto& e: Chunks.front().Data) {
if (cnt++ == itemLimit) {
return;
}
visitor(e.Descriptor, false);
}

for (const auto& descriptor: Chunks.front().DeletionMarkers) {
if (cnt++ == itemLimit) {
return;
}
visitor(descriptor, true);
}
}

void TFreshBytes::FinishCleanup(ui64 chunkId)
bool TFreshBytes::FinishCleanup(
ui64 chunkId,
ui64 dataItemCount,
ui64 deletionMarkerCount)
{
Y_ABORT_UNLESS(Chunks.size() > 1);
Y_ABORT_UNLESS(Chunks.front().Id == chunkId);
TABLET_VERIFY(Chunks.size() > 1);
TABLET_VERIFY(Chunks.front().Id == chunkId);

auto& chunk = Chunks.front();

const auto dataSize = chunk.Data.size();
const auto deletionSize = chunk.DeletionMarkers.size();
if (dataItemCount == dataSize && deletionMarkerCount == deletionSize) {
Chunks.pop_front();
return true;
}

const auto check =
dataItemCount <= dataSize && deletionMarkerCount <= deletionSize;
TABLET_VERIFY(check);

chunk.Data.erase(
chunk.Data.begin(),
std::next(chunk.Data.begin(), dataItemCount));

chunk.DeletionMarkers.erase(
chunk.DeletionMarkers.begin(),
std::next(chunk.DeletionMarkers.begin(), deletionMarkerCount));

Chunks.pop_front();
return false;
}

void TFreshBytes::FindBytes(
Expand Down
13 changes: 11 additions & 2 deletions cloud/filestore/libs/storage/tablet/model/fresh_bytes.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class TFreshBytes
IAllocator* Allocator;
TDeque<TChunk, TStlAllocator> Chunks;
ui64 LastChunkId = 0;
TString LogTag;

public:
TFreshBytes(IAllocator* allocator);
Expand All @@ -94,6 +95,11 @@ class TFreshBytes
return std::make_pair(bytes, deletedBytes);
}

void UpdateLogTag(TString logTag)
{
LogTag = std::move(logTag);
}

void AddBytes(ui64 nodeId, ui64 offset, TStringBuf data, ui64 commitId);
void AddDeletionMarker(ui64 nodeId, ui64 offset, ui64 len, ui64 commitId);

Expand All @@ -103,8 +109,11 @@ class TFreshBytes
ui64 commitId,
TVector<TBytes>* entries,
TVector<TBytes>* deletionMarkers);
void VisitTop(const TChunkVisitor& visitor);
void FinishCleanup(ui64 chunkId);
void VisitTop(ui64 itemLimit, const TChunkVisitor& visitor);
bool FinishCleanup(
ui64 chunkId,
ui64 dataItemCount,
ui64 deletionMarkerCount);

void FindBytes(
IFreshBytesVisitor& visitor,
Expand Down
Loading
Loading