Skip to content
Snippets Groups Projects
Commit 0a1d8c15 authored by Cedric CAFFY's avatar Cedric CAFFY
Browse files

Removed objectstore initialization agent after objectstore initialization...

Removed objectstore initialization agent after objectstore initialization (cta-objectstore-initialize.cpp)
Catched other exceptions in continuousintegration/orchestration/tests/client-ar-abortPrepare.cpp
parent adaa1051
No related branches found
No related tags found
No related merge requests found
......@@ -75,111 +75,128 @@ int main(int argc, char **argv) {
std::string file;
std::string error_dir;
} options;
int opt_ret;
while (-1 != (opt_ret = getopt_long(argc, argv, short_options, long_options, nullptr))) {
switch (opt_ret) {
case (int)OptionIds::eos_instance:
options.eos_instance = optarg;
break;
case (int)OptionIds::eos_poweruser:
options.eos_poweruser = optarg;
break;
case (int)OptionIds::eos_dir:
options.eos_dir = optarg;
break;
case (int)OptionIds::subdir:
options.subdir = optarg;
break;
case (int)OptionIds::file:
options.file = optarg;
break;
case (int)OptionIds::error_dir:
options.error_dir = optarg;
break;
case '?':
default:
std::cerr << "Unexpected option or missing argument." << std::endl;
exit(EXIT_FAILURE);
break;
}
}
if (options.eos_instance.empty() || options.eos_poweruser.empty() || options.error_dir.empty() || options.subdir.empty() ||
options.file.empty() || options.error_dir.empty()) {
std::cerr << "At least one option missing." << std::endl;
help();
exit (EXIT_FAILURE);
}
// std::cout << "To run again: " << argv[0]
// << " --eos-instance=" << options.eos_instance
// << " --eos-poweruser=" << options.eos_poweruser
// << " --eos-dir=" << options.eos_dir
// << " --subdir=" << options.subdir
// << " --file=" << options.file
// << " --error_dir=" << options.error_dir << std::endl;
// Get the extended attribute for the retrieve request id
std::string retrieveRequestId, fileName(options.eos_dir + "/" + options.subdir + "/" + options.file);
XrdCl::FileSystem xrdfs(options.eos_instance);
std::string errFileName;
try {
// Prepare Xrootd environment.
errFileName = options.error_dir + '/' + "XATTRGET2_" + options.subdir + '_' + options.file;
XrdCl::DefaultEnv::SetLogLevel("Dump");
XrdCl::DefaultEnv::SetLogFile(errFileName);
std::string envKRB5CCNAMEvalue = std::string("KRB5CCNAME=/tmp/") + options.eos_poweruser + "/krb5cc_0";
// We need to copy to an array because of putenv's lack of const correctness.
envKRB5CCNAME.reset(new char[envKRB5CCNAMEvalue.size() + 1]);
strncpy(envKRB5CCNAME.get(), envKRB5CCNAMEvalue.c_str(), envKRB5CCNAMEvalue.size() + 1);
putenv(envKRB5CCNAME.get());
putenv(envXrdSecPROTOCOL);
std::string query = fileName + "?mgm.pcmd=xattr&mgm.subcmd=get&mgm.xattrname=sys.retrieve.req_id";
auto qcOpaque = XrdCl::QueryCode::OpaqueFile;
XrdCl::Buffer xrdArg;
xrdArg.FromString(query);
XrdCl::Buffer *respPtr = nullptr;
auto status = xrdfs.Query(qcOpaque, xrdArg, respPtr, (uint16_t)0 /*timeout=default*/);
// Ensure proper memory management for the response buffer (it is our responsilibity to free it, we delegate to the unique_ptr).
std::unique_ptr<XrdCl::Buffer> respUP(respPtr);
respPtr = nullptr;
cta::exception::XrootCl::throwOnError(status, "Error during XrdCl::Query");
cta::utils::Regex re("value=(.*)");
std::string respStr(respUP->GetBuffer(), respUP->GetSize());
auto reResult = re.exec(respStr);
if (reResult.size() != 2) {
// We did not receive the expected structure
throw cta::exception::Exception(std::string("Unexpected result from xattr query: ") + respStr);
int opt_ret;
while (-1 != (opt_ret = getopt_long(argc, argv, short_options, long_options, nullptr))) {
switch (opt_ret) {
case (int)OptionIds::eos_instance:
options.eos_instance = optarg;
break;
case (int)OptionIds::eos_poweruser:
options.eos_poweruser = optarg;
break;
case (int)OptionIds::eos_dir:
options.eos_dir = optarg;
break;
case (int)OptionIds::subdir:
options.subdir = optarg;
break;
case (int)OptionIds::file:
options.file = optarg;
break;
case (int)OptionIds::error_dir:
options.error_dir = optarg;
break;
case '?':
default:
std::cerr << "Unexpected option or missing argument." << std::endl;
exit(EXIT_FAILURE);
break;
}
}
if (options.eos_instance.empty() || options.eos_poweruser.empty() || options.error_dir.empty() || options.subdir.empty() ||
options.file.empty() || options.error_dir.empty()) {
std::cerr << "At least one option missing." << std::endl;
help();
exit (EXIT_FAILURE);
}
// std::cout << "To run again: " << argv[0]
// << " --eos-instance=" << options.eos_instance
// << " --eos-poweruser=" << options.eos_poweruser
// << " --eos-dir=" << options.eos_dir
// << " --subdir=" << options.subdir
// << " --file=" << options.file
// << " --error_dir=" << options.error_dir << std::endl;
// Get the extended attribute for the retrieve request id
std::string retrieveRequestId, fileName(options.eos_dir + "/" + options.subdir + "/" + options.file);
XrdCl::FileSystem xrdfs(options.eos_instance);
std::string errFileName;
try {
// Prepare Xrootd environment.
errFileName = options.error_dir + '/' + "XATTRGET2_" + options.subdir + '_' + options.file;
XrdCl::DefaultEnv::SetLogLevel("Dump");
XrdCl::DefaultEnv::SetLogFile(errFileName);
std::string envKRB5CCNAMEvalue = std::string("KRB5CCNAME=/tmp/") + options.eos_poweruser + "/krb5cc_0";
// We need to copy to an array because of putenv's lack of const correctness.
envKRB5CCNAME.reset(new char[envKRB5CCNAMEvalue.size() + 1]);
strncpy(envKRB5CCNAME.get(), envKRB5CCNAMEvalue.c_str(), envKRB5CCNAMEvalue.size() + 1);
putenv(envKRB5CCNAME.get());
putenv(envXrdSecPROTOCOL);
std::string query = fileName + "?mgm.pcmd=xattr&mgm.subcmd=get&mgm.xattrname=sys.retrieve.req_id";
auto qcOpaque = XrdCl::QueryCode::OpaqueFile;
XrdCl::Buffer xrdArg;
xrdArg.FromString(query);
XrdCl::Buffer *respPtr = nullptr;
auto status = xrdfs.Query(qcOpaque, xrdArg, respPtr, (uint16_t)0 /*timeout=default*/);
// Ensure proper memory management for the response buffer (it is our responsilibity to free it, we delegate to the unique_ptr).
std::unique_ptr<XrdCl::Buffer> respUP(respPtr);
respPtr = nullptr;
cta::exception::XrootCl::throwOnError(status, "Error during XrdCl::Query");
cta::utils::Regex re("value=(.*)");
std::string respStr(respUP->GetBuffer(), respUP->GetSize());
auto reResult = re.exec(respStr);
if (reResult.size() != 2) {
// We did not receive the expected structure
throw cta::exception::Exception(std::string("Unexpected result from xattr query: ") + respStr);
}
retrieveRequestId = reResult[1];
unlink(errFileName.c_str());
} catch (cta::exception::Exception & ex) {
std::cerr << "ERROR: failed to get request Id for file " << fileName << " full logs in " << errFileName << std::endl;
std::ofstream errFile(errFileName, std::ios::out | std::ios::app);
errFile << ex.what();
return 1;
} catch (std::exception & ex) {
std::cerr << "ERROR: a standard exception occurred" << " full logs in " << errFileName << std::endl;
std::ofstream errFile(errFileName, std::ios::out | std::ios::app);
errFile << ex.what();
return 1;
}
try {
// Prepare Xrootd environment.
errFileName = options.error_dir + '/' + "PREPAREABORT_" + options.subdir + '_' + options.file;
XrdCl::DefaultEnv::SetLogLevel("Dump");
XrdCl::DefaultEnv::SetLogFile(errFileName);
std::vector<std::string> files = { retrieveRequestId, fileName };
XrdCl::PrepareFlags::Flags flags = XrdCl::PrepareFlags::Cancel;
XrdCl::Buffer *respPtr = nullptr;
auto abortStatus = xrdfs.Prepare(files, flags, 0, respPtr, 0 /* timeout */);
// Ensure proper memory management for the response buffer (it is our responsilibity to free it, we delegate to the unique_ptr).
std::unique_ptr<XrdCl::Buffer> respUP(respPtr);
respPtr = nullptr;
cta::exception::XrootCl::throwOnError(abortStatus, "Error during XrdCl::Prepare");
unlink(errFileName.c_str());
} catch (cta::exception::Exception & ex) {
std::cerr << "ERROR: failed to get request Id for file " << fileName << " full logs in " << errFileName << std::endl;
std::ofstream errFile(errFileName, std::ios::out | std::ios::app);
errFile << ex.what();
return 1;
} catch (std::exception & ex) {
std::cerr << "ERROR: a standard exception occurred" << " full logs in " << errFileName << std::endl;
std::ofstream errFile(errFileName, std::ios::out | std::ios::app);
errFile << ex.what();
return 1;
}
retrieveRequestId = reResult[1];
unlink(errFileName.c_str());
} catch (cta::exception::Exception & ex) {
std::cerr << "ERROR: failed to get request Id for file " << fileName << " full logs in " << errFileName << std::endl;
std::ofstream errFile(errFileName, std::ios::out | std::ios::app);
errFile << ex.what();
return 0;
} catch (std::exception &ex) {
std::cerr << "ERROR: a standard exception occurred " << ex.what() << std::endl;
return 1;
}
try {
// Prepare Xrootd environment.
errFileName = options.error_dir + '/' + "PREPAREABORT_" + options.subdir + '_' + options.file;
XrdCl::DefaultEnv::SetLogLevel("Dump");
XrdCl::DefaultEnv::SetLogFile(errFileName);
std::vector<std::string> files = { retrieveRequestId, fileName };
XrdCl::PrepareFlags::Flags flags = XrdCl::PrepareFlags::Cancel;
XrdCl::Buffer *respPtr = nullptr;
auto abortStatus = xrdfs.Prepare(files, flags, 0, respPtr, 0 /* timeout */);
// Ensure proper memory management for the response buffer (it is our responsilibity to free it, we delegate to the unique_ptr).
std::unique_ptr<XrdCl::Buffer> respUP(respPtr);
respPtr = nullptr;
cta::exception::XrootCl::throwOnError(abortStatus, "Error during XrdCl::Prepare");
unlink(errFileName.c_str());
} catch (cta::exception::Exception & ex) {
std::cerr << "ERROR: failed to get request Id for file " << fileName << " full logs in " << errFileName << std::endl;
std::ofstream errFile(errFileName, std::ios::out | std::ios::app);
errFile << ex.what();
} catch (...) {
std::cerr << "ERROR: an unknown general exception occurred " << std::endl;
return 1;
}
return 0;
}
......@@ -66,6 +66,7 @@ int main(int argc, char ** argv) {
re.fetch();
re.addOrGetDriveRegisterPointerAndCommit(agr, el);
re.addOrGetSchedulerGlobalLockAndCommit(agr,el);
ag.removeAndUnregisterSelf(lc);
rel.release();
std::cout << "New object store path: " << be->getParams()->toURL() << std::endl;
} catch (std::exception & e) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment