From 7d4b3dc05325fef68bb47cebe6287627197efc38 Mon Sep 17 00:00:00 2001 From: shahoian Date: Wed, 29 Jan 2025 01:06:52 +0100 Subject: [PATCH] Move XRD debug settings to copy shell command To avoid interference of ALIENPY_DEBUG and XRD_LOGLEVEL set for CTF copy failures debugging with CCDB fetches from alien, which pollute stdout. --- Common/Utils/src/FileFetcher.cxx | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/Common/Utils/src/FileFetcher.cxx b/Common/Utils/src/FileFetcher.cxx index 048402712ccd7..32c51ac704d4b 100644 --- a/Common/Utils/src/FileFetcher.cxx +++ b/Common/Utils/src/FileFetcher.cxx @@ -329,6 +329,7 @@ bool FileFetcher::copyFile(size_t id) bool aliencpMode = false; std::string uuid{}; std::vector 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"; @@ -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) {