Skip to content
Snippets Groups Projects
Commit 5d6f805b authored by Volodymyr Yurchenko's avatar Volodymyr Yurchenko
Browse files

Remove tape session error codes (#94)

parent 668f2036
No related branches found
No related tags found
No related merge requests found
Showing
with 42 additions and 121 deletions
......@@ -8,6 +8,7 @@
- cta/CTA#153 - Allow verification status to be cleared with cta-admin
- cta/CTA#173 - Update release notes and small changes to refactoring of operation tools cmd line parsing - Compatible with operations 0.4-95 or later
- cta/CTA#180 - Allow to submit multiple files for verification
- cta/CTA#94 - Remove tape session error codes
### Continuous Integration
- cta/CTA#118 - Add unit tests for OSM label
- cta/CTA#191 - Block merge until cta_valgrind success
......
......@@ -111,7 +111,7 @@ void DiskReadTask::execute(cta::log::LogContext& lc, cta::disk::DiskFileFactory
.add("BytesNotYetRead", migratingFileSize);
lc.log(cta::log::ERR, "Error while reading a file: memory block not filled up, but the file is not fully read yet");
// Mark the block as failed
mb->markAsFailed(erroMsg,666);
mb->markAsFailed(erroMsg);
// Transmit to the tape write task, which will finish the session
m_nextTask.pushDataBlock(mb);
// Fail the disk side.
......@@ -155,7 +155,7 @@ void DiskReadTask::execute(cta::log::LogContext& lc, cta::disk::DiskFileFactory
mb=m_nextTask.getFreeBlock();
++blockId;
}
mb->markAsFailed(e.getMessageValue(), 666); // TODO - Drop error code
mb->markAsFailed(e.getMessageValue());
m_nextTask.pushDataBlock(mb);
mb = nullptr;
......
......@@ -51,7 +51,7 @@ namespace unitTests{
void reportFailedJob(std::unique_ptr<cta::ArchiveJob> failedArchiveJob,
const cta::exception::Exception& ex, cta::log::LogContext & lc) override {}
void reportEndOfSession(cta::log::LogContext & lc) override {}
void reportEndOfSessionWithErrors(const std::string msg, int error_code, cta::log::LogContext & lc) override {}
void reportEndOfSessionWithErrors(const std::string& msg, bool isTapeFull, cta::log::LogContext & lc) override {}
void disableBulk() override {}
MockMigrationReportPacker(cta::ArchiveMount *rm,cta::log::LogContext lc):
MigrationReportPacker(rm,lc) {}
......
......@@ -225,16 +225,11 @@ void DiskWriteTask::releaseAllBlock(){
};
tape::utils::suppresUnusedVariable(sp);
std::string errorMsg;
//int errCode;
if(mb->isFailed()){
errorMsg=mb->errorMsg();
//disabled temporarily (see comment in MemBlock)
//errCode=mb->errorCode();
}
else{
errorMsg="Mismatch between expected and received fileid or blockid";
//errCode=666;
}
lc.log(cta::log::ERR,errorMsg);
throw cta::exception::Exception(errorMsg);
......
......@@ -85,7 +85,7 @@ namespace unitTests{
cta::threading::MutexLocker ml(m_mutex);
endSessions++;
}
void reportEndOfSessionWithErrors(const std::string& msg, int error_code, cta::log::LogContext& lc) override {
void reportEndOfSessionWithErrors(const std::string& msg, cta::log::LogContext& lc) override {
cta::threading::MutexLocker ml(m_mutex);
endSessionsWithError++;
}
......@@ -143,7 +143,7 @@ namespace unitTests{
mb->m_fileid=0;
mb->m_fileBlock=i;
if(5==i){
mb->markAsFailed("Test error",666);
mb->markAsFailed("Test error");
}
t.pushDataBlock(mb);
}
......
......@@ -187,7 +187,7 @@ void DiskWriteThreadPool::DiskWriteWorkerThread::run() {
"As last exiting DiskWriteWorkerThread, reported a successful end of session");
}
else {
m_parentThreadPool.m_reporter.reportEndOfSessionWithErrors("End of recall session with error(s)", 666, m_lc);
m_parentThreadPool.m_reporter.reportEndOfSessionWithErrors("End of recall session with error(s)", m_lc);
m_parentThreadPool.logWithStat(cta::log::INFO,
"As last exiting DiskWriteWorkerThread, reported an end of session with errors");
}
......
......@@ -80,7 +80,7 @@ namespace unitTests{
cta::threading::MutexLocker ml(m_mutex);
endSessions++;
}
void reportEndOfSessionWithErrors(const std::string& msg, int error_code, cta::log::LogContext& lc) override {
void reportEndOfSessionWithErrors(const std::string& msg, cta::log::LogContext& lc) override {
cta::threading::MutexLocker ml(m_mutex);
endSessionsWithError++;
}
......
......@@ -60,19 +60,14 @@ class MemBlock {
*/
std::string m_errorMsg;
/**
* in case of error, the error message
*/
int m_errorCode;
AlterationContext(const std::string& msg,int errorCode,Failed_t):
m_failed(true),m_cancelled(false),m_verifyonly(false),m_errorMsg(msg),m_errorCode(errorCode){}
AlterationContext(const std::string& msg,Failed_t):
m_failed(true),m_cancelled(false),m_verifyonly(false),m_errorMsg(msg){}
AlterationContext(Cancelled_t):
m_failed(false),m_cancelled(true),m_verifyonly(false),m_errorMsg(""),m_errorCode(0){}
m_failed(false),m_cancelled(true),m_verifyonly(false),m_errorMsg(""){}
AlterationContext(VerifyOnly_t):
m_failed(false),m_cancelled(false),m_verifyonly(true),m_errorMsg(""),m_errorCode(0){}
m_failed(false),m_cancelled(false),m_verifyonly(true),m_errorMsg(""){}
};
std::unique_ptr<AlterationContext> m_context;
......@@ -101,20 +96,6 @@ public:
" no error message to give");
}
/**
* Get the error code from the context,
* Throw an exception if there is no context
* @return
*/
int errorCode() const {
if(m_context.get()) {
return m_context->m_errorCode;
}
throw cta::exception::Exception("Error Context is not set ="
" no error code to give");
}
/**
* Return true if the block has been marked as failed
* @return
......@@ -144,8 +125,8 @@ public:
* m_failed is true, m_fileBlock and m_tapeFileBlock are set at -1
* Other members do not change
*/
void markAsFailed(const std::string msg,int errCode){
m_context.reset(new AlterationContext(msg,errCode,AlterationContext::Failed));
void markAsFailed(const std::string msg){
m_context.reset(new AlterationContext(msg,AlterationContext::Failed));
m_fileBlock = -1;
m_tapeFileBlock = -1;
}
......
......@@ -131,12 +131,12 @@ void MigrationReportPacker::reportEndOfSession(cta::log::LogContext& lc) {
//------------------------------------------------------------------------------
//reportEndOfSessionWithErrors
//------------------------------------------------------------------------------
void MigrationReportPacker::reportEndOfSessionWithErrors(std::string msg, int errorCode, cta::log::LogContext& lc) {
void MigrationReportPacker::reportEndOfSessionWithErrors(const std::string& msg, bool isTapeFull, cta::log::LogContext& lc) {
cta::log::ScopedParamContainer params(lc);
params.add("type", "ReportEndofSessionWithErrors");
lc.log(cta::log::DEBUG, "In MigrationReportPacker::reportEndOfSessionWithErrors(), pushing a report.");
cta::threading::MutexLocker ml(m_producterProtection);
std::unique_ptr<Report> rep(new ReportEndofSessionWithErrors(msg, errorCode));
std::unique_ptr<Report> rep(new ReportEndofSessionWithErrors(msg, isTapeFull));
m_fifo.push(std::move(rep));
}
......@@ -152,39 +152,6 @@ void MigrationReportPacker::reportTestGoingToEnd(cta::log::LogContext& lc) {
m_fifo.push(std::move(rep));
}
//------------------------------------------------------------------------------
//synchronousReportEndWithErrors
//------------------------------------------------------------------------------
void MigrationReportPacker::synchronousReportEndWithErrors(const std::string& msg, int errorCode, cta::log::LogContext& lc) {
cta::log::ScopedParamContainer params(lc);
params.add("type", "ReportEndofSessionWithErrors");
lc.log(cta::log::DEBUG, "In MigrationReportPacker::synchronousReportEndWithErrors(), reporting asynchronously session complete.");
m_continue = false;
m_archiveMount->complete();
if (m_errorHappened) {
cta::log::ScopedParamContainer sp(lc);
sp.add("errorMessage", msg)
.add("errorCode", errorCode);
lc.log(cta::log::INFO, "Reported end of session with error to client after sending file errors");
}
else {
// As a measure of safety we censor any session error which is not ENOSPC into
// Meaningless 666 (used to be SEINTERNAL in CASTOR). ENOSPC is the only one interpreted by the tape gateway.
if (ENOSPC != errorCode) {
errorCode = 666;
}
lc.log(cta::log::INFO, "Reported end of session with error to client");
}
if (m_watchdog) {
m_watchdog->addParameter(cta::log::Param("status",
ENOSPC == errorCode ? "success" : "failure"));
// We have a race condition here between the processing of this message by
// the initial process and the printing of the end-of-session log, triggered
// by the end our process. To delay the latter, we sleep half a second here.
usleep(500 * 1000);
}
}
//------------------------------------------------------------------------------
//ReportSuccessful::execute
//------------------------------------------------------------------------------
......@@ -377,21 +344,14 @@ void MigrationReportPacker::ReportEndofSessionWithErrors::execute(MigrationRepor
if (reportPacker.m_errorHappened) {
cta::log::ScopedParamContainer sp(reportPacker.m_lc);
sp.add("errorMessage", m_message)
.add("errorCode", m_errorCode);
.add("isTapeFull", m_isTapeFull);
reportPacker.m_lc.log(cta::log::INFO, "Reported end of session with error to client after sending file errors");
}
else {
const std::string& msg = "Reported end of session with error to client";
// As a measure of safety we censor any session error which is not ENOSPC into
// SEINTERNAL. ENOSPC is the only one interpreted by the tape gateway.
if (ENOSPC != m_errorCode) {
m_errorCode = 666;
}
reportPacker.m_lc.log(cta::log::INFO, msg);
reportPacker.m_lc.log(cta::log::INFO, "Reported end of session with error to client");
}
if (reportPacker.m_watchdog) {
reportPacker.m_watchdog->addParameter(cta::log::Param("status",
ENOSPC == m_errorCode ? "success" : "failure"));
reportPacker.m_watchdog->addParameter(cta::log::Param("status", m_isTapeFull ? "success" : "failure"));
// We have a race condition here between the processing of this message by
// the initial process and the printing of the end-of-session log, triggered
// by the end our process. To delay the latter, we sleep half a second here.
......
......@@ -107,18 +107,10 @@ public:
/**
* Create into the MigrationReportPacker a report for an erroneous end of session
* @param msg The error message
* @param error_code The error code given by the drive
* @param isTapeFull True if the drive returned ENOSPC code (end of space)
* @param lc log context provided by the calling thread.
*/
virtual void reportEndOfSessionWithErrors(std::string msg, int error_code, cta::log::LogContext& lc);
/**
* Immediately report the end of session to the client.
* @param msg The error message
* @param error_code The error code given by the drive
* @param lc log context provided by the calling thread.
*/
virtual void synchronousReportEndWithErrors(const std::string& msg, int error_code, cta::log::LogContext& lc);
virtual void reportEndOfSessionWithErrors(const std::string& msg, bool isTapeFull, cta::log::LogContext& lc);
void startThreads() { m_workerThread.start(); }
......@@ -220,10 +212,10 @@ private:
class ReportEndofSessionWithErrors : public Report {
std::string m_message;
int m_errorCode;
bool m_isTapeFull;
public:
ReportEndofSessionWithErrors(std::string msg, int errorCode) :
m_message(std::move(msg)), m_errorCode(errorCode) {}
ReportEndofSessionWithErrors(std::string msg, bool isTapeFull) :
m_message(std::move(msg)), m_isTapeFull(isTapeFull) {}
void execute(MigrationReportPacker& reportPacker) override;
};
......
......@@ -106,12 +106,12 @@ void RecallReportPacker::reportDriveStatus(cta::common::dataStructures::DriveSta
//------------------------------------------------------------------------------
//reportEndOfSessionWithErrors
//------------------------------------------------------------------------------
void RecallReportPacker::reportEndOfSessionWithErrors(const std::string& msg, int error_code, cta::log::LogContext& lc) {
void RecallReportPacker::reportEndOfSessionWithErrors(const std::string& msg, cta::log::LogContext& lc) {
cta::log::ScopedParamContainer params(lc);
params.add("type", "ReportEndofSessionWithErrors");
lc.log(cta::log::DEBUG, "In RecallReportPacker::reportEndOfSessionWithErrors(), pushing a report.");
cta::threading::MutexLocker ml(m_producterProtection);
m_fifo.push(new ReportEndofSessionWithErrors(msg, error_code));
m_fifo.push(new ReportEndofSessionWithErrors(msg));
}
//------------------------------------------------------------------------------
......@@ -186,7 +186,6 @@ bool RecallReportPacker::ReportDriveStatus::goingToEnd() {
//------------------------------------------------------------------------------
void RecallReportPacker::ReportEndofSessionWithErrors::execute(RecallReportPacker& parent) {
if (parent.m_errorHappened) {
LogContext::ScopedParam sp(parent.m_lc, Param("errorCode", m_error_code));
parent.m_lc.log(cta::log::ERR, m_message);
}
else {
......
......@@ -72,7 +72,7 @@ public:
* @param error_code The error code given by the drive
* @param lc log context provided by the calling thread.
*/
virtual void reportEndOfSessionWithErrors(const std::string& msg, int error_code, cta::log::LogContext& lc);
virtual void reportEndOfSessionWithErrors(const std::string& msg, cta::log::LogContext& lc);
/**
* Report the drive state and set it in the central drive register. This
......@@ -182,10 +182,9 @@ private:
class ReportEndofSessionWithErrors : public Report {
std::string m_message;
int m_error_code;
public:
ReportEndofSessionWithErrors(std::string msg, int error_code) :
m_message(std::move(msg)), m_error_code(error_code) {}
ReportEndofSessionWithErrors(std::string msg) :
m_message(std::move(msg)) {}
void execute(RecallReportPacker& reportPacker) override;
......
......@@ -65,7 +65,7 @@ namespace unitTests
cta::threading::MutexLocker ml(m_mutex);
endSessions++;
}
void reportEndOfSessionWithErrors(const std::string& msg, int error_code, cta::log::LogContext& lc) override {
void reportEndOfSessionWithErrors(const std::string& msg, cta::log::LogContext& lc) override {
cta::threading::MutexLocker ml(m_mutex);
endSessionsWithError++;
}
......
......@@ -99,8 +99,7 @@ protected:
.add("NSFSEQ", (*it)->fseq())
.add("NSHOST", (*it)->nshost())
.add("NSFILETRANSACTIONID", (*it)->fileTransactionId())
.add("ErrorMessage", (*it)->errorMessage())
.add("ErrorCode", (*it)->errorCode());
.add("ErrorMessage", (*it)->errorMessage());
m_lc.log(cta::log::INFO, msg);
}
}
......
......@@ -439,7 +439,7 @@ void castor::tape::tapeserver::daemon::TapeReadSingleThread::run() {
"Both DiskWriteWorkerThread and TapeReadSingleThread existed, reported a successful end of session");
}
else {
m_reportPacker.reportEndOfSessionWithErrors("End of recall session with error(s)", 666, m_logContext);
m_reportPacker.reportEndOfSessionWithErrors("End of recall session with error(s)", m_logContext);
}
}
} catch (const cta::exception::Exception& e) {
......@@ -482,7 +482,7 @@ void castor::tape::tapeserver::daemon::TapeReadSingleThread::run() {
"Both DiskWriteWorkerThread and TapeReadSingleThread existed, reported a successful end of session");
}
else {
m_reportPacker.reportEndOfSessionWithErrors("End of recall session with error(s)", 666, m_logContext);
m_reportPacker.reportEndOfSessionWithErrors("End of recall session with error(s)", m_logContext);
}
}
}
......
......@@ -216,7 +216,7 @@ public:
// mb might or might not be allocated at this point, but
// reportErrorToDiskTask will deal with the allocation if required.
reportErrorToDiskTask(ex.getMessageValue(),666,mb); // TODO - Remove error code
reportErrorToDiskTask(ex.getMessageValue(), mb);
} //end of catch
watchdog.fileFinished();
}
......@@ -237,7 +237,7 @@ private:
* @param errorMsg The error message we will give to the client
* @param mb The mem block we will use
*/
void reportErrorToDiskTask(const std::string& msg, int code, MemBlock* mb = nullptr) {
void reportErrorToDiskTask(const std::string& msg, MemBlock* mb = nullptr) {
// If we are not provided with a block, allocate it and
// fill it up
if (!mb) {
......@@ -246,7 +246,7 @@ private:
mb->m_fileid = m_retrieveJob->retrieveRequest.archiveFileID;
}
// mark the block failed and push it (plus signal the end)
mb->markAsFailed(msg, code);
mb->markAsFailed(msg);
m_fifo.pushDataBlock(mb);
m_fifo.pushDataBlock(nullptr);
}
......
......@@ -499,15 +499,14 @@ void castor::tape::tapeserver::daemon::TapeWriteSingleThread::run() {
// Prepare the standard error codes for the session
std::string errorMessage(e.getMessageValue());
int logLevel = cta::log::ERR;
int errorCode(666);
bool isTapeFull = false;
// Override if we got en ENOSPC error (end of tape)
try {
const auto& errnum =
dynamic_cast<const cta::exception::Errnum&> (e);
const auto& errnum = dynamic_cast<const cta::exception::Errnum&> (e);
if (ENOSPC == errnum.errorNumber()) {
errorCode = ENOSPC;
isTapeFull = true;
errorMessage = "End of migration due to tape full";
logLevel = cta::log::WARNING;
logLevel = cta::log::INFO;
}
} catch (...) {}
// then log the end of write thread
......@@ -516,7 +515,7 @@ void castor::tape::tapeserver::daemon::TapeWriteSingleThread::run() {
.add("ErrorMessage", errorMessage);
m_stats.totalTime = totalTimer.secs();
logWithStats(logLevel, "Tape thread complete for writing", params);
m_reportPacker.reportEndOfSessionWithErrors(errorMessage, errorCode, m_logContext);
m_reportPacker.reportEndOfSessionWithErrors(errorMessage, isTapeFull, m_logContext);
}
}
......
......@@ -244,19 +244,15 @@ namespace daemon {
// if of type Errnum AND the errorCode is ENOSPC, we will propagate it.
// This is how we communicate the fact that a tape is full to the client.
// We also change the log level to INFO for the case of end of tape.
int errorCode = 666; // TODO - Remove error code
int errorLevel = cta::log::ERR;
bool doReportJobError = true;
try {
const cta::exception::Errnum & errnum =
dynamic_cast<const cta::exception::Errnum &> (e);
const auto & errnum = dynamic_cast<const cta::exception::Errnum &> (e);
if (ENOSPC == errnum.errorNumber()) {
errorCode = ENOSPC;
errorLevel = cta::log::INFO;
doReportJobError = false;
}
} catch (...) {}
LogContext::ScopedParam sp(lc, Param("exceptionCode",errorCode));
LogContext::ScopedParam sp1(lc, Param("exceptionMessage", e.getMessageValue()));
lc.log(errorLevel,"An error occurred for this file. End of migrations.");
circulateMemBlocks();
......
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