Commit d0644b7a authored by Cedric Caffy's avatar Cedric Caffy
Browse files

[repack] Repack now fails if the repack buffer VID directory cannot be created during expansion

parent 6001894f
# v3.1-10
## Summary
### Features
### Bug fixes
cta/CTA#837 Repack now fails if the repack buffer VID directory cannot be created during expansion
# v3.1-9
## Summary
......
......@@ -490,6 +490,8 @@ Currently contains a helper for the client-ar script, which should be installed
%attr(0755,root,root) /usr/bin/cta-client-ar-abortPrepare
%changelog
* Wed Nov 18 2020 julien.leduc (at) cern.ch - 3.1-10
- cta/CTA#837 Repack now fails if the repack buffer VID directory cannot be created during expansion
* Wed Nov 04 2020 julien.leduc (at) cern.ch - 3.1-9
- Upstream EOS 4.8.26-1
- cta/CTA#907 For backpressure, the EOS free space can be fetched by calling an external script
......
......@@ -771,6 +771,7 @@ void XRootdDirectory::rmdir() {
bool XRootdDirectory::exist() {
XrdCl::StatInfo *statInfo;
XrdCl::XRootDStatus statStatus = m_xrootFileSystem.Stat(m_truncatedDirectoryURL,statInfo,c_xrootTimeout);
cta::exception::XrootCl::throwOnError(statStatus,"In XRootdDirectory::exist() : failed to stat the directory at "+m_URL);
if(statStatus.errNo == XErrorCode::kXR_NotFound){
return false;
}
......
......@@ -230,6 +230,10 @@ namespace cta {
* Remove the directory located at this->m_URL
*/
virtual void rmdir() = 0;
std::string getURL() {
return m_URL;
}
virtual ~Directory() throw() {}
protected:
......
......@@ -461,27 +461,20 @@ void Scheduler::expandRepackRequest(std::unique_ptr<RepackRequest>& repackReques
//We only create the folder if there are some files to Repack
cta::disk::DirectoryFactory dirFactory;
dir.reset(dirFactory.createDirectory(dirBufferURL.str()));
if(dir->exist()){
//Repack tape repair workflow
try{
try {
if(dir->exist()){
//Repack tape repair workflow
filesInDirectory = dir->getFilesName();
} catch (const cta::exception::XrootCl &ex) {
log::ScopedParamContainer spc(lc);
spc.add("vid",repackInfo.vid);
spc.add("errorMessage",ex.getMessageValue());
lc.log(log::WARNING,"In Scheduler::expandRepackRequest(), received XRootdException while listing files in the buffer");
}
} else {
if(repackInfo.noRecall){
//The buffer directory should be created if the --no-recall flag has been passed
//So we throw an exception
throw ExpandRepackRequestException("In Scheduler::expandRepackRequest(): the flag --no-recall is set but no buffer directory has been created.");
}
try {
} else {
if(repackInfo.noRecall){
//The buffer directory should be created if the --no-recall flag has been passed
//So we throw an exception
throw ExpandRepackRequestException("In Scheduler::expandRepackRequest(): the flag --no-recall is set but no buffer directory has been created.");
}
dir->mkdir();
} catch (const cta::exception::XrootCl &ex){
throw ExpandRepackRequestException(ex.getMessageValue());
}
} catch (const cta::exception::XrootCl &ex) {
throw ExpandRepackRequestException("In Scheduler::expandRepackRequest(): errors while doing some checks on the repack buffer. ExceptionMsg = " + ex.getMessageValue());
}
}
......@@ -580,7 +573,7 @@ void Scheduler::expandRepackRequest(std::unique_ptr<RepackRequest>& repackReques
}
}
if(retrieveSubRequest.copyNbsToRearchive.size() < filesToArchive){
deleteRepackBuffer(std::move(dir));
deleteRepackBuffer(std::move(dir),lc);
throw ExpandRepackRequestException("In Scheduler::expandRepackRequest(): Missing archive routes for the creation of the new copies of the files");
}
} else {
......@@ -592,7 +585,7 @@ void Scheduler::expandRepackRequest(std::unique_ptr<RepackRequest>& repackReques
}
} else {
//No storage class have been found for the current tapefile throw an exception
deleteRepackBuffer(std::move(dir));
deleteRepackBuffer(std::move(dir),lc);
throw ExpandRepackRequestException("In Scheduler::expandRepackRequest(): No storage class have been found for the file to add copies");
}
}
......@@ -642,7 +635,7 @@ void Scheduler::expandRepackRequest(std::unique_ptr<RepackRequest>& repackReques
// value in case of crash.
nbRetrieveSubrequestsQueued = repackRequest->m_dbReq->addSubrequestsAndUpdateStats(retrieveSubrequests, archiveRoutesMap, fSeq, maxAddedFSeq, totalStatsFile, diskSystemList, lc);
} catch(const cta::ExpandRepackRequestException& e){
deleteRepackBuffer(std::move(dir));
deleteRepackBuffer(std::move(dir),lc);
throw e;
}
timingList.insertAndReset("addSubrequestsAndUpdateStatsTime",t);
......@@ -654,7 +647,7 @@ void Scheduler::expandRepackRequest(std::unique_ptr<RepackRequest>& repackReques
if(archiveFilesFromCatalogue.empty() && totalStatsFile.totalFilesToArchive == 0 && (totalStatsFile.totalFilesToRetrieve == 0 || nbRetrieveSubrequestsQueued == 0)){
//If no files have been retrieve, the repack buffer will have to be deleted
//TODO : in case of Repack tape repair, we should not try to delete the buffer
deleteRepackBuffer(std::move(dir));
deleteRepackBuffer(std::move(dir),lc);
}
repackRequest->m_dbReq->expandDone();
lc.log(log::INFO,"In Scheduler::expandRepackRequest(), repack request expanded");
......@@ -1096,9 +1089,15 @@ cta::optional<common::dataStructures::LogicalLibrary> Scheduler::getLogicalLibra
return ret;
}
void Scheduler::deleteRepackBuffer(std::unique_ptr<cta::disk::Directory> repackBuffer) {
if(repackBuffer != nullptr && repackBuffer->exist()){
repackBuffer->rmdir();
void Scheduler::deleteRepackBuffer(std::unique_ptr<cta::disk::Directory> repackBuffer, cta::log::LogContext & lc) {
try{
if(repackBuffer != nullptr && repackBuffer->exist()){
repackBuffer->rmdir();
}
} catch (const cta::exception::XrootCl & ex) {
log::ScopedParamContainer spc(lc);
spc.add("exceptionMsg",ex.getMessageValue());
lc.log(log::ERR,"In Scheduler::deleteRepackBuffer() unable to delete the directory located in " + repackBuffer->getURL());
}
}
......
......@@ -306,7 +306,7 @@ private:
cta::optional<common::dataStructures::LogicalLibrary> getLogicalLibrary(const std::string &libraryName, double &getLogicalLibraryTime);
void deleteRepackBuffer(std::unique_ptr<cta::disk::Directory> repackBuffer);
void deleteRepackBuffer(std::unique_ptr<cta::disk::Directory> repackBuffer, cta::log::LogContext & lc);
uint64_t getNbFilesAlreadyArchived(const common::dataStructures::ArchiveFile& archiveFile);
......
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