Commit 847aa9bd authored by Cedric Caffy's avatar Cedric Caffy
Browse files

[cta-taped] Added configuration TapeLoadTimeout to set the timeout after which...

[cta-taped] Added configuration TapeLoadTimeout to set the timeout after which the tape mount is supposed to be failed
parent a939b199
......@@ -37,6 +37,20 @@ void SourcedParameter<time_t>::set(const std::string & value, const std::string
m_set = true;
}
template<>
void SourcedParameter<uint32_t>:: set(const std::string &value, const std::string & source){
if (!utils::isValidUInt(value)) {
BadlyFormattedInteger ex;
ex.getMessage() << "In SourcedParameter<uint32_t>::set() : badly formatted integer"
<< " for category=" << m_category << " key=" << m_key
<< " value=\'" << value << "' at:" << source;
throw ex;
}
std::istringstream(value) >> m_value;
m_source = source;
m_set = true;
}
template<>
void SourcedParameter<uint64_t>::set(const std::string & value, const std::string & source) {
if (!utils::isValidUInt(value)) {
......@@ -63,6 +77,11 @@ void SourcedParameter<time_t>::addLogParamForValue(log::LogContext & lc) {
lc.pushOrReplace({"value", m_value});
}
template<>
void SourcedParameter<uint32_t>::addLogParamForValue(log::LogContext & lc) {
lc.pushOrReplace({"value", m_value});
}
template<>
void SourcedParameter<uint64_t>::addLogParamForValue(log::LogContext & lc) {
lc.pushOrReplace({"value", m_value});
......
......@@ -209,6 +209,11 @@ void DriveState::setConfigValue<std::string>(cta::objectstore::serializers::Driv
item->set_value(value);
}
template<>
void DriveState::setConfigValue<uint32_t>(cta::objectstore::serializers::DriveConfig * item,const uint32_t & value){
item->set_value(std::to_string(value));
}
template<>
void DriveState::setConfigValue<uint64_t>(cta::objectstore::serializers::DriveConfig * item,const uint64_t & value){
item->set_value(std::to_string(value));
......@@ -249,6 +254,12 @@ void DriveState::fillConfig<cta::tape::daemon::FetchReportOrFlushLimits>(cta::So
setConfigValue(itemBytes,sourcedParameter.value().maxBytes);
}
template<>
void DriveState::fillConfig<uint32_t>(cta::SourcedParameter<uint32_t>& sourcedParameter){
auto item = createAndInitDriveConfig(sourcedParameter);
setConfigValue(item,sourcedParameter.value());
}
template<>
void DriveState::fillConfig<uint64_t>(cta::SourcedParameter<uint64_t>& sourcedParameter){
auto item = createAndInitDriveConfig(sourcedParameter);
......@@ -294,6 +305,7 @@ void DriveState::setConfig(const cta::tape::daemon::TapedConfiguration& tapedCon
fillConfig(config->disableRepackManagement);
fillConfig(config->disableMaintenanceProcess);
fillConfig(config->fetchEosFreeSpaceScript);
fillConfig(config->tapeLoadTimeout);
}
//------------------------------------------------------------------------------
......
......@@ -47,7 +47,7 @@ castor::tape::tapeserver::daemon::CleanerSession::CleanerSession(
m_sysWrapper(sysWrapper),
m_vid(vid),
m_waitMediaInDrive(waitMediaInDrive),
m_waitMediaInDriveTimeout(waitMediaInDriveTimeout),
m_tapeLoadTimeout(waitMediaInDriveTimeout),
m_encryptionControl(externalEncryptionKeyScript),
m_catalogue(catalogue),
m_scheduler(scheduler)
......@@ -288,11 +288,11 @@ void castor::tape::tapeserver::daemon::CleanerSession::waitUntilMediaIsReady(
params.push_back(cta::log::Param("tapeVid", m_vid));
params.push_back(cta::log::Param("tapeDrive", m_driveConfig.unitName));
params.push_back(cta::log::Param("waitMediaInDriveTimeout",
m_waitMediaInDriveTimeout));
m_tapeLoadTimeout));
try {
m_log(cta::log::INFO, "Cleaner waiting for drive to be ready", params);
drive.waitUntilReady(m_waitMediaInDriveTimeout);
drive.waitUntilReady(m_tapeLoadTimeout);
m_log(cta::log::INFO, "Cleaner detected drive is ready", params);
} catch (cta::exception::Exception &ex) {
params.push_back(cta::log::Param("message", ex.getMessage().str()));
......
......@@ -131,7 +131,7 @@ namespace daemon {
* The maximum number of seconds to wait for
* the media to be ready for operations inside the drive.
*/
const uint32_t m_waitMediaInDriveTimeout;
const uint32_t m_tapeLoadTimeout;
/**
* Encryption helper object
......
......@@ -137,6 +137,11 @@ struct DataTransferConfig {
* The path to the operator provided EOS free space fetch script (or empty string)
*/
std::string fetchEosFreeSpaceScript;
/**
* The timeout after which the mount of a tape is considered failed
*/
uint32_t tapeLoadTimeout;
/**
* Constructor that sets all integer member-variables to 0 and all string
......
......@@ -250,7 +250,7 @@ castor::tape::tapeserver::daemon::Session::EndOfSessionAction
TapeReadSingleThread trst(*drive, m_mc, tsr, m_volInfo,
m_castorConf.bulkRequestRecallMaxFiles,m_capUtils,rwd,lc,rrp,
m_castorConf.useLbp, m_castorConf.useRAO, m_castorConf.externalEncryptionKeyScript,*retrieveMount);
m_castorConf.useLbp, m_castorConf.useRAO, m_castorConf.externalEncryptionKeyScript,*retrieveMount, m_castorConf.tapeLoadTimeout);
DiskWriteThreadPool dwtp(m_castorConf.nbDiskThreads,
rrp,
rwd,
......@@ -374,7 +374,8 @@ castor::tape::tapeserver::daemon::Session::EndOfSessionAction
m_castorConf.maxBytesBeforeFlush,
m_castorConf.useLbp,
m_castorConf.externalEncryptionKeyScript,
*archiveMount);
*archiveMount,
m_castorConf.tapeLoadTimeout);
DiskReadThreadPool drtp(m_castorConf.nbDiskThreads,
m_castorConf.bulkRequestMigrationMaxFiles,
......
......@@ -104,9 +104,10 @@ namespace unitTests
cta::mediachanger::MediaChangerFacade & mc,
tapeserver::daemon::TapeServerReporter & tsr,
const tapeserver::daemon::VolumeInfo& volInfo,
cta::server::ProcessCap& cap,
cta::server::ProcessCap& cap,
const uint32_t tapeLoadTimeout,
cta::log::LogContext & lc):
TapeSingleThreadInterface<TapeReadTask>(drive, mc, tsr, volInfo,cap, lc, ""){}
TapeSingleThreadInterface<TapeReadTask>(drive, mc, tsr, volInfo,cap, lc, "", tapeLoadTimeout){}
~FakeSingleTapeReadThread(){
const unsigned int size= m_tasks.size();
......@@ -166,7 +167,7 @@ namespace unitTests
volume.mountType=cta::common::dataStructures::MountType::Retrieve;
castor::tape::tapeserver::daemon::TapeServerReporter gsr(initialProcess, cta::tape::daemon::TpconfigLine(), "0.0.0.0", volume, lc);
cta::server::ProcessCapDummy cap;
FakeSingleTapeReadThread tapeRead(drive, mc, gsr, volume, cap, lc);
FakeSingleTapeReadThread tapeRead(drive, mc, gsr, volume, cap, 60, lc);
tapeserver::daemon::RecallTaskInjector rti(mm, tapeRead, diskWrite, trm, maxNbJobsInjectedAtOnce, blockSize, lc);
bool noFilesToRecall;
......@@ -229,7 +230,7 @@ namespace unitTests
volume.mountType=cta::common::dataStructures::MountType::Retrieve;
cta::server::ProcessCapDummy cap;
castor::tape::tapeserver::daemon::TapeServerReporter tsr(initialProcess, cta::tape::daemon::TpconfigLine(), "0.0.0.0", volume, lc);
FakeSingleTapeReadThread tapeRead(drive, mc, tsr, volume, cap, lc);
FakeSingleTapeReadThread tapeRead(drive, mc, tsr, volume, cap, 60, lc);
tapeserver::daemon::RecallTaskInjector rti(mm, tapeRead, diskWrite, trm, 6, blockSize, lc);
......
......@@ -38,9 +38,10 @@ castor::tape::tapeserver::daemon::TapeReadSingleThread::TapeReadSingleThread(
const bool useLbp,
const bool useRAO,
const std::string & externalEncryptionKeyScript,
const cta::RetrieveMount& retrieveMount) :
const cta::RetrieveMount& retrieveMount,
const uint32_t tapeLoadTimeout) :
TapeSingleThreadInterface<TapeReadTask>(drive, mc, initialProcess, volInfo,
capUtils, lc, externalEncryptionKeyScript),
capUtils, lc, externalEncryptionKeyScript,tapeLoadTimeout),
m_maxFilesRequest(maxFilesRequest),
m_watchdog(watchdog),
m_rrp(rrp),
......@@ -91,9 +92,9 @@ castor::tape::tapeserver::daemon::TapeReadSingleThread::TapeCleaning::~TapeClean
// drive, which is a fine situation (so timeout exceptions are discarded).
// Other exception, where we failed to access the drive somehow are at passed
// through.
const uint32_t waitMediaInDriveTimeout = 60;
const uint32_t tapeLoadTimeout = m_this.m_tapeLoadTimeout;
try {
m_this.m_drive.waitUntilReady(waitMediaInDriveTimeout);
m_this.m_drive.waitUntilReady(tapeLoadTimeout);
} catch (cta::exception::TimeOut &) {}
if (!m_this.m_drive.hasTapeInPlace()) {
m_this.m_logContext.log(cta::log::INFO, "TapeReadSingleThread: No tape to unload");
......
......@@ -69,7 +69,8 @@ public:
const bool useLbp,
const bool useRAO,
const std::string & externalEncryptionKeyScript,
const cta::RetrieveMount &retrieveMount);
const cta::RetrieveMount &retrieveMount,
const uint32_t tapeLoadTimeout);
/**
* Set the task injector. Has to be done that way (and not in the constructor)
......
......@@ -94,6 +94,9 @@ protected:
/** Encryption helper object */
EncryptionControl m_encryptionControl;
/** Tape load timeout after which the mount is considered failed. */
uint32_t m_tapeLoadTimeout;
/**
* Try to mount the tape for read-only access, get an exception if it fails
......@@ -144,14 +147,14 @@ protected:
* After mounting the tape, the drive will say it has no tape inside,
* because there was no tape the first time it was opened...
* That function will wait a certain amount of time for the drive
* to tell us he acknowledge it has indeed a tap (get an ex exception in
* to tell us he acknowledge it has indeed a tape (get an ex exception in
* case of timeout)
*/
void waitForDrive(){
try{
cta::utils::Timer timer;
// wait 60s for drive to be ready (the mount call is synchronous, so this just the load operation.
m_drive.waitUntilReady(60);
// wait tapeLoadTimeout seconds for drive to be ready (the mount call is synchronous, so this just the load operation.
m_drive.waitUntilReady(m_tapeLoadTimeout);
cta::log::LogContext::ScopedParam sp0(m_logContext, cta::log::Param("loadTime", timer.secs()));
}catch(const cta::exception::Exception& e){
cta::log::LogContext::ScopedParam sp01(m_logContext, cta::log::Param("exceptionMessage", e.getMessageValue()));
......@@ -284,16 +287,17 @@ public:
* @param volInfo All we need to know about the tape we are manipulating
* @param capUtils
* @param lc lc The log context, later on copied
* @param tapeLoadTimeout the timeout after which the mount of the tape is considered failed
*/
TapeSingleThreadInterface(castor::tape::tapeserver::drive::DriveInterface & drive,
cta::mediachanger::MediaChangerFacade &mc,
TapeServerReporter & tsr,
const VolumeInfo& volInfo,
cta::server::ProcessCap &capUtils,cta::log::LogContext & lc,
const std::string & externalEncryptionKeyScript):m_capUtils(capUtils),
const std::string & externalEncryptionKeyScript, const uint32_t tapeLoadTimeout):m_capUtils(capUtils),
m_drive(drive), m_mc(mc), m_initialProcess(tsr), m_vid(volInfo.vid), m_logContext(lc),
m_volInfo(volInfo),m_hardwareStatus(Session::MARK_DRIVE_AS_UP),
m_encryptionControl(externalEncryptionKeyScript) {}
m_encryptionControl(externalEncryptionKeyScript),m_tapeLoadTimeout(tapeLoadTimeout) {}
}; // class TapeSingleThreadInterface
} // namespace daemon
......
......@@ -38,9 +38,10 @@ castor::tape::tapeserver::drive::DriveInterface & drive,
cta::server::ProcessCap &capUtils,
uint64_t filesBeforeFlush, uint64_t bytesBeforeFlush,
const bool useLbp, const std::string & externalEncryptionKeyScript,
const cta::ArchiveMount & archiveMount):
const cta::ArchiveMount & archiveMount,
const uint64_t tapeLoadTimeout):
TapeSingleThreadInterface<TapeWriteTask>(drive, mc, tsr, volInfo,
capUtils, lc, externalEncryptionKeyScript),
capUtils, lc, externalEncryptionKeyScript,tapeLoadTimeout),
m_filesBeforeFlush(filesBeforeFlush),
m_bytesBeforeFlush(bytesBeforeFlush),
m_drive(drive),
......@@ -82,7 +83,7 @@ castor::tape::tapeserver::daemon::TapeWriteSingleThread::TapeCleaning::~TapeClea
// First check that a tape is actually present in the drive. We can get here
// after failing to mount (library error) in which case there is nothing to
// do (and trying to unmount will only lead to a failure.)
const uint32_t waitMediaInDriveTimeout = 60;
const uint32_t waitMediaInDriveTimeout = m_this.m_tapeLoadTimeout;
try {
m_this.m_drive.waitUntilReady(waitMediaInDriveTimeout);
} catch (cta::exception::TimeOut &) {}
......
......@@ -58,6 +58,7 @@ public:
* @param filesBeforeFlush how many file written before flushing on tape
* @param bytesBeforeFlush how many bytes written before flushing on tape
* @param lastFseq the last fSeq
* @param tapeLoadTimeout the timeout after which we consider the tape mount to be failed
*/
TapeWriteSingleThread(
castor::tape::tapeserver::drive::DriveInterface & drive,
......@@ -70,7 +71,8 @@ public:
cta::server::ProcessCap &capUtils,
uint64_t filesBeforeFlush, uint64_t bytesBeforeFlush, const bool useLbp,
const std::string & externalEncryptionKeyScript,
const cta::ArchiveMount & archiveMount);
const cta::ArchiveMount & archiveMount,
const uint64_t tapeLoadTimeout);
/**
*
......
......@@ -1059,7 +1059,7 @@ int DriveHandler::runChild() {
sWrapper,
m_previousVid,
true,
60,
m_tapedConfig.tapeLoadTimeout.value(),
"",
*m_catalogue,
scheduler);
......@@ -1095,6 +1095,7 @@ int DriveHandler::runChild() {
dataTransferConfig.raoLtoAlgorithm = m_tapedConfig.raoLtoAlgorithm.value();
dataTransferConfig.raoLtoAlgorithmOptions = m_tapedConfig.raoLtoOptions.value();
dataTransferConfig.fetchEosFreeSpaceScript = m_tapedConfig.fetchEosFreeSpaceScript.value();
dataTransferConfig.tapeLoadTimeout = m_tapedConfig.tapeLoadTimeout.value();
dataTransferConfig.xrootPrivateKey = "";
// Before launching, and if this is the first session since daemon start, we will
......@@ -1245,7 +1246,7 @@ SubprocessHandler::ProcessingStatus DriveHandler::shutdown() {
sWrapper,
m_sessionVid,
true,
60,
m_tapedConfig.tapeLoadTimeout.value(),
"",
*m_catalogue,
*scheduler
......
......@@ -125,6 +125,8 @@ TapedConfiguration TapedConfiguration::createFromCtaConf(
ret.disableMaintenanceProcess.setFromConfigurationFile(cf,generalConfigPath);
// Fetch EOS Free space script configuration
ret.fetchEosFreeSpaceScript.setFromConfigurationFile(cf,generalConfigPath);
// Timeout for tape load action
ret.tapeLoadTimeout.setFromConfigurationFile(cf,generalConfigPath);
// Extract drive list from tpconfig + parsed config file
ret.driveConfigs = Tpconfig::parseFile(ret.tpConfigPath.value());
......@@ -161,6 +163,8 @@ TapedConfiguration TapedConfiguration::createFromCtaConf(
ret.disableMaintenanceProcess.log(log);
ret.fetchEosFreeSpaceScript.log(log);
ret.tapeLoadTimeout.log(log);
for (auto & i:ret.driveConfigs) {
i.second.log(log);
}
......
......@@ -156,6 +156,13 @@ struct TapedConfiguration {
"taped","DisableMaintenanceProcess","no","Compile time default"
};
//----------------------------------------------------------------------------
// Tape load actions
//----------------------------------------------------------------------------
cta::SourcedParameter<uint32_t> tapeLoadTimeout {
"taped", "TapeLoadTimeout",60,"Compile time default"
};
private:
/** A private dummy logger which will simplify the implementation of the
* functions (just unconditionally log things). */
......
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