|
@@ -134,12 +134,7 @@ public:
|
|
|
return NKikimrServices::TActivity::CONFIGS_DISPATCHER_ACTOR;
|
|
|
}
|
|
|
|
|
|
- TConfigsDispatcher(
|
|
|
- const NKikimrConfig::TAppConfig &config,
|
|
|
- const TMap<TString, TString> &labels,
|
|
|
- const NKikimrConfig::TAppConfig &initialCmsConfig,
|
|
|
- const NKikimrConfig::TAppConfig &initialCmsYamlConfig,
|
|
|
- const THashMap<ui32, TConfigItemInfo> &configInitInfo);
|
|
|
+ TConfigsDispatcher(const TConfigsDispatcherInitInfo& initInfo);
|
|
|
|
|
|
void Bootstrap();
|
|
|
|
|
@@ -164,6 +159,8 @@ public:
|
|
|
|
|
|
NKikimrConfig::TAppConfig ParseYamlProtoConfig();
|
|
|
|
|
|
+ TDynBitMap FilterKinds(const TDynBitMap& in);
|
|
|
+
|
|
|
void Handle(NMon::TEvHttpInfo::TPtr &ev);
|
|
|
void Handle(TEvInterconnect::TEvNodesInfo::TPtr &ev);
|
|
|
void Handle(TEvConsole::TEvConfigSubscriptionNotification::TPtr &ev);
|
|
@@ -231,12 +228,11 @@ public:
|
|
|
|
|
|
|
|
|
private:
|
|
|
- TMap<TString, TString> Labels;
|
|
|
- const NKikimrConfig::TAppConfig InitialConfig;
|
|
|
+ const TMap<TString, TString> Labels;
|
|
|
+ const std::variant<std::monostate, TDenyList, TAllowList> ItemsServeRules;
|
|
|
+ const NKikimrConfig::TAppConfig BaseConfig;
|
|
|
NKikimrConfig::TAppConfig CurrentConfig;
|
|
|
- const NKikimrConfig::TAppConfig InitialCmsConfig;
|
|
|
- const NKikimrConfig::TAppConfig InitialCmsYamlConfig;
|
|
|
- const THashMap<ui32, TConfigItemInfo> ConfigInitInfo;
|
|
|
+ const std::optional<TDebugInfo> DebugInfo;
|
|
|
ui64 NextRequestCookie;
|
|
|
TVector<TActorId> HttpRequests;
|
|
|
TActorId CommonSubscriptionClient;
|
|
@@ -256,21 +252,14 @@ private:
|
|
|
|
|
|
};
|
|
|
|
|
|
-TConfigsDispatcher::TConfigsDispatcher(
|
|
|
- const NKikimrConfig::TAppConfig &config,
|
|
|
- const TMap<TString, TString> &labels,
|
|
|
- const NKikimrConfig::TAppConfig &initialCmsConfig,
|
|
|
- const NKikimrConfig::TAppConfig &initialCmsYamlConfig,
|
|
|
- const THashMap<ui32, TConfigItemInfo> &configInitInfo)
|
|
|
- : Labels(labels)
|
|
|
- , InitialConfig(config)
|
|
|
- , CurrentConfig(config)
|
|
|
- , InitialCmsConfig(initialCmsConfig)
|
|
|
- , InitialCmsYamlConfig(initialCmsYamlConfig)
|
|
|
- , ConfigInitInfo(configInitInfo)
|
|
|
+TConfigsDispatcher::TConfigsDispatcher(const TConfigsDispatcherInitInfo& initInfo)
|
|
|
+ : Labels(initInfo.Labels)
|
|
|
+ , ItemsServeRules(initInfo.ItemsServeRules)
|
|
|
+ , BaseConfig(initInfo.InitialConfig)
|
|
|
+ , CurrentConfig(initInfo.InitialConfig)
|
|
|
+ , DebugInfo(initInfo.DebugInfo)
|
|
|
, NextRequestCookie(Now().GetValue())
|
|
|
-{
|
|
|
-}
|
|
|
+{}
|
|
|
|
|
|
void TConfigsDispatcher::Bootstrap()
|
|
|
{
|
|
@@ -401,9 +390,12 @@ void TConfigsDispatcher::ReplyMonJson(TActorId mailbox) {
|
|
|
response.InsertValue("yaml_config", YamlConfig);
|
|
|
response.InsertValue("resolved_json_config", NJson::ReadJsonFastTree(ResolvedJsonConfig, true));
|
|
|
response.InsertValue("current_json_config", NJson::ReadJsonFastTree(NProtobufJson::Proto2Json(CurrentConfig, NYamlConfig::GetProto2JsonConfig()), true));
|
|
|
- response.InsertValue("initial_json_config", NJson::ReadJsonFastTree(NProtobufJson::Proto2Json(InitialConfig, NYamlConfig::GetProto2JsonConfig()), true));
|
|
|
- response.InsertValue("initial_cms_json_config", NJson::ReadJsonFastTree(NProtobufJson::Proto2Json(InitialCmsConfig, NYamlConfig::GetProto2JsonConfig()), true));
|
|
|
- response.InsertValue("initial_cms_yaml_json_config", NJson::ReadJsonFastTree(NProtobufJson::Proto2Json(InitialCmsYamlConfig, NYamlConfig::GetProto2JsonConfig()), true));
|
|
|
+
|
|
|
+ if (DebugInfo) {
|
|
|
+ response.InsertValue("initial_json_config", NJson::ReadJsonFastTree(NProtobufJson::Proto2Json(DebugInfo->StaticConfig, NYamlConfig::GetProto2JsonConfig()), true));
|
|
|
+ response.InsertValue("initial_cms_json_config", NJson::ReadJsonFastTree(NProtobufJson::Proto2Json(DebugInfo->OldDynConfig, NYamlConfig::GetProto2JsonConfig()), true));
|
|
|
+ response.InsertValue("initial_cms_yaml_json_config", NJson::ReadJsonFastTree(NProtobufJson::Proto2Json(DebugInfo->NewDynConfig, NYamlConfig::GetProto2JsonConfig()), true));
|
|
|
+ }
|
|
|
|
|
|
NJson::WriteJson(&str, &response, {});
|
|
|
|
|
@@ -420,6 +412,29 @@ void TConfigsDispatcher::Handle(TEvConsole::TEvConfigNotificationRequest::TPtr &
|
|
|
Send(ev->Sender, resp.Release(), 0, ev->Cookie);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+TDynBitMap TConfigsDispatcher::FilterKinds(const TDynBitMap& in) {
|
|
|
+ TDynBitMap out;
|
|
|
+
|
|
|
+ if (const auto* denyList = std::get_if<TDenyList>(&ItemsServeRules)) {
|
|
|
+ Y_FOR_EACH_BIT(kind, in) {
|
|
|
+ if (!denyList->Items.contains(kind)) {
|
|
|
+ out.Set(kind);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (const auto* allowList = std::get_if<TAllowList>(&ItemsServeRules)) {
|
|
|
+ Y_FOR_EACH_BIT(kind, in) {
|
|
|
+ if (allowList->Items.contains(kind)) {
|
|
|
+ out.Set(kind);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ out = in;
|
|
|
+ }
|
|
|
+
|
|
|
+ return out;
|
|
|
+}
|
|
|
+
|
|
|
void TConfigsDispatcher::Handle(TEvInterconnect::TEvNodesInfo::TPtr &ev)
|
|
|
{
|
|
|
Y_UNUSED(ev);
|
|
@@ -495,14 +510,14 @@ void TConfigsDispatcher::Handle(TEvInterconnect::TEvNodesInfo::TPtr &ev)
|
|
|
str << "Coloring: \"<font color=\"red\">config not set</font>\","
|
|
|
<< " \"<font color=\"green\">config set in dynamic config</font>\", \"<font color=\"#007bff\">config set in static config</font>\"" << Endl;
|
|
|
str << "</div>" << Endl;
|
|
|
- NHttp::OutputRichConfigHTML(str, InitialConfig, YamlProtoConfig, CurrentConfig, DYNAMIC_KINDS, NON_YAML_KINDS, YamlConfigEnabled);
|
|
|
+ NHttp::OutputRichConfigHTML(str, BaseConfig, YamlProtoConfig, CurrentConfig, DYNAMIC_KINDS, NON_YAML_KINDS, YamlConfigEnabled);
|
|
|
}
|
|
|
str << "<br />" << Endl;
|
|
|
COLLAPSED_REF_CONTENT("effective-startup-config", "Effective startup config") {
|
|
|
str << "<div class=\"alert alert-primary tab-left\" role=\"alert\">" << Endl;
|
|
|
str << "Some of these configs may be overwritten by dynamic ones." << Endl;
|
|
|
str << "</div>" << Endl;
|
|
|
- NHttp::OutputConfigHTML(str, InitialConfig);
|
|
|
+ NHttp::OutputConfigHTML(str, BaseConfig);
|
|
|
}
|
|
|
str << "<br />" << Endl;
|
|
|
COLLAPSED_REF_CONTENT("effective-dynamic-config", "Effective dynamic config") {
|
|
@@ -511,10 +526,10 @@ void TConfigsDispatcher::Handle(TEvInterconnect::TEvNodesInfo::TPtr &ev)
|
|
|
str << "</div>" << Endl;
|
|
|
NKikimrConfig::TAppConfig trunc;
|
|
|
if (YamlConfigEnabled) {
|
|
|
- ReplaceConfigItems(YamlProtoConfig, trunc, KindsToBitMap(DYNAMIC_KINDS), InitialConfig);
|
|
|
- ReplaceConfigItems(CurrentConfig, trunc, KindsToBitMap(NON_YAML_KINDS), trunc, false);
|
|
|
+ ReplaceConfigItems(YamlProtoConfig, trunc, FilterKinds(KindsToBitMap(DYNAMIC_KINDS)), BaseConfig);
|
|
|
+ ReplaceConfigItems(CurrentConfig, trunc, FilterKinds(KindsToBitMap(NON_YAML_KINDS)), trunc, false);
|
|
|
} else {
|
|
|
- ReplaceConfigItems(CurrentConfig, trunc, KindsToBitMap(DYNAMIC_KINDS), InitialConfig);
|
|
|
+ ReplaceConfigItems(CurrentConfig, trunc, FilterKinds(KindsToBitMap(DYNAMIC_KINDS)), BaseConfig);
|
|
|
}
|
|
|
NHttp::OutputConfigHTML(str, trunc);
|
|
|
}
|
|
@@ -522,7 +537,15 @@ void TConfigsDispatcher::Handle(TEvInterconnect::TEvNodesInfo::TPtr &ev)
|
|
|
COLLAPSED_REF_CONTENT("debug-info", "Debug info") {
|
|
|
DIV_CLASS("tab-left") {
|
|
|
COLLAPSED_REF_CONTENT("effective-config-debug-info", "Effective config debug info") {
|
|
|
- NHttp::OutputConfigDebugInfoHTML(str, InitialConfig, YamlProtoConfig, CurrentConfig, ConfigInitInfo, DYNAMIC_KINDS, NON_YAML_KINDS, YamlConfigEnabled);
|
|
|
+ NHttp::OutputConfigDebugInfoHTML(
|
|
|
+ str,
|
|
|
+ BaseConfig,
|
|
|
+ YamlProtoConfig,
|
|
|
+ CurrentConfig,
|
|
|
+ {DebugInfo ? DebugInfo->InitInfo : THashMap<ui32, TConfigItemInfo>{}},
|
|
|
+ DYNAMIC_KINDS,
|
|
|
+ NON_YAML_KINDS,
|
|
|
+ YamlConfigEnabled);
|
|
|
}
|
|
|
str << "<br />" << Endl;
|
|
|
COLLAPSED_REF_CONTENT("state", "State") {
|
|
@@ -652,15 +675,17 @@ void TConfigsDispatcher::Handle(TEvInterconnect::TEvNodesInfo::TPtr &ev)
|
|
|
}
|
|
|
str << "<br />" << Endl;
|
|
|
COLLAPSED_REF_CONTENT("initial-config", "Initial config") {
|
|
|
- NHttp::OutputConfigHTML(str, InitialConfig);
|
|
|
+ NHttp::OutputConfigHTML(str, BaseConfig);
|
|
|
}
|
|
|
- str << "<br />" << Endl;
|
|
|
- COLLAPSED_REF_CONTENT("initial-cms-config", "Initial CMS config") {
|
|
|
- NHttp::OutputConfigHTML(str, InitialCmsConfig);
|
|
|
- }
|
|
|
- str << "<br />" << Endl;
|
|
|
- COLLAPSED_REF_CONTENT("initial-cms-yaml-config", "Initial CMS YAML config") {
|
|
|
- NHttp::OutputConfigHTML(str, InitialCmsYamlConfig);
|
|
|
+ if (DebugInfo) {
|
|
|
+ str << "<br />" << Endl;
|
|
|
+ COLLAPSED_REF_CONTENT("initial-cms-config", "Initial CMS config") {
|
|
|
+ NHttp::OutputConfigHTML(str, DebugInfo->OldDynConfig);
|
|
|
+ }
|
|
|
+ str << "<br />" << Endl;
|
|
|
+ COLLAPSED_REF_CONTENT("initial-cms-yaml-config", "Initial CMS YAML config") {
|
|
|
+ NHttp::OutputConfigHTML(str, DebugInfo->NewDynConfig);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -743,7 +768,7 @@ void TConfigsDispatcher::Handle(TEvConsole::TEvConfigSubscriptionNotification::T
|
|
|
bool hasAffectedKinds = false;
|
|
|
|
|
|
if (subscription->Yaml && YamlConfigEnabled) {
|
|
|
- ReplaceConfigItems(YamlProtoConfig, trunc, subscription->Kinds, InitialConfig);
|
|
|
+ ReplaceConfigItems(YamlProtoConfig, trunc, FilterKinds(subscription->Kinds), BaseConfig);
|
|
|
} else {
|
|
|
Y_FOR_EACH_BIT(kind, kinds) {
|
|
|
if (affectedKinds.contains(kind)) {
|
|
@@ -756,7 +781,7 @@ void TConfigsDispatcher::Handle(TEvConsole::TEvConfigSubscriptionNotification::T
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- ReplaceConfigItems(ev->Get()->Record.GetConfig(), trunc, kinds, InitialConfig);
|
|
|
+ ReplaceConfigItems(ev->Get()->Record.GetConfig(), trunc, FilterKinds(kinds), BaseConfig);
|
|
|
}
|
|
|
|
|
|
if (hasAffectedKinds || !CompareConfigs(subscription->CurrentConfig.Config, trunc) || CurrentStateFunc() == &TThis::StateInit) {
|
|
@@ -821,9 +846,9 @@ void TConfigsDispatcher::Handle(TEvConfigsDispatcher::TEvGetConfigRequest::TPtr
|
|
|
auto trunc = std::make_shared<NKikimrConfig::TAppConfig>();
|
|
|
auto kinds = KindsToBitMap(ev->Get()->ConfigItemKinds);
|
|
|
if (YamlConfigEnabled && yamlKinds) {
|
|
|
- ReplaceConfigItems(YamlProtoConfig, *trunc, kinds, InitialConfig);
|
|
|
+ ReplaceConfigItems(YamlProtoConfig, *trunc, FilterKinds(kinds), BaseConfig);
|
|
|
} else {
|
|
|
- ReplaceConfigItems(CurrentConfig, *trunc, kinds, InitialConfig);
|
|
|
+ ReplaceConfigItems(CurrentConfig, *trunc, FilterKinds(kinds), BaseConfig);
|
|
|
}
|
|
|
resp->Config = trunc;
|
|
|
|
|
@@ -894,9 +919,9 @@ void TConfigsDispatcher::Handle(TEvConfigsDispatcher::TEvSetConfigSubscriptionRe
|
|
|
subscription->UpdateInProcess = MakeHolder<TEvConsole::TEvConfigNotificationRequest>();
|
|
|
NKikimrConfig::TAppConfig trunc;
|
|
|
if (YamlConfigEnabled) {
|
|
|
- ReplaceConfigItems(YamlProtoConfig, trunc, kinds, InitialConfig);
|
|
|
+ ReplaceConfigItems(YamlProtoConfig, trunc, FilterKinds(kinds), BaseConfig);
|
|
|
} else {
|
|
|
- ReplaceConfigItems(CurrentConfig, trunc, kinds, InitialConfig);
|
|
|
+ ReplaceConfigItems(CurrentConfig, trunc, FilterKinds(kinds), BaseConfig);
|
|
|
}
|
|
|
subscription->UpdateInProcess->Record.MutableConfig()->CopyFrom(trunc);
|
|
|
Y_FOR_EACH_BIT(kind, kinds) {
|
|
@@ -998,14 +1023,8 @@ void TConfigsDispatcher::Handle(TEvConsole::TEvGetNodeLabelsRequest::TPtr &ev) {
|
|
|
Send(ev->Sender, Response.Release());
|
|
|
}
|
|
|
|
|
|
-IActor *CreateConfigsDispatcher(
|
|
|
- const NKikimrConfig::TAppConfig &config,
|
|
|
- const TMap<TString, TString> &labels,
|
|
|
- const NKikimrConfig::TAppConfig &initialCmsConfig,
|
|
|
- const NKikimrConfig::TAppConfig &initialCmsYamlConfig,
|
|
|
- const THashMap<ui32, TConfigItemInfo> &configInitInfo)
|
|
|
-{
|
|
|
- return new TConfigsDispatcher(config, labels, initialCmsConfig, initialCmsYamlConfig, configInitInfo);
|
|
|
+IActor *CreateConfigsDispatcher(const TConfigsDispatcherInitInfo& initInfo) {
|
|
|
+ return new TConfigsDispatcher(initInfo);
|
|
|
}
|
|
|
|
|
|
} // namespace NKikimr::NConsole
|