Skip to content

Commit 83f6d8a

Browse files
authored
Better error output when no auth (#27733)
1 parent ab80f0c commit 83f6d8a

File tree

1 file changed

+29
-9
lines changed

1 file changed

+29
-9
lines changed

ydb/library/workload/tpcc/util.cpp

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,26 @@
1515

1616
namespace NYdb::NTPCC {
1717

18+
namespace {
19+
20+
//-----------------------------------------------------------------------------
21+
22+
void PrintErrorStatus(const TStatus& status, const TString& what) {
23+
TStringStream ss;
24+
ss << what << ": " << ToString(status.GetStatus());
25+
const auto& issues = status.GetIssues();
26+
if (issues) {
27+
ss << ", issues: ";
28+
issues.PrintTo(ss, true);
29+
}
30+
31+
Cerr << ss.Str() << Endl;
32+
}
33+
34+
} // anonymous
35+
36+
//-----------------------------------------------------------------------------
37+
1838
std::string GetFormattedSize(size_t size) {
1939
constexpr size_t TiB = 1024ULL * 1024 * 1024 * 1024;
2040
constexpr size_t GiB = 1024ULL * 1024 * 1024;
@@ -43,15 +63,7 @@ void ExitIfError(const TStatus& status, const TString& what) {
4363
return;
4464
}
4565

46-
TStringStream ss;
47-
ss << what << ": " << ToString(status.GetStatus());
48-
const auto& issues = status.GetIssues();
49-
if (issues) {
50-
ss << ", issues: ";
51-
issues.PrintTo(ss, true);
52-
}
53-
54-
Cerr << ss.Str() << Endl;
66+
PrintErrorStatus(status, what);
5567
std::exit(1);
5668
}
5769

@@ -115,6 +127,14 @@ size_t NumberOfComputeCpus(TDriver& driver) {
115127
}).GetValueSync();
116128

117129
if (!result.IsSuccess()) {
130+
TString what = "failed to get number of compute cores";
131+
if (result.GetStatus() == EStatus::UNAUTHORIZED) {
132+
// in this case no reason to continue
133+
ExitIfError(result, what);
134+
} else {
135+
// print error and try to continue workload execution
136+
PrintErrorStatus(result, what);
137+
}
118138
return 0;
119139
}
120140

0 commit comments

Comments
 (0)