aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorermolovd <ermolovd@yandex-team.com>2024-11-23 10:59:09 +0300
committerermolovd <ermolovd@yandex-team.com>2024-11-23 11:10:09 +0300
commit8e841b73f8df78e6844dfe9350d0f0a6c98c30cb (patch)
tree1c85d665bb9b428d3c5136307bd64dd9187bd66d
parente8c90ae8a977270555b84d2e098839ea75168ce9 (diff)
downloadydb-8e841b73f8df78e6844dfe9350d0f0a6c98c30cb.tar.gz
YT-23422: do not write command line into attributes of operations
* Changelog entry Type: feature Component: cpp-sdk C++ SDK doesn't write launching process command line to operation attributes. commit_hash:c50cbc2a31f5a3b733833767fe94019a0d7615d3
-rw-r--r--yt/cpp/mapreduce/client/init.cpp4
-rw-r--r--yt/cpp/mapreduce/client/operation.cpp6
-rw-r--r--yt/cpp/mapreduce/interface/config.cpp34
-rw-r--r--yt/cpp/mapreduce/interface/config.h10
-rw-r--r--yt/cpp/mapreduce/raw_client/rpc_parameters_serialization.cpp6
5 files changed, 16 insertions, 44 deletions
diff --git a/yt/cpp/mapreduce/client/init.cpp b/yt/cpp/mapreduce/client/init.cpp
index ea1f7a5561..3a68942cab 100644
--- a/yt/cpp/mapreduce/client/init.cpp
+++ b/yt/cpp/mapreduce/client/init.cpp
@@ -166,7 +166,7 @@ NLogging::ELogLevel ToCoreLogLevel(ILogger::ELevel level)
Y_ABORT();
}
-void CommonInitialize(int argc, const char** argv)
+void CommonInitialize(int, const char**)
{
auto logLevelStr = to_lower(TConfig::Get()->LogLevel);
ILogger::ELevel logLevel;
@@ -187,8 +187,6 @@ void CommonInitialize(int argc, const char** argv)
NLogging::TLogManager::Get()->Configure(coreLoggingConfig);
}
SetLogger(logger);
-
- TProcessState::Get()->SetCommandLine(argc, argv);
}
void NonJobInitialize(const TInitializeOptions& options)
diff --git a/yt/cpp/mapreduce/client/operation.cpp b/yt/cpp/mapreduce/client/operation.cpp
index c96c191bdd..824b36b206 100644
--- a/yt/cpp/mapreduce/client/operation.cpp
+++ b/yt/cpp/mapreduce/client/operation.cpp
@@ -804,10 +804,8 @@ void BuildCommonOperationPart(
startedBySpec["user"] = properties->UserName;
startedBySpec["wrapper_version"] = properties->ClientVersion;
- startedBySpec["command"] = TNode::CreateList();
- for (const auto& arg : properties->CensoredCommandLine) {
- startedBySpec["command"].Add(arg);
- }
+ startedBySpec["binary"] = properties->BinaryPath;
+ startedBySpec["binary_name"] = properties->BinaryName;
auto nirvanaBlockUrl = GetNirvanaBlockUrlFromContext();
if (!nirvanaBlockUrl.IsUndefined()) {
startedBySpec["nirvana_block_url"] = nirvanaBlockUrl;
diff --git a/yt/cpp/mapreduce/interface/config.cpp b/yt/cpp/mapreduce/interface/config.cpp
index 418868a7eb..b1f546f7a4 100644
--- a/yt/cpp/mapreduce/interface/config.cpp
+++ b/yt/cpp/mapreduce/interface/config.cpp
@@ -1,6 +1,5 @@
#include "config.h"
-
-#include "operation.h"
+#include "serialize.h"
#include <yt/cpp/mapreduce/interface/logging/yt_log.h>
@@ -12,17 +11,18 @@
#include <library/cpp/yson/json/yson2json_adapter.h>
-#include <util/string/strip.h>
#include <util/folder/dirut.h>
#include <util/folder/path.h>
-#include <util/stream/file.h>
#include <util/generic/singleton.h>
+#include <util/stream/file.h>
#include <util/string/builder.h>
#include <util/string/cast.h>
+#include <util/string/strip.h>
#include <util/string/type.h>
+#include <util/system/env.h>
+#include <util/system/execpath.h>
#include <util/system/hostname.h>
#include <util/system/user.h>
-#include <util/system/env.h>
namespace NYT {
@@ -294,27 +294,9 @@ TProcessState::TProcessState()
Pid = static_cast<int>(getpid());
- if (!ClientVersion) {
- ClientVersion = ::TStringBuilder() << "YT C++ native " << GetProgramCommitId();
- }
-}
-
-static TString CensorString(TString input)
-{
- static const TString prefix = "AQAD-";
- if (input.find(prefix) == TString::npos) {
- return input;
- } else {
- return TString(input.size(), '*');
- }
-}
-
-void TProcessState::SetCommandLine(int argc, const char* argv[])
-{
- for (int i = 0; i < argc; ++i) {
- CommandLine.push_back(argv[i]);
- CensoredCommandLine.push_back(CensorString(CommandLine.back()));
- }
+ ClientVersion = ::TStringBuilder() << "YT C++ native " << GetProgramCommitId();
+ BinaryPath = GetExecPath();
+ BinaryName = GetBaseName(BinaryPath);
}
TProcessState* TProcessState::Get()
diff --git a/yt/cpp/mapreduce/interface/config.h b/yt/cpp/mapreduce/interface/config.h
index 71f0c4fcdc..05c4c473e5 100644
--- a/yt/cpp/mapreduce/interface/config.h
+++ b/yt/cpp/mapreduce/interface/config.h
@@ -2,10 +2,11 @@
#include "fwd.h"
#include "common.h"
-#include "node.h"
#include <library/cpp/yt/misc/enum.h>
+#include <library/cpp/yson/node/node.h>
+
#include <util/generic/maybe.h>
#include <util/generic/string.h>
#include <util/generic/hash_set.h>
@@ -236,17 +237,14 @@ struct TProcessState
{
TString FqdnHostName;
TString UserName;
- TVector<TString> CommandLine;
- // Command line with everything that looks like tokens censored.
- TVector<TString> CensoredCommandLine;
int Pid;
TString ClientVersion;
+ TString BinaryPath;
+ TString BinaryName;
TProcessState();
- void SetCommandLine(int argc, const char* argv[]);
-
static TProcessState* Get();
};
diff --git a/yt/cpp/mapreduce/raw_client/rpc_parameters_serialization.cpp b/yt/cpp/mapreduce/raw_client/rpc_parameters_serialization.cpp
index 3a78ed3319..cd36cea25a 100644
--- a/yt/cpp/mapreduce/raw_client/rpc_parameters_serialization.cpp
+++ b/yt/cpp/mapreduce/raw_client/rpc_parameters_serialization.cpp
@@ -84,11 +84,7 @@ static TString GetDefaultTransactionTitle()
res << "User transaction. Created by: " << processState->UserName << " on " << processState->FqdnHostName
<< " client: " << processState->ClientVersion << " pid: " << processState->Pid;
- if (!processState->CommandLine.empty()) {
- res << " program: " << processState->CommandLine[0];
- } else {
- res << " command line is unknown probably NYT::Initialize was never called";
- }
+ res << " program: " << processState->BinaryName;
#ifndef NDEBUG
res << " build: debug";