Notice to GitKraken users: A vulnerability has been found in the SSH key generation of GitKraken versions 7.6.0 to 8.0.0 (https://www.gitkraken.com/blog/weak-ssh-key-fix). If you use GitKraken and have generated a SSH key using one of these versions, please remove it both from your local workstation and from your LRZ GitLab profile.

21.10.2021, 9:00 - 11:00: Due to updates GitLab may be unavailable for some minutes between 09:00 and 11:00.

Commit 4b876ed5 authored by Michael Ott's avatar Michael Ott
Browse files

Check whether dcdbslurmjob runs in slurmd context and execute only on first node in nodelist

parent bd79521e
......@@ -95,6 +95,7 @@ void usage() {
std::cout << " -i<userid> Numerical user id [default: SLURM_JOB_USER var]" << std::endl;
std::cout << " -s<pattern> Nodelist substitution pattern [default: none]" << std::endl;
std::cout << " -m<pattern> Maximum job length in h [default: none]" << std::endl;
std::cout << " -f Force job insert/update [default: no]" << std::endl;
std::cout << std::endl;
std::cout << " -h This help page" << std::endl;
std::cout << std::endl;
......@@ -263,10 +264,11 @@ int main(int argc, char** argv) {
std::string domainId = JOB_DEFAULT_DOMAIN;
std::string substitution="";
int maxJobLength = -1;
bool force = false;
uint64_t ts=0;
// Defining options
const char *opts = "b:q:o:c:u:p:n:t:d:j:i:s:m:h";
const char *opts = "b:q:o:c:u:p:n:t:d:j:i:s:m:fh";
char ret;
while ((ret = getopt(argc, argv, opts))!=-1) {
......@@ -349,12 +351,30 @@ int main(int argc, char** argv) {
case 'm':
maxJobLength = std::stoull(optarg);
break;
case 'f':
force = true;
break;
case 'h':
default:
usage();
return 1;
}
}
// Check whether we are started by slurmd and are the first node in the nodelist
std::string slurmNodename = getEnv("SLURMD_NODENAME");
std::string slurmNodelist = getEnv("SLURM_JOB_NODELIST");
if (slurmNodelist == "") {
slurmNodelist = getEnv("SLURM_NODELIST");
}
DCDB::NodeList nl;
splitNodeList(slurmNodelist, nl);
if (!force && (slurmNodename.size() > 0)) {
if (slurmNodename != nl.front()) {
std::cout << "Running in slurmd context but not the first node in nodelist. Exiting." << std::endl;
return 0;
}
}
if (hostList.size() == 0) {
hostList.push_back("localhost");
......@@ -460,22 +480,19 @@ int main(int argc, char** argv) {
}
}
DCDB::NodeList nl, pnl;
DCDB::NodeList pnl;
if (start) {
if(nodelist=="") {
nodelist = getEnv("SLURM_JOB_NODELIST");
if (nodelist == "") {
nodelist = getEnv("SLURM_NODELIST");
}
// Check whether a nodelist was provided as command line argument.
// Otherwise we have populated nl above already.
if(nodelist.size() > 0) {
splitNodeList(nodelist, nl);
}
convertNodeList(nl, substitution);
// Getting the whole pack's node list, if necessary
if(isPackLeader) {
pnodelist = getEnv("SLURM_PACK_JOB_NODELIST");
}
}
splitNodeList(nodelist, nl);
convertNodeList(nl, substitution);
std::cout << "DOMAINID = " << domainId << std::endl;
std::cout << "JOBID = " << jobId << std::endl;
std::cout << "USER = " << userId << std::endl;
......
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