Commit 91ab5273 authored by Cedric Caffy's avatar Cedric Caffy
Browse files

Added status to "Tape session finished" message

parent 717256c6
......@@ -408,7 +408,7 @@ echo ${INITIAL_DRIVES_STATE} | jq -r '.[] | [ .driveName, .driveStatus] | @tsv'
echo -n "Will put down those drives : "
echo ${INITIAL_DRIVES_STATE} | jq -r '.[] | select (.driveStatus == "UP") | .driveName'
for d in `echo ${INITIAL_DRIVES_STATE} | jq -r '.[] | select (.driveStatus == "UP") | .driveName'`; do
admin_cta dr down $d
admin_cta drive down $d --reason "putting drive down for test"
done
# Prepare-stage the files
......
......@@ -196,8 +196,8 @@ repackCancellation() {
echo "***********************************"
echo "Putting all drives down"
echo 'kubectl -n ${NAMESPACE} exec ctacli -- cta-admin drive down VD.*'
kubectl -n ${NAMESPACE} exec ctacli -- cta-admin drive down VD.*
echo 'kubectl -n ${NAMESPACE} exec ctacli -- cta-admin drive down VD.* --reason "Putting drive down for repack test"'
kubectl -n ${NAMESPACE} exec ctacli -- cta-admin drive down VD.* --reason "Putting drive down for repack test"
VID_TO_REPACK=$(getFirstVidContainingFiles)
if [ "$VID_TO_REPACK" != "null" ]
......
......@@ -268,8 +268,8 @@ castor::tape::tapeserver::daemon::Session::EndOfSessionAction
if (m_castorConf.useRAO) {
rti.initRAO();
}
if (rti.synchronousFetch()) { //adapt the recall task injector (starting from synchronousFetch)
bool noFilesToRecall = false;
if (rti.synchronousFetch(noFilesToRecall)) { //adapt the recall task injector (starting from synchronousFetch)
// We got something to recall. Time to start the machinery
trst.setWaitForInstructionsTime(timer.secs());
rwd.startThread();
......@@ -294,7 +294,15 @@ castor::tape::tapeserver::daemon::Session::EndOfSessionAction
} else {
// Just log this was an empty mount and that's it. The memory management
// will be deallocated automatically.
lc.log(cta::log::WARNING, "Aborting recall mount startup: empty mount");
int priority = cta::log::ERR;
std::string status = "success";
if(noFilesToRecall){
//If this is an empty mount because no files have been popped from the queue, it is just a warning
priority = cta::log::WARNING;
status = "failure";
}
lc.log(priority, "Aborting recall mount startup: empty mount");
std::string mountId = retrieveMount->getMountTransactionId();
std::string mountType = cta::common::dataStructures::toString(retrieveMount->getMountType());
......@@ -302,17 +310,18 @@ castor::tape::tapeserver::daemon::Session::EndOfSessionAction
cta::log::Param errorMessageParam("errorMessage", "Aborted: empty recall mount");
cta::log::Param mountIdParam("mountId", mountId);
cta::log::Param mountTypeParam("mountType", mountType);
cta::log::Param statusParam("status",status);
cta::log::LogContext::ScopedParam sp1(lc, errorMessageParam);
try {
retrieveMount->abort();
rwd.updateStats(TapeSessionStats());
rwd.reportStats();
std::list<cta::log::Param> paramList { errorMessageParam, mountIdParam, mountTypeParam };
std::list<cta::log::Param> paramList { errorMessageParam, mountIdParam, mountTypeParam, statusParam };
m_intialProcess.addLogParams(m_driveConfig.unitName,paramList);
cta::log::LogContext::ScopedParam sp08(lc, cta::log::Param("MountTransactionId", mountId));
cta::log::LogContext::ScopedParam sp11(lc, cta::log::Param("errorMessage", "Aborted: empty recall mount"));
lc.log(cta::log::WARNING, "Notified client of end session with error");
lc.log(priority, "Notified client of end session with error");
} catch(cta::exception::Exception & ex) {
cta::log::LogContext::ScopedParam sp1(lc, cta::log::Param("notificationError", ex.getMessageValue()));
lc.log(cta::log::ERR, "Failed to notified client of end session with error");
......@@ -373,7 +382,8 @@ castor::tape::tapeserver::daemon::Session::EndOfSessionAction
mrp.setWatchdog(mwd);
cta::utils::Timer timer;
if (mti.synchronousInjection()) {
bool noFilesToMigrate = false;
if (mti.synchronousInjection(noFilesToMigrate)) {
const uint64_t firstFseqFromClient = mti.firstFseqToWrite();
//the last fseq written on the tape is the first file's fseq minus one
......@@ -421,22 +431,29 @@ castor::tape::tapeserver::daemon::Session::EndOfSessionAction
} else {
// Just log this was an empty mount and that's it. The memory management
// will be deallocated automatically.
lc.log(cta::log::WARNING, "Aborting migration mount startup: empty mount");
int priority = cta::log::ERR;
std::string status = "failure";
if(noFilesToMigrate){
priority = cta::log::WARNING;
status = "success";
}
lc.log(priority, "Aborting migration mount startup: empty mount");
std::string mountId = archiveMount->getMountTransactionId();
std::string mountType = cta::common::dataStructures::toString(archiveMount->getMountType());
cta::log::Param errorMessageParam("errorMessage", "Aborted: empty migration mount");
cta::log::Param mountIdParam("mountId", mountId);
cta::log::Param mountTypeParam("mountType",mountType);
cta::log::Param statusParam("status", status);
cta::log::LogContext::ScopedParam sp1(lc, errorMessageParam);
try {
archiveMount->complete();
mwd.updateStats(TapeSessionStats());
mwd.reportStats();
std::list<cta::log::Param> paramList { errorMessageParam, mountIdParam, mountTypeParam };
std::list<cta::log::Param> paramList { errorMessageParam, mountIdParam, mountTypeParam, statusParam };
m_intialProcess.addLogParams(m_driveConfig.unitName,paramList);
cta::log::LogContext::ScopedParam sp1(lc, cta::log::Param("MountTransactionId", mountId));
lc.log(cta::log::WARNING, "Notified client of end session with error");
lc.log(priority, "Notified client of end session with error");
} catch(cta::exception::Exception & ex) {
cta::log::LogContext::ScopedParam sp1(lc, cta::log::Param("notificationError", ex.getMessageValue()));
lc.log(cta::log::ERR, "Failed to notified client of end session with error");
......
......@@ -109,8 +109,9 @@ namespace daemon {
//------------------------------------------------------------------------------
//synchronousInjection
//------------------------------------------------------------------------------
bool MigrationTaskInjector::synchronousInjection() {
bool MigrationTaskInjector::synchronousInjection(bool & noFilesToMigrate) {
std::list<std::unique_ptr<cta::ArchiveJob> > jobs;
noFilesToMigrate = false;
try {
//First popping of files, we multiply the number of popped files / bytes by 2 to avoid multiple mounts on Repack
//(it is applied to ArchiveForUser and ArchiveForRepack batches)
......@@ -128,6 +129,7 @@ namespace daemon {
scoped.add("byteSizeThreshold",m_maxBytes)
.add("maxFiles", m_maxFiles);
if(jobs.empty()) {
noFilesToMigrate = true;
m_lc.log(cta::log::WARNING, "No files to migrate: empty mount");
return false;
} else {
......
......@@ -86,9 +86,10 @@ public:
* Contact the client to make sure there are really something to do
* Something = migration at most maxFiles or at least maxBytes
*
* @param noFilesToMigrate[out] will be true if it triggered an empty mount because of no files to migrate
* @return true if there are jobs to be done, false otherwise
*/
bool synchronousInjection();
bool synchronousInjection(bool & noFilesToMigrate);
/**
* Send an end token in the request queue. There should be no subsequent
......
......@@ -233,8 +233,9 @@ void RecallTaskInjector::injectBulkRecalls() {
//------------------------------------------------------------------------------
//synchronousInjection
//------------------------------------------------------------------------------
bool RecallTaskInjector::synchronousFetch()
bool RecallTaskInjector::synchronousFetch(bool & noFilesToRecall)
{
noFilesToRecall = false;
uint64_t reqFiles = (m_useRAO && m_hasUDS) ? m_raoLimits.maxSupported - m_fetched : m_maxFiles;
/* If RAO is enabled, we must ask for files up to 1PB.
* We are limiting to 1PB because the size will be passed as
......@@ -260,6 +261,7 @@ bool RecallTaskInjector::synchronousFetch()
.add("requestedFiles", reqFiles);
if(m_jobs.empty()) {
m_lc.log(cta::log::WARNING, "No files to recall: empty mount");
noFilesToRecall = true;
return false;
}
else {
......@@ -312,7 +314,8 @@ void RecallTaskInjector::WorkerThread::run()
m_parent.m_lc.log(cta::log::INFO,"Query getLimitUDS for RAO completed");
if (m_parent.m_fetched < m_parent.m_raoLimits.maxSupported) {
/* Fetching until we reach maxSupported for the tape drive RAO */
m_parent.synchronousFetch();
bool noFilesToRecall;
m_parent.synchronousFetch(noFilesToRecall);
}
m_parent.injectBulkRecalls();
/**
......
......@@ -98,11 +98,10 @@ public:
* Contact the client to make sure there are really something to do
* Something = recall at most maxFiles or at least maxBytes
*
* @param maxFiles files count requested.
* @param byteSizeThreshold total bytes count at least requested
* @param noFilesToRecall will be true if noFilesWere popped from the queue.
* @return true if there are jobs to be done, false otherwise
*/
bool synchronousFetch();
bool synchronousFetch(bool & noFilesToRecall);
/**
* Wait for the inner thread to finish
......
......@@ -169,7 +169,9 @@ namespace unitTests
FakeSingleTapeReadThread tapeRead(drive, mc, gsr, volume, cap, lc);
tapeserver::daemon::RecallTaskInjector rti(mm, tapeRead, diskWrite, trm, maxNbJobsInjectedAtOnce, blockSize, lc);
ASSERT_EQ(true, rti.synchronousFetch());
bool noFilesToRecall;
ASSERT_EQ(true, rti.synchronousFetch(noFilesToRecall));
ASSERT_FALSE(noFilesToRecall);
ASSERT_EQ(maxNbJobsInjectedAtOnce, diskWrite.m_tasks.size());
ASSERT_EQ(maxNbJobsInjectedAtOnce, tapeRead.m_tasks.size());
......@@ -231,9 +233,11 @@ namespace unitTests
tapeserver::daemon::RecallTaskInjector rti(mm, tapeRead, diskWrite, trm, 6, blockSize, lc);
ASSERT_FALSE(rti.synchronousFetch());
bool noFilesToRecall;
ASSERT_FALSE(rti.synchronousFetch(noFilesToRecall));
ASSERT_EQ(0U, diskWrite.m_tasks.size());
ASSERT_EQ(0U, tapeRead.m_tasks.size());
ASSERT_EQ(1, trm.getJobs);
ASSERT_TRUE(noFilesToRecall);
}
}
......@@ -179,9 +179,9 @@ protected:
deliveryTime > totalTime?deliveryTime-totalTime: 0.0;
bool wasTapeMounted = true;
if(m_stats.mountTime == 0.0){
//Tape was not mounted, we add a message to tell that no physical mount has been
//triggered
wasTapeMounted = false;
//Tape was not mounted, we add a message to tell that no physical mount has been
//triggered
wasTapeMounted = false;
}
paramList.push_back(Param("wasTapeMounted",wasTapeMounted));
paramList.push_back(Param("mountTime", m_stats.mountTime));
......
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