Skip to content

Commit

Permalink
Move XRD debug settings to copy shell command
Browse files Browse the repository at this point in the history
To avoid interference of ALIENPY_DEBUG and XRD_LOGLEVEL set for CTF copy failures debugging
with CCDB fetches from alien, which pollute stdout.
  • Loading branch information
shahor02 committed Jan 29, 2025
1 parent 933c8d0 commit 7d4b3dc
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions Common/Utils/src/FileFetcher.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ bool FileFetcher::copyFile(size_t id)
bool aliencpMode = false;
std::string uuid{};
std::vector<std::string> logsToClean;
std::string dbgset{};
if (mCopyCmd.find("alien") != std::string::npos) {
if (!gGrid && !TGrid::Connect("alien://")) {
LOG(error) << "Copy command refers to alien but connection to Grid failed";
Expand All @@ -339,18 +340,18 @@ bool FileFetcher::copyFile(size_t id)
c = '_';
}
}
gSystem->Setenv("ALIENPY_DEBUG", "1");
logsToClean.push_back(fmt::format("log_alienpy_{}.txt", uuid));
gSystem->Setenv("ALIENPY_DEBUG_FILE", logsToClean.back().c_str());
gSystem->Setenv("XRD_LOGLEVEL", "Dump");
logsToClean.push_back(fmt::format("log_xrd_{}.txt", uuid));
gSystem->Setenv("XRD_LOGFILE", logsToClean.back().c_str());
LOGP(info, "debug log files for {}: ALIENPY_DEBUG_FILE={} XRD_LOGFILE={}", mInputFiles[id].getOrigName(),
getenv("ALIENPY_DEBUG_FILE") ? getenv("ALIENPY_DEBUG_FILE") : "",
getenv("XRD_LOGFILE") ? getenv("XRD_LOGFILE") : "");
if (!(getenv("ALIENPY_DEBUG") && std::stoi(getenv("ALIENPY_DEBUG")) == 1)) {
logsToClean.push_back(fmt::format("log_alienpy_{}.txt", uuid));
dbgset += fmt::format("ALIENPY_DEBUG=1 ALIENPY_DEBUG_FILE={} ", logsToClean.back());
}
if (!(getenv("XRD_LOGLEVEL") && strcmp(getenv("XRD_LOGLEVEL"), "Dump") == 0)) {
logsToClean.push_back(fmt::format("log_xrd_{}.txt", uuid));
dbgset += fmt::format("XRD_LOGLEVEL=Dump XRD_LOGFILE={} ", logsToClean.back());
}
LOGP(debug, "debug setting for for {}: {}", mInputFiles[id].getOrigName(), dbgset);
}
auto realCmd = std::regex_replace(std::regex_replace(mCopyCmd, std::regex(R"(\?src)"), mInputFiles[id].getOrigName()), std::regex(R"(\?dst)"), mInputFiles[id].getLocalName());
auto fullCmd = fmt::format(R"(sh -c "{}" >> {} 2>&1)", realCmd, mCopyCmdLogFile);
auto fullCmd = fmt::format(R"(sh -c "{}{}" >> {} 2>&1)", dbgset, realCmd, mCopyCmdLogFile);
LOG(info) << "Executing " << fullCmd;
const auto sysRet = gSystem->Exec(fullCmd.c_str());
if (sysRet != 0) {
Expand Down

0 comments on commit 7d4b3dc

Please sign in to comment.