The expiration time for new job artifacts in CI/CD pipelines is now 30 days (GitLab default). Previously generated artifacts in already completed jobs will not be affected by the change. The latest artifacts for all jobs in the latest successful pipelines will be kept. More information: https://gitlab.lrz.de/help/user/admin_area/settings/continuous_integration.html#default-artifacts-expiration

Commit cc47c480 authored by Michael Ott's avatar Michael Ott
Browse files

Expand SLURM-style nodelist to list of actual nodes

parent 80cae631
......@@ -27,6 +27,7 @@
#include "../../common/include/globalconfiguration.h"
#include "timestamp.h"
#include <boost/algorithm/string.hpp>
#include <boost/regex.hpp>
#include <boost/property_tree/json_parser.hpp>
#include <boost/property_tree/ptree.hpp>
#include <cstdlib>
......@@ -34,6 +35,9 @@
#include <dcdb/jobdatastore.h>
#include <iostream>
#include <mosquitto.h>
#include "dcdb/version.h"
#include "version.h"
#define SLURMJOBTIMEOUT 60000000000
......@@ -81,13 +85,37 @@ std::string getEnv(const char* var) {
}
}
void splitNodeList(const std::string& str, DCDB::NodeList& nl, char delim = ',')
void splitNodeList(const std::string& str, DCDB::NodeList& nl)
{
nl.clear();
std::stringstream ss(str);
std::string token;
while (std::getline(ss, token, delim)) {
nl.push_back(token);
std::string s1 = str;
boost::regex r1("([^,[]+)(\\[[0-9,-]+\\])?(,|$)", boost::regex::extended);
boost::smatch m1;
while (boost::regex_search(s1, m1, r1)) {
std::string hostBase = m1[1].str();
if (m1[2].str().size() == 0) {
nl.push_back(hostBase);
} else {
std::string s2 = m1[2].str();
boost::regex r2("([0-9]+)-?([0-9]+)?(,|\\])", boost::regex::extended);
boost::smatch m2;
while (boost::regex_search(s2, m2, r2)) {
if (m2[2] == "") {
nl.push_back(hostBase + m2[1].str());
} else {
int start = atoi(m2[1].str().c_str());
int stop = atoi(m2[2].str().c_str());
for (int i=start; i<=stop; i++) {
std::stringstream ss;
ss << std::setw(m2[2].str().length()) << std::setfill('0') << i;
nl.push_back(hostBase + ss.str());
}
}
s2 = m2.suffix().str();
}
}
s1 = m1.suffix().str();
}
}
......@@ -242,14 +270,19 @@ int main(int argc, char** argv) {
}
}
std::cout << "JOBID = " << jobId << std::endl;
std::cout << "USER = " << userId << std::endl;
std::cout << "START = " << ts << std::endl;
std::cout << "NODES = " << nodelist << std::endl;
DCDB::NodeList nl;
splitNodeList(nodelist, nl, ',');
DCDB::NodeList nl;
splitNodeList(nodelist, nl);
std::cout << "JOBID = " << jobId << std::endl;
std::cout << "USER = " << userId << std::endl;
std::cout << "START = " << ts << std::endl;
std::cout << "NODELIST = " << nodelist << std::endl;
std::cout << "NODES =";
for (auto &n: nl) {
std::cout << " " << n;
}
std::cout << std::endl;
try {
jd.jobId = jobId;
jd.userId = userId;
......
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