Skip to content

Commit 8e841b7

Browse files
author
ermolovd
committed
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
1 parent e8c90ae commit 8e841b7

File tree

5 files changed

+16
-44
lines changed

5 files changed

+16
-44
lines changed

yt/cpp/mapreduce/client/init.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ NLogging::ELogLevel ToCoreLogLevel(ILogger::ELevel level)
166166
Y_ABORT();
167167
}
168168

169-
void CommonInitialize(int argc, const char** argv)
169+
void CommonInitialize(int, const char**)
170170
{
171171
auto logLevelStr = to_lower(TConfig::Get()->LogLevel);
172172
ILogger::ELevel logLevel;
@@ -187,8 +187,6 @@ void CommonInitialize(int argc, const char** argv)
187187
NLogging::TLogManager::Get()->Configure(coreLoggingConfig);
188188
}
189189
SetLogger(logger);
190-
191-
TProcessState::Get()->SetCommandLine(argc, argv);
192190
}
193191

194192
void NonJobInitialize(const TInitializeOptions& options)

yt/cpp/mapreduce/client/operation.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -804,10 +804,8 @@ void BuildCommonOperationPart(
804804
startedBySpec["user"] = properties->UserName;
805805
startedBySpec["wrapper_version"] = properties->ClientVersion;
806806

807-
startedBySpec["command"] = TNode::CreateList();
808-
for (const auto& arg : properties->CensoredCommandLine) {
809-
startedBySpec["command"].Add(arg);
810-
}
807+
startedBySpec["binary"] = properties->BinaryPath;
808+
startedBySpec["binary_name"] = properties->BinaryName;
811809
auto nirvanaBlockUrl = GetNirvanaBlockUrlFromContext();
812810
if (!nirvanaBlockUrl.IsUndefined()) {
813811
startedBySpec["nirvana_block_url"] = nirvanaBlockUrl;

yt/cpp/mapreduce/interface/config.cpp

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#include "config.h"
2-
3-
#include "operation.h"
2+
#include "serialize.h"
43

54
#include <yt/cpp/mapreduce/interface/logging/yt_log.h>
65

@@ -12,17 +11,18 @@
1211

1312
#include <library/cpp/yson/json/yson2json_adapter.h>
1413

15-
#include <util/string/strip.h>
1614
#include <util/folder/dirut.h>
1715
#include <util/folder/path.h>
18-
#include <util/stream/file.h>
1916
#include <util/generic/singleton.h>
17+
#include <util/stream/file.h>
2018
#include <util/string/builder.h>
2119
#include <util/string/cast.h>
20+
#include <util/string/strip.h>
2221
#include <util/string/type.h>
22+
#include <util/system/env.h>
23+
#include <util/system/execpath.h>
2324
#include <util/system/hostname.h>
2425
#include <util/system/user.h>
25-
#include <util/system/env.h>
2626

2727
namespace NYT {
2828

@@ -294,27 +294,9 @@ TProcessState::TProcessState()
294294

295295
Pid = static_cast<int>(getpid());
296296

297-
if (!ClientVersion) {
298-
ClientVersion = ::TStringBuilder() << "YT C++ native " << GetProgramCommitId();
299-
}
300-
}
301-
302-
static TString CensorString(TString input)
303-
{
304-
static const TString prefix = "AQAD-";
305-
if (input.find(prefix) == TString::npos) {
306-
return input;
307-
} else {
308-
return TString(input.size(), '*');
309-
}
310-
}
311-
312-
void TProcessState::SetCommandLine(int argc, const char* argv[])
313-
{
314-
for (int i = 0; i < argc; ++i) {
315-
CommandLine.push_back(argv[i]);
316-
CensoredCommandLine.push_back(CensorString(CommandLine.back()));
317-
}
297+
ClientVersion = ::TStringBuilder() << "YT C++ native " << GetProgramCommitId();
298+
BinaryPath = GetExecPath();
299+
BinaryName = GetBaseName(BinaryPath);
318300
}
319301

320302
TProcessState* TProcessState::Get()

yt/cpp/mapreduce/interface/config.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
#include "fwd.h"
44
#include "common.h"
5-
#include "node.h"
65

76
#include <library/cpp/yt/misc/enum.h>
87

8+
#include <library/cpp/yson/node/node.h>
9+
910
#include <util/generic/maybe.h>
1011
#include <util/generic/string.h>
1112
#include <util/generic/hash_set.h>
@@ -236,17 +237,14 @@ struct TProcessState
236237
{
237238
TString FqdnHostName;
238239
TString UserName;
239-
TVector<TString> CommandLine;
240240

241-
// Command line with everything that looks like tokens censored.
242-
TVector<TString> CensoredCommandLine;
243241
int Pid;
244242
TString ClientVersion;
243+
TString BinaryPath;
244+
TString BinaryName;
245245

246246
TProcessState();
247247

248-
void SetCommandLine(int argc, const char* argv[]);
249-
250248
static TProcessState* Get();
251249
};
252250

yt/cpp/mapreduce/raw_client/rpc_parameters_serialization.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,7 @@ static TString GetDefaultTransactionTitle()
8484

8585
res << "User transaction. Created by: " << processState->UserName << " on " << processState->FqdnHostName
8686
<< " client: " << processState->ClientVersion << " pid: " << processState->Pid;
87-
if (!processState->CommandLine.empty()) {
88-
res << " program: " << processState->CommandLine[0];
89-
} else {
90-
res << " command line is unknown probably NYT::Initialize was never called";
91-
}
87+
res << " program: " << processState->BinaryName;
9288

9389
#ifndef NDEBUG
9490
res << " build: debug";

0 commit comments

Comments
 (0)