@@ -443,8 +443,7 @@ void TNodeWarden::Bootstrap() {
443
443
444
444
// LoadConfigVersion();
445
445
if (Cfg->YamlConfig ) {
446
- YamlConfig.emplace ();
447
- YamlConfig->CopyFrom (*Cfg->YamlConfig );
446
+ YamlConfig.emplace (std::move (*Cfg->YamlConfig ));
448
447
}
449
448
450
449
// Start a statically configured set
@@ -635,31 +634,42 @@ void TNodeWarden::ProcessShredStatus(ui64 cookie, ui64 generation, std::optional
635
634
}
636
635
}
637
636
638
- void TNodeWarden::PersistConfig (const TString& configYaml, ui64 version, std::optional<TString> storageYaml) {
637
+ void TNodeWarden::PersistConfig (std::optional<TString> mainYaml, ui64 mainYamlVersion, std::optional<TString> storageYaml,
638
+ std::optional<ui64> storageYamlVersion) {
639
639
if (!Cfg->ConfigStorePath ) {
640
640
return ;
641
641
}
642
642
643
- if (YamlConfig && version <= YamlConfig->GetConfigVersion ()) {
644
- return ; // some kind of a race
643
+ const bool updateMain = mainYaml && (!YamlConfig || YamlConfig->GetMainConfigVersion () < mainYamlVersion);
644
+
645
+ const bool updateStorage = !storageYamlVersion || // delete storage config file in single-config mode
646
+ storageYaml && (!YamlConfig || YamlConfig->GetStorageConfigVersion () < storageYamlVersion);
647
+
648
+ if (!updateMain && !updateStorage) {
649
+ return ; // nothing to do
645
650
}
646
651
647
652
struct TSaveContext {
648
653
TString ConfigStorePath;
649
- TString ConfigYaml ;
650
- ui64 Version ;
654
+ std::optional< TString> MainYaml ;
655
+ ui64 MainYamlVersion ;
651
656
std::optional<TString> StorageYaml;
652
- bool Success = true ;
653
- TString ErrorMessage;
654
- TActorId SelfId;
657
+ std::optional<ui64> StorageYamlVersion;
658
+ bool UpdateMain;
659
+ bool UpdateStorage;
660
+ bool DeleteStorage;
655
661
};
656
662
657
- auto saveCtx = std::make_shared<TSaveContext>();
658
- saveCtx->ConfigStorePath = Cfg->ConfigStorePath ;
659
- saveCtx->ConfigYaml = std::move (configYaml);
660
- saveCtx->StorageYaml = std::move (storageYaml);
661
- saveCtx->Version = std::move (version);
662
- saveCtx->SelfId = SelfId ();
663
+ auto saveCtx = std::make_shared<TSaveContext>(TSaveContext{
664
+ .ConfigStorePath = Cfg->ConfigStorePath ,
665
+ .MainYaml = std::move (mainYaml),
666
+ .MainYamlVersion = mainYamlVersion,
667
+ .StorageYaml = std::move (storageYaml),
668
+ .StorageYamlVersion = storageYamlVersion,
669
+ .UpdateMain = updateMain,
670
+ .UpdateStorage = updateStorage,
671
+ .DeleteStorage = !storageYamlVersion,
672
+ });
663
673
664
674
EnqueueSyncOp ([this , saveCtx](const TActorContext&) {
665
675
bool success = true ;
@@ -694,14 +704,16 @@ void TNodeWarden::PersistConfig(const TString& configYaml, ui64 version, std::op
694
704
}
695
705
};
696
706
697
- if (success) {
698
- success = saveConfig (saveCtx->ConfigYaml , YamlConfigFileName);
707
+ if (success && saveCtx-> UpdateMain ) {
708
+ success = saveConfig (* saveCtx->MainYaml , YamlConfigFileName);
699
709
if (success) {
700
710
STLOG (PRI_INFO, BS_NODE, NW94, " Yaml config saved" );
701
711
}
702
712
}
703
713
704
- if (success && saveCtx->StorageYaml ) {
714
+ if (saveCtx->DeleteStorage ) {
715
+ std::filesystem::remove (std::filesystem::path (saveCtx->ConfigStorePath .c_str ()) / StorageConfigFileName);
716
+ } else if (success && saveCtx->UpdateStorage ) {
705
717
success = saveConfig (*saveCtx->StorageYaml , StorageConfigFileName);
706
718
if (success) {
707
719
STLOG (PRI_INFO, BS_NODE, NW95, " Storage config saved" );
@@ -713,16 +725,22 @@ void TNodeWarden::PersistConfig(const TString& configYaml, ui64 version, std::op
713
725
if (!YamlConfig) {
714
726
YamlConfig.emplace ();
715
727
}
716
- YamlConfig->SetYAML (saveCtx->ConfigYaml );
717
- YamlConfig->SetConfigVersion (saveCtx->Version );
728
+ if (saveCtx->UpdateMain ) {
729
+ YamlConfig->SetMainConfig (*saveCtx->MainYaml );
730
+ YamlConfig->SetMainConfigVersion (saveCtx->MainYamlVersion );
731
+ }
732
+ if (saveCtx->DeleteStorage ) {
733
+ YamlConfig->ClearStorageConfig ();
734
+ YamlConfig->ClearStorageConfigVersion ();
735
+ } else if (saveCtx->UpdateStorage ) {
736
+ YamlConfig->SetStorageConfig (*saveCtx->StorageYaml );
737
+ YamlConfig->SetStorageConfigVersion (*saveCtx->StorageYamlVersion );
738
+ }
718
739
ConfigSaveTimer.Reset ();
719
740
} else {
720
- NKikimrBlobStorage::TYamlConfig yamlConfig;
721
- yamlConfig.SetYAML (saveCtx->ConfigYaml );
722
- yamlConfig.SetConfigVersion (saveCtx->Version );
723
- TActivationContext::Schedule (TDuration::MilliSeconds (ConfigSaveTimer.NextBackoffMs ()),
724
- new IEventHandle (SelfId (), SelfId (),
725
- new TEvPrivate::TEvRetrySaveConfig (yamlConfig), 0 , ExpectedSaveConfigCookie));
741
+ TActivationContext::Schedule (TDuration::MilliSeconds (ConfigSaveTimer.NextBackoffMs ()), new IEventHandle (
742
+ SelfId (), {}, new TEvPrivate::TEvRetrySaveConfig (std::move (saveCtx->MainYaml ), saveCtx->MainYamlVersion ,
743
+ std::move (saveCtx->StorageYaml ), saveCtx->StorageYamlVersion ), 0 , ExpectedSaveConfigCookie));
726
744
}
727
745
};
728
746
});
@@ -733,7 +751,7 @@ void TNodeWarden::Handle(TEvRegisterPDiskLoadActor::TPtr ev) {
733
751
}
734
752
735
753
void TNodeWarden::Handle (TEvBlobStorage::TEvControllerNodeServiceSetUpdate::TPtr ev) {
736
- const auto & record = ev->Get ()->Record ;
754
+ auto & record = ev->Get ()->Record ;
737
755
738
756
if (record.HasAvailDomain () && record.GetAvailDomain () != AvailDomainId) {
739
757
// AvailDomain may arrive unset
@@ -814,13 +832,26 @@ void TNodeWarden::Handle(TEvBlobStorage::TEvControllerNodeServiceSetUpdate::TPtr
814
832
}
815
833
816
834
if (record.HasYamlConfig ()) {
817
- const auto & request = record.GetYamlConfig ();
818
- if (request.HasYAML ()) {
819
- TString yaml = NYamlConfig::DecompressYamlString (request.GetYAML ());
820
- ui64 version = request.GetConfigVersion ();
821
- PersistConfig (yaml, version);
822
- ExpectedSaveConfigCookie++;
835
+ auto & yaml = *record.MutableYamlConfig ();
836
+
837
+ if (yaml.HasCompressedMainConfig ()) {
838
+ Y_DEBUG_ABORT_UNLESS (!yaml.HasMainConfig ());
839
+ yaml.SetMainConfig (NYamlConfig::DecompressYamlString (yaml.GetCompressedMainConfig ()));
840
+ yaml.ClearCompressedMainConfig ();
841
+ }
842
+
843
+ if (yaml.HasCompressedStorageConfig ()) {
844
+ Y_DEBUG_ABORT_UNLESS (!yaml.HasStorageConfig ());
845
+ yaml.SetStorageConfig (NYamlConfig::DecompressYamlString (yaml.GetCompressedStorageConfig ()));
846
+ yaml.ClearCompressedStorageConfig ();
823
847
}
848
+
849
+ PersistConfig (yaml.HasMainConfig () ? std::make_optional (yaml.GetMainConfig ()) : std::nullopt,
850
+ yaml.GetMainConfigVersion (),
851
+ yaml.HasStorageConfig () ? std::make_optional (yaml.GetStorageConfig ()) : std::nullopt,
852
+ yaml.HasStorageConfigVersion () ? std::make_optional (yaml.GetStorageConfigVersion ()) : std::nullopt);
853
+
854
+ ExpectedSaveConfigCookie++;
824
855
}
825
856
}
826
857
@@ -1048,8 +1079,8 @@ void TNodeWarden::Handle(TEvPrivate::TEvUpdateNodeDrives::TPtr&) {
1048
1079
void TNodeWarden::Handle (TEvPrivate::TEvRetrySaveConfig::TPtr& ev) {
1049
1080
STLOG (PRI_TRACE, BS_NODE, NW97, " Handle(TEvRetrySaveConfig)" );
1050
1081
if (ev->Cookie == ExpectedSaveConfigCookie) {
1051
- const auto & yamlConfig = ev->Get ()-> YamlConfig ;
1052
- PersistConfig (yamlConfig. GetYAML ( ), yamlConfig. GetConfigVersion () );
1082
+ auto *msg = ev->Get ();
1083
+ PersistConfig (std::move (msg-> MainYaml ), msg-> MainYamlVersion , std::move (msg-> StorageYaml ), msg-> StorageYamlVersion );
1053
1084
ExpectedSaveConfigCookie++;
1054
1085
}
1055
1086
}
@@ -1270,7 +1301,6 @@ bool NKikimr::NStorage::DeriveStorageConfig(const NKikimrConfig::TAppConfig& app
1270
1301
return false ;
1271
1302
}
1272
1303
smTo->CopyFrom (smFrom);
1273
- smTo->ClearInitialConfigYaml (); // do not let this section into final StorageConfig
1274
1304
} else {
1275
1305
config->ClearSelfManagementConfig ();
1276
1306
}
0 commit comments