diff options
author | Grigory Reznikov <gritukan@nebius.com> | 2024-04-02 22:52:36 +0300 |
---|---|---|
committer | robot-piglet <robot-piglet@yandex-team.com> | 2024-04-02 23:04:58 +0300 |
commit | 710a878d0b66c06d0e79ed31b702d6861482a388 (patch) | |
tree | 62c724b922787db3e89e30603fa637e49c5ee1d9 | |
parent | ba80a9fbc798f333ba35e1f5fe9882d3d91337b2 (diff) | |
download | ydb-710a878d0b66c06d0e79ed31b702d6861482a388.tar.gz |
Support some c-ares options in YT config
No description
---
3971a04217d89905831824822771973f898d4f40
Pull Request resolved: https://github.com/ytsaurus/ytsaurus/pull/500
-rw-r--r-- | yt/yt/core/dns/ares_dns_resolver.cpp | 9 | ||||
-rw-r--r-- | yt/yt/core/dns/config.cpp | 4 | ||||
-rw-r--r-- | yt/yt/core/dns/config.h | 9 |
3 files changed, 21 insertions, 1 deletions
diff --git a/yt/yt/core/dns/ares_dns_resolver.cpp b/yt/yt/core/dns/ares_dns_resolver.cpp index 44eee4eb9c..799a681c3c 100644 --- a/yt/yt/core/dns/ares_dns_resolver.cpp +++ b/yt/yt/core/dns/ares_dns_resolver.cpp @@ -146,8 +146,15 @@ public: // See https://c-ares.haxx.se/ares_init_options.html for full details. int mask = 0; - Options_.flags |= ARES_FLAG_STAYOPEN; + + if (Config_->ForceTcp) { + Options_.flags |= ARES_FLAG_USEVC; + } + if (Config_->KeepSocket) { + Options_.flags |= ARES_FLAG_STAYOPEN; + } mask |= ARES_OPT_FLAGS; + Options_.timeout = static_cast<int>(Config_->ResolveTimeout.MilliSeconds()); mask |= ARES_OPT_TIMEOUTMS; diff --git a/yt/yt/core/dns/config.cpp b/yt/yt/core/dns/config.cpp index 302cb67eb1..1765d7cb8d 100644 --- a/yt/yt/core/dns/config.cpp +++ b/yt/yt/core/dns/config.cpp @@ -18,6 +18,10 @@ void TAresDnsResolverConfig::Register(TRegistrar registrar) .Default(TDuration::Seconds(3)); registrar.Parameter("jitter", &TThis::Jitter) .Default(0.5); + registrar.Parameter("force_tcp", &TThis::ForceTcp) + .Default(false); + registrar.Parameter("keep_socket", &TThis::KeepSocket) + .Default(true); } //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/core/dns/config.h b/yt/yt/core/dns/config.h index b6d7c6e5cc..7e68a0fbc8 100644 --- a/yt/yt/core/dns/config.h +++ b/yt/yt/core/dns/config.h @@ -14,6 +14,7 @@ class TAresDnsResolverConfig public: bool EnableIPv4; bool EnableIPv6; + //! If true, when determining local host name, it will additionally be resolved //! into FQDN by calling |getaddrinfo|. Setting this option to false may be //! useful in MTN environment, in which hostnames are barely resolvable. @@ -33,6 +34,14 @@ public: //! Used to check that bootstrap is being initialized from a correct container. std::optional<TString> ExpectedLocalHostName; + //! If set, Ares forcefully uses TCP for DNS queries. + //! See ARES_FLAG_USEVC. + bool ForceTcp; + + //! If set, Ares keeps socket open even if there are no active queries. + //! See ARES_FLAG_STAYOPEN. + bool KeepSocket; + REGISTER_YSON_STRUCT(TAresDnsResolverConfig); static void Register(TRegistrar registrar); |