Commit b055e6f6 authored by Jozsef Makai's avatar Jozsef Makai

MGM: sync::closew FST URL creaton was before create :(

parent 367f3021
......@@ -131,11 +131,9 @@ Workflow::getCGICloseW(std::string workflow, const eos::common::Mapping::Virtual
return "";
}
auto attributes = WFE::CollectAttributes(fullPath);
std::ostringstream attrStream;
std::string separator;
for (const auto& attribute : attributes) {
for (const auto& attribute : WFE::CollectAttributes(fullPath)) {
attrStream << separator << attribute.first << "=" << attribute.second;
separator = ";;;";
}
......
......@@ -2324,7 +2324,49 @@ XrdMgmOfsFile::open(const char* inpath,
redirectionhost += "&mgm.mtime=0";
}
// add workflow cgis
// Also trigger synchronous create workflow event if it's defined
if(isCreation) {
errno = 0;
workflow.SetFile(path, fileId);
auto workflowType = openOpaque->Get("eos.workflow") != nullptr ? openOpaque->Get("eos.workflow") : "default";
auto ret_wfe = workflow.Trigger("sync::create", std::string{workflowType}, vid);
if (ret_wfe < 0 && errno == ENOKEY) {
eos_info("msg=\"no workflow defined for sync::create\"");
} else {
eos_info("msg=\"workflow trigger returned\" retc=%d errno=%d", ret_wfe, errno);
if (ret_wfe != 0) {
// Remove the file from the namespace in this case
try {
eos::common::RWMutexWriteLock lock(gOFS->eosViewRWMutex);
gOFS->eosView->removeFile(fmd.get());
} catch (eos::MDException& ex) {
eos_err("Failed to remove file from namespace in case of create workflow error. Reason: %s",
ex.what());
}
return Emsg(epname, error, ret_wfe, "open - synchronous create workflow error", path);
}
}
}
// Also trigger synchronous open-write workflow event if it's defined
if(isRW) {
errno = 0;
workflow.SetFile(path, fileId);
auto workflowType = openOpaque->Get("eos.workflow") != nullptr ? openOpaque->Get("eos.workflow") : "default";
auto ret_wfe = workflow.Trigger("sync::openw", std::string{workflowType}, vid);
if (ret_wfe < 0 && errno == ENOKEY) {
eos_info("msg=\"no workflow defined for sync::openw\"");
} else {
eos_info("msg=\"workflow trigger returned\" retc=%d errno=%d", ret_wfe, errno);
if (ret_wfe != 0) {
// Error from the workflow
rcode = Emsg(epname, error, ret_wfe, "open - synchronous openw workflow error", path);
}
}
}
// add workflow cgis, has to come after create workflow
workflow.SetFile(path, fileId);
if (isRW) {
redirectionhost += workflow.getCGICloseW(currentWorkflow.c_str(), vid).c_str();
......@@ -2406,56 +2448,6 @@ XrdMgmOfsFile::open(const char* inpath,
}
}
// Also trigger synchronous create workflow event if it's defined
if (isCreation) {
errno = 0;
workflow.SetFile(path, fileId);
auto workflowType = openOpaque->Get("eos.workflow") != nullptr ?
openOpaque->Get("eos.workflow") : "default";
auto ret_wfe = workflow.Trigger("sync::create", std::string{workflowType}, vid);
if (ret_wfe < 0 && errno == ENOKEY) {
eos_info("msg=\"no workflow defined for sync::create\"");
} else {
eos_info("msg=\"workflow trigger returned\" retc=%d errno=%d", ret_wfe, errno);
if (ret_wfe != 0) {
// Remove the file from the namespace in this case
try {
eos::common::RWMutexWriteLock lock(gOFS->eosViewRWMutex);
gOFS->eosView->removeFile(fmd.get());
} catch (eos::MDException& ex) {
eos_err("Failed to remove file from namespace in case of create workflow error. Reason: %s",
ex.what());
}
return Emsg(epname, error, ret_wfe, "open - synchronous create workflow error",
path);
}
}
}
// Also trigger synchronous open-write workflow event if it's defined
if (isRW) {
errno = 0;
workflow.SetFile(path, fileId);
auto workflowType = openOpaque->Get("eos.workflow") != nullptr ?
openOpaque->Get("eos.workflow") : "default";
auto ret_wfe = workflow.Trigger("sync::openw", std::string{workflowType}, vid);
if (ret_wfe < 0 && errno == ENOKEY) {
eos_info("msg=\"no workflow defined for sync::openw\"");
} else {
eos_info("msg=\"workflow trigger returned\" retc=%d errno=%d", ret_wfe, errno);
if (ret_wfe != 0) {
// Error from the workflow
rcode = Emsg(epname, error, ret_wfe, "open - synchronous openw workflow error",
path);
}
}
}
EXEC_TIMING_END("Open");
return rcode;
}
......
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