@@ -392,6 +392,9 @@ void TNodeWarden::Bootstrap() {
392392
393393 // fill in a base storage config (from the file)
394394 NKikimrConfig::TAppConfig appConfig;
395+ if (Cfg->DomainsConfig ) {
396+ appConfig.MutableDomainsConfig ()->CopyFrom (*Cfg->DomainsConfig );
397+ }
395398 appConfig.MutableBlobStorageConfig ()->CopyFrom (Cfg->BlobStorageConfig );
396399 appConfig.MutableNameserviceConfig ()->CopyFrom (Cfg->NameserviceConfig );
397400 TString errorReason;
@@ -1014,11 +1017,26 @@ bool NKikimr::NStorage::DeriveStorageConfig(const NKikimrConfig::TAppConfig& app
10141017 const auto & ssFrom = bsFrom.GetServiceSet ();
10151018 auto *ssTo = bsTo->MutableServiceSet ();
10161019
1017- ssTo->MutableAvailabilityDomains ()->CopyFrom (ssFrom.GetAvailabilityDomains ());
1020+ // update availability domains if set
1021+ if (ssFrom.AvailabilityDomainsSize ()) {
1022+ ssTo->MutableAvailabilityDomains ()->CopyFrom (ssFrom.GetAvailabilityDomains ());
1023+ }
1024+
1025+ // replace replication broker configuration
10181026 if (ssFrom.HasReplBrokerConfig ()) {
10191027 ssTo->MutableReplBrokerConfig ()->CopyFrom (ssFrom.GetReplBrokerConfig ());
1028+ } else {
1029+ ssTo->ClearReplBrokerConfig ();
10201030 }
1021- if (!ssTo->PDisksSize () && !ssTo->VDisksSize () && !ssTo->GroupsSize ()) {
1031+
1032+ const auto hasStaticGroupInfo = [](const NKikimrBlobStorage::TNodeWardenServiceSet& ss) {
1033+ return ss.PDisksSize () && ss.VDisksSize () && ss.GroupsSize ();
1034+ };
1035+
1036+ // update static group information unless distconf is enabled
1037+ if (!hasStaticGroupInfo (ssFrom) && bsFrom.HasAutoconfigSettings ()) {
1038+ // distconf enabled, keep it as is
1039+ } else if (!hasStaticGroupInfo (*ssTo)) {
10221040 ssTo->MutablePDisks ()->CopyFrom (ssFrom.GetPDisks ());
10231041 ssTo->MutableVDisks ()->CopyFrom (ssFrom.GetVDisks ());
10241042 ssTo->MutableGroups ()->CopyFrom (ssFrom.GetGroups ());
@@ -1031,16 +1049,16 @@ bool NKikimr::NStorage::DeriveStorageConfig(const NKikimrConfig::TAppConfig& app
10311049 };
10321050
10331051 auto pdiskKey = [](const auto *item) {
1034- return TStringBuilder () << " PDisk NodeId# " << item->GetNodeID () << " PDiskId# " << item->GetPDiskID ();
1052+ return TStringBuilder () << " PDisk [ " << item->GetNodeID () << ' : ' << item->GetPDiskID () << ' ] ' ;
10351053 };
10361054
10371055 auto vdiskKey = [](const auto *item) {
1038- return TStringBuilder () << " VDisk NodeId# " << item->GetNodeID () << " PDiskId# " << item->GetPDiskID ()
1039- << " VDiskSlotId# " << item->GetVDiskSlotID ();
1056+ return TStringBuilder () << " VSlot [ " << item->GetNodeID () << ' : ' << item->GetPDiskID () << ' : '
1057+ << item->GetVDiskSlotID () << ' ] ' ;
10401058 };
10411059
10421060 auto groupKey = [](const auto *item) {
1043- return TStringBuilder () << " group GroupId# " << item->GetGroupID ();
1061+ return TStringBuilder () << " group " << item->GetGroupID ();
10441062 };
10451063
10461064 auto duplicateKey = [&](auto && key) { return error (std::move (key), " duplicate key in existing StorageConfig" ); };
@@ -1064,7 +1082,13 @@ bool NKikimr::NStorage::DeriveStorageConfig(const NKikimrConfig::TAppConfig& app
10641082 }
10651083 }
10661084 if (!pdiskMap.empty ()) {
1067- *errorReason = " some PDisks were added in newly provided configuration" ;
1085+ TStringStream err;
1086+ err << " some static PDisks were removed in newly provided configuration:" ;
1087+ for (const auto & [id, _] : pdiskMap) {
1088+ const auto & [nodeId, pdiskId] = id;
1089+ err << " [" << nodeId << ' :' << pdiskId << ' ]' ;
1090+ }
1091+ *errorReason = std::move (err.Str ());
10681092 return false ;
10691093 }
10701094
@@ -1096,7 +1120,13 @@ bool NKikimr::NStorage::DeriveStorageConfig(const NKikimrConfig::TAppConfig& app
10961120 }
10971121 }
10981122 if (!vdiskMap.empty ()) {
1099- *errorReason = " some VDisks were added in newly provided configuration" ;
1123+ TStringStream err;
1124+ err << " some static VDisks were removed in newly provided configuration:" ;
1125+ for (const auto & [id, _] : vdiskMap) {
1126+ const auto & [nodeId, pdiskId, vdiskSlotId] = id;
1127+ err << " [" << nodeId << ' :' << pdiskId << ' :' << vdiskSlotId << ' ]' ;
1128+ }
1129+ *errorReason = std::move (err.Str ());
11001130 return false ;
11011131 }
11021132
@@ -1116,12 +1146,20 @@ bool NKikimr::NStorage::DeriveStorageConfig(const NKikimrConfig::TAppConfig& app
11161146 }
11171147 }
11181148 if (!groupMap.empty ()) {
1119- *errorReason = " some groups were added in newly provided configuration" ;
1149+ *errorReason = " some static groups were removed in newly provided configuration" ;
11201150 return false ;
11211151 }
11221152 }
11231153 }
11241154
1155+ // copy define box
1156+ if (bsFrom.HasDefineBox ()) {
1157+ bsTo->MutableDefineBox ()->CopyFrom (bsFrom.GetDefineBox ());
1158+ } else {
1159+ bsTo->ClearDefineBox ();
1160+ }
1161+ bsTo->MutableDefineHostConfig ()->CopyFrom (bsFrom.GetDefineHostConfig ());
1162+
11251163 // copy nameservice-related things
11261164 if (!appConfig.HasNameserviceConfig ()) {
11271165 *errorReason = " origin config missing mandatory NameserviceConfig section" ;
@@ -1148,7 +1186,47 @@ bool NKikimr::NStorage::DeriveStorageConfig(const NKikimrConfig::TAppConfig& app
11481186 // and copy ClusterUUID from there too
11491187 config->SetClusterUUID (nsFrom.GetClusterUUID ());
11501188
1151- // TODO(alexvru): apply SS, SSB, SB configs from there too
1189+ if (appConfig.HasDomainsConfig ()) {
1190+ const auto & domains = appConfig.GetDomainsConfig ();
1191+
1192+ // we expect strictly one domain
1193+ if (domains.DomainSize () == 1 ) {
1194+ const auto & domain = domains.GetDomain (0 );
1195+
1196+ auto updateConfig = [&](bool needMerge, auto *to, const auto & from) {
1197+ if (needMerge) {
1198+ char prefix[TActorId::MaxServiceIDLength] = {0 };
1199+ auto toInfo = BuildStateStorageInfo (prefix, *to);
1200+ auto fromInfo = BuildStateStorageInfo (prefix, from);
1201+ if (toInfo->NToSelect != fromInfo->NToSelect ) {
1202+ *errorReason = " NToSelect differs" ;
1203+ return false ;
1204+ } else if (toInfo->SelectAllReplicas () != fromInfo->SelectAllReplicas ()) {
1205+ *errorReason = " StateStorage rings differ" ;
1206+ return false ;
1207+ }
1208+ }
1209+
1210+ to->CopyFrom (from);
1211+ return true ;
1212+ };
1213+
1214+ // find state storage setup for that domain
1215+ for (const auto & ss : domains.GetStateStorage ()) {
1216+ if (domain.SSIdSize () == 1 && ss.GetSSId () == domain.GetSSId (0 )) {
1217+ const bool hadStateStorageConfig = config->HasStateStorageConfig ();
1218+ const bool hadStateStorageBoardConfig = config->HasStateStorageBoardConfig ();
1219+ const bool hadSchemeBoardConfig = config->HasSchemeBoardConfig ();
1220+ if (!updateConfig (hadStateStorageConfig, config->MutableStateStorageConfig (), ss) ||
1221+ !updateConfig (hadStateStorageBoardConfig, config->MutableStateStorageBoardConfig (), ss) ||
1222+ !updateConfig (hadSchemeBoardConfig, config->MutableSchemeBoardConfig (), ss)) {
1223+ return false ;
1224+ }
1225+ break ;
1226+ }
1227+ }
1228+ }
1229+ }
11521230
11531231 return true ;
11541232}
0 commit comments