@@ -31,19 +31,45 @@ std::string ReadStageName(const std::string& filepath) {
3131}
3232
3333#ifdef ARCADIA_ROOT
34- bool IsClownductorPrestable () {
35- constexpr std::string_view filepath = " /etc/clownductor_group" ;
34+ std::optional<std::string> ReadFile (std::string_view filepath) {
3635 auto & tp = engine::current_task::GetBlockingTaskProcessor ();
36+ const std::string filepath_str{filepath};
37+ if (!fs::FileExists (tp, filepath_str)) {
38+ return std::nullopt ;
39+ }
40+
41+ return fs::ReadFileContents (tp, filepath_str);
42+ }
3743
38- if (!fs::FileExists (tp, std::string{filepath})) {
44+ bool IsClownductorPrestable () {
45+ auto content = ReadFile (" /etc/clownductor_group" );
46+ if (!content) {
3947 return false ;
4048 }
41- auto content = fs::ReadFileContents (tp, std::string{filepath});
42- utils::text::Trim (content);
43- return utils::text::EndsWith (content, " _pre_stable" ) || utils::text::EndsWith (content, " _prestable" );
49+
50+ utils::text::Trim (*content);
51+ return utils::text::EndsWith (*content, " _pre_stable" ) || utils::text::EndsWith (*content, " _prestable" );
52+ }
53+
54+ std::string ReadCircuit () {
55+ constexpr std::string_view kCircuitPrefix = " UPLATFORM_CIRCUIT=" ;
56+
57+ const auto content = ReadFile (" /etc/uplatform_environment" );
58+ if (!content) {
59+ return {};
60+ }
61+
62+ for (const auto line : utils::text::SplitIntoStringViewVector (*content, " \n " )) {
63+ const auto trimmed_line = utils::text::TrimView (line);
64+ if (utils::text::StartsWith (trimmed_line, kCircuitPrefix )) {
65+ return std::string{trimmed_line.substr (kCircuitPrefix .size ())};
66+ }
67+ }
68+ return {};
4469}
4570#else
4671bool IsClownductorPrestable () { return false ; }
72+ std::string ReadCircuit () { return {}; }
4773#endif
4874
4975} // namespace
@@ -67,6 +93,7 @@ DynamicConfigClient::DynamicConfigClient(const ComponentConfig& config, const Co
6793 }
6894 }
6995 client_config.is_prestable = IsClownductorPrestable ();
96+ client_config.circuit = ReadCircuit ();
7097 client_config.config_url = config[" config-url" ].As <std::string>();
7198
7299 if (!client_config.stage_name .empty () && client_config.get_configs_overrides_for_service ) {
0 commit comments