Skip to content
Merged
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
16 changes: 8 additions & 8 deletions ydb/core/blobstorage/base/blobstorage_console_events.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,9 @@ namespace NKikimr {
NKikimrBlobStorage::TEvControllerReplaceConfigRequest, EvControllerReplaceConfigRequest> {
TEvControllerReplaceConfigRequest() = default;

TEvControllerReplaceConfigRequest(
std::optional<TString> clusterYaml,
std::optional<TString> storageYaml,
std::optional<bool> switchDedicatedStorageSection,
bool dedicatedConfigMode,
bool allowUnknownFields,
bool bypassMetadataChecks) {

TEvControllerReplaceConfigRequest(std::optional<TString> clusterYaml, std::optional<TString> storageYaml,
std::optional<bool> switchDedicatedStorageSection, bool dedicatedConfigMode, bool allowUnknownFields,
bool bypassMetadataChecks, bool enableConfigV2, bool disableConfigV2) {
if (clusterYaml) {
Record.SetClusterYaml(*clusterYaml);
}
Expand All @@ -97,6 +92,11 @@ namespace NKikimr {
Record.SetDedicatedConfigMode(dedicatedConfigMode);
Record.SetAllowUnknownFields(allowUnknownFields);
Record.SetBypassMetadataChecks(bypassMetadataChecks);
if (enableConfigV2) {
Record.SetSwitchEnableConfigV2(true);
} else if (disableConfigV2) {
Record.SetSwitchEnableConfigV2(false);
}
}

TString ToString() const override {
Expand Down
2 changes: 1 addition & 1 deletion ydb/core/blobstorage/nodewarden/distconf_console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ namespace NKikimr::NStorage {
if (!fetched) { // fill in 'to-be-fetched' version of config with version incremented by one
try {
auto metadata = NYamlConfig::GetMainMetadata(yaml);
metadata.Cluster = metadata.Cluster.value_or("unknown"); // TODO: fix this
metadata.Cluster = metadata.Cluster.value_or(AppData()->ClusterName);
metadata.Version = metadata.Version.value_or(0) + 1;
temp = NYamlConfig::ReplaceMetadata(yaml, metadata);
} catch (const std::exception& ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,17 @@ namespace NKikimr::NStorage {
void TInvokeRequestHandlerActor::FetchStorageConfig(bool manual, bool fetchMain, bool fetchStorage) {
if (!Self->StorageConfig) {
FinishWithError(TResult::ERROR, "no agreed StorageConfig");
} else if (!Self->MainConfigFetchYaml) {
} else if (!Self->MainConfigYaml) {
FinishWithError(TResult::ERROR, "no stored YAML for storage config");
} else {
auto ev = PrepareResult(TResult::OK, std::nullopt);
auto *record = &ev->Record;
auto *res = record->MutableFetchStorageConfig();
if (fetchMain) {
res->SetYAML(Self->MainConfigFetchYaml);
res->SetYAML(Self->MainConfigYaml);
}
if (fetchStorage && Self->StorageConfigYaml) {
auto metadata = NYamlConfig::GetStorageMetadata(*Self->StorageConfigYaml);
metadata.Cluster = metadata.Cluster.value_or("unknown"); // TODO: fix this
metadata.Version = metadata.Version.value_or(0) + 1;
res->SetStorageYAML(NYamlConfig::ReplaceMetadata(*Self->StorageConfigYaml, metadata));
res->SetStorageYAML(*Self->StorageConfigYaml);
}

if (manual) {
Expand All @@ -48,6 +45,22 @@ namespace NKikimr::NStorage {
NewYaml = request.HasYAML() ? std::make_optional(request.GetYAML()) : std::nullopt;
NewStorageYaml = request.HasStorageYAML() ? std::make_optional(request.GetStorageYAML()) : std::nullopt;

// check if we are really changing something?
if (NewYaml == Self->MainConfigYaml) {
NewYaml.reset();
}
if (NewStorageYaml == Self->StorageConfigYaml) {
NewStorageYaml.reset();
}
if (!NewYaml && !NewStorageYaml) {
if (request.HasSwitchDedicatedStorageSection()) {
return FinishWithError(TResult::ERROR, "switching dedicated storage section mode without providing any new config");
} else {
// finish this request prematurely: no configs are actually changed
return Finish(Sender, SelfId(), PrepareResult(TResult::OK, std::nullopt).release(), 0, Cookie);
}
}

// start deriving a config from current one
TString state;
NKikimrBlobStorage::TStorageConfig config(*Self->StorageConfig);
Expand All @@ -67,6 +80,10 @@ namespace NKikimr::NStorage {
throw yexception() << "missing or invalid kind provided";
}
version = metadata["version"].GetUIntegerRobust();
if (metadata.Has("cluster") && metadata["cluster"] != AppData()->ClusterName) {
throw yexception() << "cluster name mismatch: provided# " << metadata["cluster"]
<< " expected# " << AppData()->ClusterName;
}

state = TStringBuilder() << "validating " << expectedKind << " config section";
if (!json.Has("config") || !json["config"].IsMap()) {
Expand Down
2 changes: 1 addition & 1 deletion ydb/core/cms/console/console_configs_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void TConfigsManager::ReplaceMainConfigMetadata(const TString &config, bool forc
try {
if (!force) {
auto metadata = NYamlConfig::GetMainMetadata(config);
opCtx.Cluster = metadata.Cluster.value_or(TString("unknown"));
opCtx.Cluster = metadata.Cluster.value_or(ClusterName);
opCtx.Version = metadata.Version.value_or(0);
} else {
opCtx.Cluster = ClusterName;
Expand Down
4 changes: 3 additions & 1 deletion ydb/core/grpc_services/rpc_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,9 @@ class TReplaceStorageConfigRequest : public TBSConfigRequestGrpc<TReplaceStorage
shim.SwitchDedicatedStorageSection,
shim.DedicatedConfigMode,
request->allow_unknown_fields() || request->bypass_checks(),
request->bypass_checks());
request->bypass_checks(),
false /* TODO: implement */,
false /* TODO: implement */);
}

private:
Expand Down
13 changes: 12 additions & 1 deletion ydb/core/grpc_services/rpc_config_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,14 @@ class TBSConfigRequestGrpc : public TRpcOperationRequestActor<TDerived, TRequest
if constexpr (std::is_same_v<TResultRecord, Ydb::Config::FetchConfigResult>) {
TResultRecord result;
const auto& record = ev->Get()->Record;
if (record.HasErrorReason()) {
const auto status = record.GetDisabledConfigV2()
? Ydb::StatusIds::UNSUPPORTED
: Ydb::StatusIds::INTERNAL_ERROR;
self->Reply(status, TStringBuilder() << "failed to fetch config: " << record.GetErrorReason(),
NKikimrIssues::TIssuesIds::DEFAULT_ERROR, self->ActorContext());
return;
}
if (record.HasClusterYaml()) {
auto conf = ev->Get()->Record.GetClusterYaml();
auto metadata = NYamlConfig::GetMainMetadata(conf);
Expand Down Expand Up @@ -327,7 +335,10 @@ class TBSConfigRequestGrpc : public TRpcOperationRequestActor<TDerived, TRequest
TResultRecord result;
self->ReplyWithResult(Ydb::StatusIds::SUCCESS, result, self->ActorContext());
} else {
self->Reply(Ydb::StatusIds::INTERNAL_ERROR, TStringBuilder() << "failed to replace configuration: "
const auto status = record.GetDisabledConfigV2()
? Ydb::StatusIds::UNSUPPORTED
: Ydb::StatusIds::INTERNAL_ERROR;
self->Reply(status, TStringBuilder() << "failed to replace configuration: "
<< NKikimrBlobStorage::TEvControllerReplaceConfigResponse::EStatus_Name(record.GetStatus())
<< ": " << record.GetErrorReason(), NKikimrIssues::TIssuesIds::DEFAULT_ERROR, self->ActorContext());
}
Expand Down
2 changes: 1 addition & 1 deletion ydb/core/mind/bscontroller/bsc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ void TBlobStorageController::Handle(TEvBlobStorage::TEvControllerDistconfRequest

// commit it
Execute(CreateTxCommitConfig(std::move(yamlConfig), std::make_optional(std::move(storageYaml)), std::nullopt,
expectedStorageYamlConfigVersion, std::exchange(h, {})));
expectedStorageYamlConfigVersion, std::exchange(h, {}), std::nullopt));
break;
}

Expand Down
16 changes: 13 additions & 3 deletions ydb/core/mind/bscontroller/commit_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ namespace NKikimr::NBsController {
std::optional<NKikimrBlobStorage::TStorageConfig> StorageConfig;
std::optional<ui64> ExpectedStorageYamlConfigVersion;
std::unique_ptr<IEventHandle> Handle;
std::optional<bool> SwitchEnableConfigV2;

ui64 GenerationOnStart = 0;
TString FingerprintOnStart;
Expand All @@ -23,13 +24,15 @@ namespace NKikimr::NBsController {
TTxCommitConfig(TBlobStorageController *controller, std::optional<TYamlConfig>&& yamlConfig,
std::optional<std::optional<TString>>&& storageYamlConfig,
std::optional<NKikimrBlobStorage::TStorageConfig>&& storageConfig,
std::optional<ui64> expectedStorageYamlConfigVersion, std::unique_ptr<IEventHandle> handle)
std::optional<ui64> expectedStorageYamlConfigVersion, std::unique_ptr<IEventHandle> handle,
std::optional<bool> switchEnableConfigV2)
: TTransactionBase(controller)
, YamlConfig(std::move(yamlConfig))
, StorageYamlConfig(std::move(storageYamlConfig))
, StorageConfig(std::move(storageConfig))
, ExpectedStorageYamlConfigVersion(expectedStorageYamlConfigVersion)
, Handle(std::move(handle))
, SwitchEnableConfigV2(switchEnableConfigV2)
{}

TTxType GetTxType() const override { return NBlobStorageController::TXTYPE_COMMIT_CONFIG; }
Expand All @@ -53,6 +56,9 @@ namespace NKikimr::NBsController {
if (ExpectedStorageYamlConfigVersion) {
row.Update<Schema::State::ExpectedStorageYamlConfigVersion>(*ExpectedStorageYamlConfigVersion);
}
if (SwitchEnableConfigV2) {
row.Update<Schema::State::EnableConfigV2>(*SwitchEnableConfigV2);
}
return true;
}

Expand Down Expand Up @@ -104,6 +110,9 @@ namespace NKikimr::NBsController {
if (update && Self->StorageYamlConfig) {
update->SetStorageConfigVersion(NYamlConfig::GetStorageMetadata(*Self->StorageYamlConfig).Version.value_or(0));
}
if (SwitchEnableConfigV2) {
Self->EnableConfigV2 = *SwitchEnableConfigV2;
}

if (Handle) {
TActivationContext::Send(Handle.release());
Expand All @@ -126,9 +135,10 @@ namespace NKikimr::NBsController {
ITransaction* TBlobStorageController::CreateTxCommitConfig(std::optional<TYamlConfig>&& yamlConfig,
std::optional<std::optional<TString>>&& storageYamlConfig,
std::optional<NKikimrBlobStorage::TStorageConfig>&& storageConfig,
std::optional<ui64> expectedStorageYamlConfigVersion, std::unique_ptr<IEventHandle> handle) {
std::optional<ui64> expectedStorageYamlConfigVersion, std::unique_ptr<IEventHandle> handle,
std::optional<bool> switchEnableConfigV2) {
return new TTxCommitConfig(this, std::move(yamlConfig), std::move(storageYamlConfig), std::move(storageConfig),
expectedStorageYamlConfigVersion, std::move(handle));
expectedStorageYamlConfigVersion, std::move(handle), switchEnableConfigV2);
}

} // namespace NKikimr::NBsController
Loading
Loading