Commit 5ba462b1 authored by Jozsef Makai's avatar Jozsef Makai

MGM,FST: finished FST to CTA closew [ci skip]

parent 0e9843d9
......@@ -363,6 +363,7 @@ target_compile_definitions(XrdEosFst-Shared PUBLIC
-DDAEMONUID=${DAEMONUID} -DDAEMONGID=${DAEMONGID})
target_link_libraries(XrdEosFst PRIVATE
eosCommon
eosCommonServer
EosFstIo-Static
eosCapability-Static
......@@ -381,6 +382,7 @@ target_link_libraries(XrdEosFst PRIVATE
${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(XrdEosFst-Shared PUBLIC
eosCommon
eosCommonServer
EosFstIo-Static
eosCapability-Static
......
......@@ -343,6 +343,8 @@ XrdFstOfs::Configure(XrdSysError& Eroute, XrdOucEnv* envP)
int cfgFD;
int NoGo = 0;
eos::common::StringConversion::InitLookupTables();
if (XrdOfs::Configure(Eroute, envP)) {
Eroute.Emsg("Config", "default OFS configuration failed");
return SFS_ERROR;
......@@ -1570,12 +1572,15 @@ XrdFstOfs::WaitForOngoingIO(std::chrono::seconds timeout)
int
XrdFstOfs::CallSynchronousClosew(const Fmd& fmd, const string& ownerName,
const string& ownerGroupName, const string& instanceName,
const string& ownerGroupName, const string& requestorName,
const string& requestorGroupName, const string& instanceName,
const string& fullPath, const std::map<std::string, std::string>& xattrs) {
using namespace eos::common;
cta::xrd::Request request;
auto notification = request.mutable_notification();
notification->mutable_cli()->mutable_user()->set_username(requestorName);
notification->mutable_cli()->mutable_user()->set_groupname(requestorGroupName);
notification->mutable_file()->mutable_owner()->set_username(ownerName);
notification->mutable_file()->mutable_owner()->set_groupname(ownerGroupName);
......@@ -1641,7 +1646,7 @@ XrdFstOfs::CallSynchronousClosew(const Fmd& fmd, const string& ownerName,
if(getenv("XRDDEBUG")) {
config.set("log", "all");
} else {
config.set("log", "all");
config.set("log", "info");
}
config.set("request_timeout", "120");
// Instantiate service object only once, static is also thread-safe
......
......@@ -307,7 +307,8 @@ public:
bool retry = true);
int CallSynchronousClosew(const Fmd& fmd, const string& ownerName,
const string& ownerGroupName, const string& instanceName,
const string& ownerGroupName, const string& requestorName,
const string& requestorGroupName, const string& instanceName,
const string& fullPath, const std::map<std::string, std::string>& xattrs);
//----------------------------------------------------------------------------
......
......@@ -1922,7 +1922,8 @@ XrdFstOfsFile::close()
std::map<std::string, std::string> attributes;
eos::common::StringConversion::GetKeyValueMap(decodedAttributes.c_str(), attributes, "=", ";;;", nullptr);
rc = gOFS.CallSynchronousClosew(fMd->mProtoFmd, eventOwner, eventOwnerGroup, eventInstance, capOpaque->Get("mgm.path"), attributes);
rc = gOFS.CallSynchronousClosew(fMd->mProtoFmd, eventOwner, eventOwnerGroup, eventRequestor, eventRequestorGroup,
eventInstance, capOpaque->Get("mgm.path"), attributes);
if (rc == SFS_OK) {
return rc;
......@@ -2915,6 +2916,12 @@ XrdFstOfsFile::ProcessOpenOpaque(const std::string& in_opaque,
val = env.Get("mgm.ownergroup");
eventOwnerGroup = val ? val : "";
val = env.Get("mgm.requestor");
eventRequestor = val ? val : "";
val = env.Get("mgm.requestorgroup");
eventRequestorGroup = val ? val : "";
val = env.Get("mgm.attributes");
eventAttributes = val ? val : "";
}
......
......@@ -402,6 +402,8 @@ protected:
std::string eventInstance;
std::string eventOwner;
std::string eventOwnerGroup;
std::string eventRequestor;
std::string eventRequestorGroup;
std::string eventAttributes;
enum {
......
......@@ -1806,7 +1806,7 @@ WFE::Job::DoIt(bool issync)
}
std::string errorMsg;
int sendResult = SendProtoWFRequest(this, fullPath, request, errorMsg);
auto sendResult = SendProtoWFRequest(this, fullPath, request, errorMsg);
if (sendResult != 0) {
// Create human readable timestamp with the error message
auto time = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
......@@ -1990,7 +1990,23 @@ WFE::Job::DoIt(bool issync)
notification->mutable_transport()->set_error_report_url(errorReportStream.str());
std::string errorMsg;
return SendProtoWFRequest(this, fullPath, request, errorMsg, !IsSync(event));
auto sendResult = SendProtoWFRequest(this, fullPath, request, errorMsg, !IsSync(event));
if (sendResult != 0) {
// Create human readable timestamp with the error message
auto time = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
std::string ctime = std::ctime(&time);
std::string errorMsgAttr = ctime.substr(0, ctime.length() - 1) + " -> " +
(errorMsg.empty() ? "Closew handshake failed" : errorMsg);
eos::common::RWMutexWriteLock lock(gOFS->eosViewRWMutex);
try {
fmd->setAttribute(ARCHIVE_ERROR_ATTR_NAME, errorMsgAttr);
gOFS->eosView->updateFileStore(fmd.get());
} catch (eos::MDException& ex) {}
}
return sendResult;
}
} else if (event == "sync::archived" || event == "archived") {
bool onlyTapeCopy = false;
......
......@@ -111,7 +111,7 @@ Workflow::Trigger(const std::string& event, std::string workflow,
/*----------------------------------------------------------------------------*/
std::string
Workflow::getCGICloseW(std::string workflow)
Workflow::getCGICloseW(std::string workflow, const eos::common::Mapping::VirtualIdentity& vid)
{
std::string cgi;
std::string key = "sys.workflow.closew." + workflow;
......@@ -127,6 +127,7 @@ Workflow::getCGICloseW(std::string workflow)
owner = WFE::GetUserName(fmd->getCUid());
ownerGroup = WFE::GetGroupName(fmd->getCGid());
} catch (eos::MDException& e) {
eos_static_err("Not creating workflow URL because cannot get meta data. Reason: %s", e.what());
return "";
}
......@@ -151,6 +152,10 @@ Workflow::getCGICloseW(std::string workflow)
cgi += owner;
cgi += "&mgm.ownergroup=";
cgi += ownerGroup;
cgi += "&mgm.requestor=";
cgi += WFE::GetUserName(vid.uid);
cgi += "&mgm.requestorgroup=";
cgi += WFE::GetGroupName(vid.gid);
cgi += "&mgm.attributes=";
cgi += attrEncoded;
} else if (mAttr && (*mAttr).count(key)) {
......
......@@ -62,7 +62,7 @@ public:
int Trigger(const std::string& event, std::string workflow,
eos::common::Mapping::VirtualIdentity& vid, const std::string& errorMessage = "");
std::string getCGICloseW(std::string workflow);
std::string getCGICloseW(std::string workflow, const eos::common::Mapping::VirtualIdentity& vid);
std::string getCGICloseR(std::string workflow);
......
......@@ -2327,7 +2327,7 @@ XrdMgmOfsFile::open(const char* inpath,
// add workflow cgis
workflow.SetFile(path, fileId);
if (isRW) {
redirectionhost += workflow.getCGICloseW(currentWorkflow.c_str()).c_str();
redirectionhost += workflow.getCGICloseW(currentWorkflow.c_str(), vid).c_str();
} else {
redirectionhost += workflow.getCGICloseR(currentWorkflow.c_str()).c_str();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment