Commit 2f97f2af authored by Eric Cano's avatar Eric Cano
Browse files

CASTOR-4751: tapeserverd does not report drive as empty and does not finish...

CASTOR-4751: tapeserverd does not report drive as empty and does not finish client session if user does not have migration access-rights

The error situation was already generating an exception, which went all the way to the caller
of the data transfer session. It is now intercepted and the client is notified synchronously.
The session now ends successfully (the drive was not touched).
parent 7d2e0695
......@@ -310,8 +310,24 @@ castor::tape::tapeserver::daemon::Session::EndOfSessionAction
twst.setlastFseq(firstFseqFromClient-1);
//we retrieved the detail from the client in execute, so at this point
//we can report. We get in exchange the number of files on the tape
const uint64_t nbOfFileOnTape = tsr.gotWriteMountDetailsFromClient();
//we can report. We get in exchange the number of files on the tape.
// This function can throw an exception (usually for permission reasons)
// This is not a reason to put the drive down. The error is already logged
// upstream.
// Letting the exception slip through would leave the drive down.
// Initialise with something obviously wrong.
uint64_t nbOfFileOnTape = std::numeric_limits<uint64_t>::max();
try {
nbOfFileOnTape = tsr.gotWriteMountDetailsFromClient();
} catch (castor::exception::Exception & e) {
lc.log(LOG_INFO, "Aborting the session after problem with mount details. Notifying the client.");
mrp.synchronousReportEndWithErrors(e.getMessageValue(), SEINTERNAL);
return MARK_DRIVE_AS_UP;
} catch (...) {
lc.log(LOG_INFO, "Aborting the session after problem with mount details (unknown exception). Notifying the client.");
mrp.synchronousReportEndWithErrors("Unknown exception while checking session parameters with VMGR", SEINTERNAL);
return MARK_DRIVE_AS_UP;
}
//theses 2 numbers should match. Otherwise, it means the stager went mad
if(firstFseqFromClient != nbOfFileOnTape + 1) {
......
......@@ -95,6 +95,15 @@ void MigrationReportPacker::reportEndOfSessionWithErrors(std::string msg,int err
castor::server::MutexLocker ml(&m_producterProtection);
m_fifo.push(new ReportEndofSessionWithErrors(msg,errorCode));
}
//------------------------------------------------------------------------------
//synchronousReportEndWithErrors
//------------------------------------------------------------------------------
void MigrationReportPacker::synchronousReportEndWithErrors(const std::string msg, int errorCode){
// We create the report task here and excute it immediately instead of posting
// it to a queue.
ReportEndofSessionWithErrors rep(msg,errorCode);
rep.execute(*this);
}
//------------------------------------------------------------------------------
//ReportSuccessful::execute
......
......@@ -86,6 +86,13 @@ public:
*/
void reportEndOfSessionWithErrors(const std::string msg,int error_code);
/**
* Immediately report the end of session to the client.
* @param msg The error message
* @param error_code The error code given by the drive
*/
void synchronousReportEndWithErrors(const std::string msg,int error_code);
void startThreads() { m_workerThread.start(); }
void waitThread() { m_workerThread.wait(); }
......
Supports Markdown
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