From 47ff3a809baa3b8e752b77edffddbc73a55055b5 Mon Sep 17 00:00:00 2001 From: Andrey Chulkov Date: Sat, 2 Nov 2024 10:10:06 +0300 Subject: Use cell leader address as sanitized host This PR addresses multiple issues: * Host sanitization was dependent on cell peer hostnames having the same length. The fallback was the local host name, which is different for different peers and can lead to snapshot mismatch. * The sanitized host attribute is only **serialized** when running under error sanitizer guard. However, response errors aren't serialized in `Automaton`, so right now all such errors are returned to the user without the host attribute. Conversely, PRK serialization is performed in `Automaton`, so we were storing the potentially differing host names :) The new approach uses the address of the leading peer in the cell as the sanitized host name, and a fixed placeholder if it is not possible to determine it for some reason. This way we don't need additional options for cellar nodes, since the leader is handling all requests and sanitization is not poisoning any errors. Additionally, the host attribute is always serialized into errors, if available, same as datetime. Also deletes `SanitizeLocalHostName` helper and corresponding unittest as obsolete. --- Pull Request resolved: https://github.com/ytsaurus/ytsaurus/pull/908 commit_hash:04cb44b995e467540d5921d2bf90f2d8c2ac2b06 --- yt/yt/core/misc/error.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/yt/yt/core/misc/error.cpp b/yt/yt/core/misc/error.cpp index c4de07c2bf5..0fc60af3d4f 100644 --- a/yt/yt/core/misc/error.cpp +++ b/yt/yt/core/misc/error.cpp @@ -336,12 +336,12 @@ void Serialize( .Item("attributes").DoMap([&] (auto fluent) { if (error.HasOriginAttributes()) { fluent - .Item("host").Value(GetHost(error)) .Item("pid").Value(error.GetPid()) .Item("tid").Value(error.GetTid()) .Item("thread").Value(error.GetThreadName()) .Item("fid").Value(GetFid(error)); - } else if (IsErrorSanitizerEnabled() && HasHost(error)) { + } + if (HasHost(error)) { fluent .Item("host").Value(GetHost(error)); } @@ -455,9 +455,6 @@ void ToProto(NYT::NProto::TError* protoError, const TError& error) }; if (error.HasOriginAttributes()) { - static const TString HostKey("host"); - addAttribute(HostKey, GetHost(error)); - static const TString PidKey("pid"); addAttribute(PidKey, error.GetPid()); @@ -469,7 +466,9 @@ void ToProto(NYT::NProto::TError* protoError, const TError& error) static const TString FidKey("fid"); addAttribute(FidKey, GetFid(error)); - } else if (IsErrorSanitizerEnabled() && HasHost(error)) { + } + + if (HasHost(error)) { static const TString HostKey("host"); addAttribute(HostKey, GetHost(error)); } -- cgit v1.3