Skip to content
Snippets Groups Projects
Commit 3489cb09 authored by Miguel Barros's avatar Miguel Barros
Browse files

Add support for eosSpace resolution in disk instance space freeSpaceQueryURL

parent 3537949e
No related branches found
No related tags found
No related merge requests found
......@@ -148,9 +148,9 @@ if [ ! -z $BACKPRESSURE_TEST ]; then
echo "Backpressure test: setting too high free space requirements"
# This should be idempotent as we will be called several times
if [[ $( admin_cta --json ds ls | jq '.[] | select(.name=="repackBuffer") | .name') != '"repackBuffer"' ]]; then
admin_cta di add -n repackDiskInstance -m toto
admin_cta dis add -n repackDiskInstanceSpace --di repackDiskInstance -u "eos:${EOSINSTANCE}:default" -i 5 -m toto
admin_cta ds add -n repackBuffer --di repackDiskInstance --dis repackDiskInstanceSpace -r "root://${EOSINSTANCE}/${REPACK_BUFFER_BASEDIR}" -f 111222333444555 -s 20 -m toto
admin_cta di add -n ${EOSINSTANCE} -m toto
admin_cta dis add -n repackDiskInstanceSpace --di ${EOSINSTANCE} -u "eosSpace:default" -i 5 -m toto
admin_cta ds add -n repackBuffer --di ${EOSINSTANCE} --dis repackDiskInstanceSpace -r "root://${EOSINSTANCE}/${REPACK_BUFFER_BASEDIR}" -f 111222333444555 -s 20 -m toto
else
echo "Disk system repackBuffer alread defined. Ensuring too high free space requirements."
admin_cta ds ch -n repackBuffer -f 111222333444555
......
......@@ -77,6 +77,14 @@ std::string DiskSystemList::getFetchEosFreeSpaceScript() const{
// DiskSystemFreeSpaceList::fetchFileSystemFreeSpace()
//------------------------------------------------------------------------------
void DiskSystemFreeSpaceList::fetchDiskSystemFreeSpace(const std::set<std::string>& diskSystems, log::LogContext & lc) {
auto getDiskSystemFreeSpaceQueryURL = [](DiskSystem ds) {
auto dsURL = ds.diskInstanceSpace.freeSpaceQueryURL;
// Replace URLS starting in eosSpace with eos:{diskInstanceName}
if (dsURL.rfind("eosSpace", 0) == 0) {
dsURL = "eos:" + ds.diskInstanceSpace.diskInstance + dsURL.substr(8);
}
return dsURL;
};
// The real deal: go fetch the file system's free space.
cta::utils::Regex eosDiskSystem("^eos:(.*):(.*)$");
// For testing purposes
......@@ -88,7 +96,7 @@ void DiskSystemFreeSpaceList::fetchDiskSystemFreeSpace(const std::set<std::strin
try {
std::vector<std::string> regexResult;
auto & currentDiskSystem = m_systemList.at(ds);
regexResult = eosDiskSystem.exec(currentDiskSystem.diskInstanceSpace.freeSpaceQueryURL);
regexResult = eosDiskSystem.exec(getDiskSystemFreeSpaceQueryURL(currentDiskSystem));
if (regexResult.size()) {
//Script, then EOS free space query
if(!m_systemList.getFetchEosFreeSpaceScript().empty()){
......@@ -108,7 +116,7 @@ void DiskSystemFreeSpaceList::fetchDiskSystemFreeSpace(const std::set<std::strin
freeSpace = fetchEosFreeSpace(regexResult.at(1), regexResult.at(2), lc);
goto found;
}
regexResult = constantFreeSpaceDiskSystem.exec(m_systemList.at(ds).diskInstanceSpace.freeSpaceQueryURL);
regexResult = constantFreeSpaceDiskSystem.exec(getDiskSystemFreeSpaceQueryURL(m_systemList.at(ds)));
if (regexResult.size()) {
freeSpace = fetchConstantFreeSpace(regexResult.at(1), lc);
goto found;
......
......@@ -94,12 +94,12 @@ namespace unitTests {
void insertDiskSystemDefault() {
auto & catalogue = getCatalogue();
// create disk instance
std::string diskInstanceName = "DiskInstanceNameDefault";
std::string diskInstanceName = "ctaeos";
std::string diskInstanceComment = "Comment";
catalogue.createDiskInstance(m_cliId, diskInstanceName, diskInstanceComment);
// create disk instance space
std::string diskInstanceSpaceName = "DiskInstanceSpaceDefault";
std::string freeSpaceQueryURL = "eos:ctaeos:default";
std::string freeSpaceQueryURL = "eosSpace:default";
uint64_t refrestInterval = 1;
std::string diskInstanceSpaceComment = "Comment";
catalogue.createDiskInstanceSpace(m_cliId, diskInstanceSpaceName, diskInstanceName, freeSpaceQueryURL, refrestInterval, diskInstanceSpaceComment);
......
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