diff options
author | innokentii <innokentii@yandex-team.com> | 2023-04-24 10:47:02 +0300 |
---|---|---|
committer | innokentii <innokentii@yandex-team.com> | 2023-04-24 10:47:02 +0300 |
commit | 69783e85e2d334c8f0326fc6abcc1c8a4e86c519 (patch) | |
tree | eb25f849bca2f8ee2108a18988b08ee52cea279c | |
parent | d584b272cb94e044cce1dd821877b02cbf93387e (diff) | |
download | ydb-69783e85e2d334c8f0326fc6abcc1c8a4e86c519.tar.gz |
Fix node_id label setup
fix node_id label setup
-rw-r--r-- | ydb/core/driver_lib/cli_utils/cli_cmds_server.cpp | 53 |
1 files changed, 33 insertions, 20 deletions
diff --git a/ydb/core/driver_lib/cli_utils/cli_cmds_server.cpp b/ydb/core/driver_lib/cli_utils/cli_cmds_server.cpp index c04b96b0d66..74ef5411478 100644 --- a/ydb/core/driver_lib/cli_utils/cli_cmds_server.cpp +++ b/ydb/core/driver_lib/cli_utils/cli_cmds_server.cpp @@ -382,22 +382,47 @@ protected: RunConfig.Labels["node_id"] = ToString(NodeId); RunConfig.Labels["node_host"] = FQDNHostName(); - RunConfig.Labels["tenant"] = RunConfig.TenantName; + RunConfig.Labels["tenant"] = TenantName; RunConfig.Labels["node_type"] = NodeType; // will be replaced with proper version info RunConfig.Labels["branch"] = GetBranch(); RunConfig.Labels["rev"] = ToString(GetProgramSvnRevision()); RunConfig.Labels["dynamic"] = ToString(NodeBrokerAddresses.empty() ? "false" : "true"); + NKikimrConfig::TLabel *dynamicLabel = nullptr; + NKikimrConfig::TLabel *nodeIdLabel = nullptr; + for (const auto& [name, value] : RunConfig.Labels) { auto *label = RunConfig.AppConfig.AddLabels(); + if (name == "dynamic") { + dynamicLabel = label; + } + if (name == "node_id") { + nodeIdLabel = label; + } label->SetName(name); label->SetValue(value); } RunConfig.ClusterName = ClusterName; - MaybeRegisterAndLoadConfigs(); + // static node + if (NodeBrokerAddresses.empty() && !NodeBrokerPort) { + if (!NodeId) { + ythrow yexception() << "Either --node [NUM|'static'] or --node-broker[-port] should be specified"; + } + + if (!HierarchicalCfg && RunConfig.PathToConfigCacheFile) + LoadCachedConfigsForStaticNode(); + } else { + RegisterDynamicNode(); + + RunConfig.Labels["node_id"] = ToString(RunConfig.NodeId); + nodeIdLabel->SetValue(RunConfig.Labels["node_id"]); + + if (!HierarchicalCfg && !IgnoreCmsConfigs) + LoadConfigForDynamicNode(); + } LoadYamlConfig(); @@ -703,6 +728,12 @@ protected: messageBusConfig->SetStartTracingBusProxy(!!TracePath); messageBusConfig->SetTracePath(TracePath); } + + if (RunConfig.AppConfig.HasDynamicNameserviceConfig()) { + bool isDynamic = RunConfig.NodeId > RunConfig.AppConfig.GetDynamicNameserviceConfig().GetMaxStaticNodeId(); + RunConfig.Labels["dynamic"] = ToString(isDynamic ? "true" : "false"); + dynamicLabel->SetValue(RunConfig.Labels["dynamic"]); + } } inline bool LoadConfigFromCMS() { @@ -884,24 +915,6 @@ protected: } } - void MaybeRegisterAndLoadConfigs() - { - // static node - if (NodeBrokerAddresses.empty() && !NodeBrokerPort) { - if (!NodeId) { - ythrow yexception() << "Either --node [NUM|'static'] or --node-broker[-port] should be specified"; - } - - if (!HierarchicalCfg && RunConfig.PathToConfigCacheFile) - LoadCachedConfigsForStaticNode(); - return; - } - - RegisterDynamicNode(); - if (!HierarchicalCfg && !IgnoreCmsConfigs) - LoadConfigForDynamicNode(); - } - THolder<NClient::TRegistrationResult> TryToRegisterDynamicNode( const TString &addr, const TString &domainName, |