From 0d2c4d8465488a5d7234bacb93d9a902e7ecd811 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20Pomar?= Date: Wed, 22 Jun 2022 17:37:15 +0200 Subject: [PATCH] -ignis-export and ignis-export scripts for copying IgnisHPC out of container -ignis-submit can now run outside of the submitter container -future implementation of udocker has been dropper from slurm -new slurm dockerfile to extract ignis-slurm from a container -docker scheduler important fixes --- Dockerfiles/driver-builder/Dockerfile | 8 +- Dockerfiles/driver-builder/ignis-export | 13 ++ Dockerfiles/driver-builder/ignis-export-all | 10 ++ Dockerfiles/slurm-submitter/Dockerfile | 9 ++ Dockerfiles/slurm-submitter/ignis-slurm | 7 + Dockerfiles/submitter/Dockerfile | 3 +- Dockerfiles/submitter/ignis-submit | 5 + .../src/main/java/org/ignis/backend/Main.java | 3 + .../org/ignis/backend/cluster/IExecutor.java | 5 +- .../tasks/container/IContainerCreateTask.java | 1 + .../tasks/executor/IExecutorDestroyTask.java | 2 +- etc/ignis.conf | 2 +- .../main/java/org/ignis/scheduler/Docker.java | 151 ++++++++++-------- scheduler-slurm/build.gradle | 2 +- .../main/java/org/ignis/scheduler/Slurm.java | 17 +- .../java/org/ignis/submitter/SlurmSubmit.java | 12 +- .../src/main/resources/ignis-slurm | 3 - submitter/build.gradle | 9 +- .../main/java/org/ignis/submitter/Submit.java | 12 +- 19 files changed, 174 insertions(+), 100 deletions(-) create mode 100644 Dockerfiles/driver-builder/ignis-export create mode 100644 Dockerfiles/driver-builder/ignis-export-all create mode 100644 Dockerfiles/slurm-submitter/Dockerfile create mode 100644 Dockerfiles/slurm-submitter/ignis-slurm delete mode 100644 scheduler-slurm/src/main/resources/ignis-slurm diff --git a/Dockerfiles/driver-builder/Dockerfile b/Dockerfiles/driver-builder/Dockerfile index 27881a8a..8a494490 100644 --- a/Dockerfiles/driver-builder/Dockerfile +++ b/Dockerfiles/driver-builder/Dockerfile @@ -14,7 +14,7 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ ENV GRADLE_VERSION=7.2 RUN \ - mkdir -p /tmp/gradle && \ + mkdir -p /tmp/gradle && \ cd /tmp/gradle && \ wget https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip -O src.zip && \ unzip src && \ @@ -38,4 +38,8 @@ RUN mkdir ${IGNIS_HOME}/lib/java && \ rm -fr /tmp/backend COPY ${RELPATH}driver-install.sh ${IGNIS_HOME}/common -RUN chmod +x ${IGNIS_HOME}/common/driver-install.sh +COPY ${RELPATH}ignis-export ${IGNIS_HOME}/bin +COPY ${RELPATH}ignis-export-all ${IGNIS_HOME}/bin +RUN chmod +x ${IGNIS_HOME}/common/driver-install.sh && \ + chmod +x ${IGNIS_HOME}/bin/ignis-export && \ + chmod +x ${IGNIS_HOME}/bin/ignis-export-all diff --git a/Dockerfiles/driver-builder/ignis-export b/Dockerfiles/driver-builder/ignis-export new file mode 100644 index 00000000..af9244ed --- /dev/null +++ b/Dockerfiles/driver-builder/ignis-export @@ -0,0 +1,13 @@ +#!/bin/bash + +if [ $# -ne 1 ] + then echo "usage ignis-export " + exit +fi + +cd "$1" +mkdir -p ignis/lib +cp -R ${IGNIS_HOME}/bin ignis/ +cp -R ${IGNIS_HOME}/etc ignis/ +cp -R ${IGNIS_HOME}/backend ignis/ +cp -R ${IGNIS_HOME}/lib/java ignis/lib/ diff --git a/Dockerfiles/driver-builder/ignis-export-all b/Dockerfiles/driver-builder/ignis-export-all new file mode 100644 index 00000000..973df015 --- /dev/null +++ b/Dockerfiles/driver-builder/ignis-export-all @@ -0,0 +1,10 @@ +#!/bin/bash + +if [ $# -ne 1 ] + then echo "usage ignis-export-all " + exit +fi + +cd "$1" +mkdir -p ignis +cp -R ${IGNIS_HOME}/* ignis/ diff --git a/Dockerfiles/slurm-submitter/Dockerfile b/Dockerfiles/slurm-submitter/Dockerfile new file mode 100644 index 00000000..84a125f1 --- /dev/null +++ b/Dockerfiles/slurm-submitter/Dockerfile @@ -0,0 +1,9 @@ + +ARG REGISTRY="" +ARG NAMESPACE="ignishpc/" +ARG TAG="" +FROM ${REGISTRY}${NAMESPACE}common${TAG} +ARG RELPATH="" + +COPY ${RELPATH}ignis-slurm ${IGNIS_HOME}/bin +RUN chmod +x ${IGNIS_HOME}/bin/ignis-slurm diff --git a/Dockerfiles/slurm-submitter/ignis-slurm b/Dockerfiles/slurm-submitter/ignis-slurm new file mode 100644 index 00000000..06dd8fa1 --- /dev/null +++ b/Dockerfiles/slurm-submitter/ignis-slurm @@ -0,0 +1,7 @@ +#!/bin/bash +#script is inside IGNIS_HOME so if it is not set, we can discover it. +if [[ -z "${IGNIS_HOME}" ]]; then + export IGNIS_HOME=$(builtin cd $(dirname "$0"); cd ..; pwd) +fi + +exec ${IGNIS_HOME}/backend/jre/bin/java -cp "${IGNIS_HOME}/lib/java/*" org.ignis.submitter.SlurmSubmit "$@" diff --git a/Dockerfiles/submitter/Dockerfile b/Dockerfiles/submitter/Dockerfile index 771b63b4..49af5019 100644 --- a/Dockerfiles/submitter/Dockerfile +++ b/Dockerfiles/submitter/Dockerfile @@ -7,13 +7,12 @@ ARG RELPATH="" RUN ${IGNIS_HOME}/common/driver-install.sh && \ rm -fR ${IGNIS_HOME}/common && \ - rm -f ${IGNIS_HOME}/bin/* && \ export DEBIAN_FRONTEND=noninteractive && \ apt update && \ apt install -y --no-install-recommends \ git \ wget \ - unzip \ + unzip \ python3 \ python3-distutils && \ rm -rf /var/lib/apt/lists/* && \ diff --git a/Dockerfiles/submitter/ignis-submit b/Dockerfiles/submitter/ignis-submit index c945471e..06dc3e54 100644 --- a/Dockerfiles/submitter/ignis-submit +++ b/Dockerfiles/submitter/ignis-submit @@ -1,2 +1,7 @@ #!/bin/bash +#script is inside IGNIS_HOME so if it is not set, we can discover it. +if [[ -z "${IGNIS_HOME}" ]]; then + export IGNIS_HOME=$(builtin cd $(dirname "$0"); cd ..; pwd) +fi + exec ${IGNIS_HOME}/backend/jre/bin/java -cp "${IGNIS_HOME}/lib/java/*" org.ignis.submitter.Submit "$@" diff --git a/backend/src/main/java/org/ignis/backend/Main.java b/backend/src/main/java/org/ignis/backend/Main.java index 3b137baf..2ead973e 100644 --- a/backend/src/main/java/org/ignis/backend/Main.java +++ b/backend/src/main/java/org/ignis/backend/Main.java @@ -48,6 +48,7 @@ public static void main(String[] args) { LOGGER.info("Loading environment variables"); props.fromEnv(System.getenv()); + String home = props.getString(IKeys.HOME); if (props.contains(IKeys.OPTIONS)) {//Submit user options try { @@ -57,6 +58,8 @@ public static void main(String[] args) { } props.rmProperty(IKeys.OPTIONS); } + //Submitter home may be different so we ignore it. + props.setProperty(IKeys.HOME, home); LOGGER.info("Loading configuration file"); try { diff --git a/backend/src/main/java/org/ignis/backend/cluster/IExecutor.java b/backend/src/main/java/org/ignis/backend/cluster/IExecutor.java index 0a230648..36fe58ee 100644 --- a/backend/src/main/java/org/ignis/backend/cluster/IExecutor.java +++ b/backend/src/main/java/org/ignis/backend/cluster/IExecutor.java @@ -28,7 +28,10 @@ import org.ignis.rpc.executor.*; import org.ignis.scheduler.model.IPort; -import java.util.*; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; /** * @author César Pomar diff --git a/backend/src/main/java/org/ignis/backend/cluster/tasks/container/IContainerCreateTask.java b/backend/src/main/java/org/ignis/backend/cluster/tasks/container/IContainerCreateTask.java index 728fdb60..a7f2995e 100644 --- a/backend/src/main/java/org/ignis/backend/cluster/tasks/container/IContainerCreateTask.java +++ b/backend/src/main/java/org/ignis/backend/cluster/tasks/container/IContainerCreateTask.java @@ -128,6 +128,7 @@ public void run(ITaskContext context) throws IgnisException { try { scheduler.destroyExecutorInstances(stopped); } catch (ISchedulerException ex) { + LOGGER.warn(log() + ex); } } else { for (int i = 0; i < stoppedIndex.size(); i++) { diff --git a/backend/src/main/java/org/ignis/backend/cluster/tasks/executor/IExecutorDestroyTask.java b/backend/src/main/java/org/ignis/backend/cluster/tasks/executor/IExecutorDestroyTask.java index d6c19e3d..b3044067 100644 --- a/backend/src/main/java/org/ignis/backend/cluster/tasks/executor/IExecutorDestroyTask.java +++ b/backend/src/main/java/org/ignis/backend/cluster/tasks/executor/IExecutorDestroyTask.java @@ -50,7 +50,7 @@ public void run(ITaskContext context) throws IgnisException { "; do sleep 1; done\" || kill -9 " + executor.getPid(); executor.getContainer().getTunnel().execute(killScript, false); } catch (IgnisException ex) { - LOGGER.warn(log() + ex.toString()); + LOGGER.warn(log() + ex); } executor.setPid(-1); LOGGER.info(log() + "Executor destroyed"); diff --git a/etc/ignis.conf b/etc/ignis.conf index 2f997c58..fd20f912 100644 --- a/etc/ignis.conf +++ b/etc/ignis.conf @@ -10,7 +10,7 @@ ignis.debug=false #ignis.job.worker= #DFS #ignis.dfs.id= -#ignis.dfs.home= +ignis.dfs.home=/media/dfs #SCHEDULER #ignis.scheduler.url= #ignis.scheduler.type= diff --git a/scheduler-docker/src/main/java/org/ignis/scheduler/Docker.java b/scheduler-docker/src/main/java/org/ignis/scheduler/Docker.java index 25d37c2d..fb55ee13 100644 --- a/scheduler-docker/src/main/java/org/ignis/scheduler/Docker.java +++ b/scheduler-docker/src/main/java/org/ignis/scheduler/Docker.java @@ -20,7 +20,6 @@ import com.github.dockerjava.api.command.CreateContainerCmd; import com.github.dockerjava.api.command.InspectContainerResponse; import com.github.dockerjava.api.exception.DockerException; -import com.github.dockerjava.api.exception.NotFoundException; import com.github.dockerjava.api.model.*; import com.github.dockerjava.core.DefaultDockerClientConfig; import com.github.dockerjava.core.DockerClientConfig; @@ -29,6 +28,7 @@ import com.github.dockerjava.transport.DockerHttpClient; import org.ignis.scheduler.model.*; +import java.io.File; import java.math.BigInteger; import java.nio.ByteBuffer; import java.time.Duration; @@ -59,7 +59,18 @@ public class Docker implements IScheduler { private final DockerClient dockerClient; public Docker(String url) { - this.path = url; + if (!url.contains("://")) { + if (url.startsWith("/")) { + url = "unix://" + url; + } else if (url.contains(":") && !url.startsWith("tcp://")) { + url = "tcp://" + url; + } + } + if (url.toLowerCase().startsWith("unix:")) { + this.path = new File(url.substring("unix:".length())).getAbsolutePath(); + } else { + this.path = null; + } config = DefaultDockerClientConfig. createDefaultConfigBuilder(). withDockerHost(url). @@ -85,6 +96,10 @@ private String newId() { return new BigInteger(buffer.array()).toString(36); } + private String fixName(String name) { + return name.toLowerCase().replaceAll("[^\\w\\-\\._\\\\]", ""); + } + private CreateContainerCmd parseContainer(IContainerInfo container) { CreateContainerCmd dockerContainer = dockerClient.createContainerCmd(container.getImage()); dockerContainer.withLabels(new HashMap<>()); @@ -111,22 +126,17 @@ private CreateContainerCmd parseContainer(IContainerInfo container) { int i = 0; for (IPort port : container.getPorts()) { String value = ""; - boolean flag = false; - if (port.getContainerPort() == 0) { - value += dynPort; - flag = true; - } else { - value += port.getContainerPort(); - } - value += ":"; - if (port.getHostPort() == 0) { - value += dynPort; - flag = true; - } else { - value += port.getHostPort(); - } - if (flag) { + if(port.getContainerPort() == 0 && port.getHostPort() == 0){ + value += dynPort + ":" + dynPort; dynPort++; + }else{ + if (port.getContainerPort() == 0){ + value += port.getContainerPort(); + } + if (port.getHostPort() == 0){ + value += port.getContainerPort(); + } + value = value + ":" + value; } value += ":" + port.getProtocol(); dockerContainer.getLabels().put("port" + i, value); @@ -182,8 +192,8 @@ private CreateContainerCmd parseContainer(IContainerInfo container) { private IContainerInfo parseContainer(InspectContainerResponse container) { IContainerInfo.IContainerInfoBuilder builder = IContainerInfo.builder(); Map labels = container.getConfig().getLabels(); - builder.id(container.getId()); - builder.host(container.getConfig().getHostName()); + builder.id(container.getName().substring(1)); + builder.host(container.getNetworkSettings().getNetworks().get("bridge").getIpAddress()); builder.image(container.getConfig().getImage()); builder.command(container.getConfig().getCmd()[0]); List args = new ArrayList<>(); @@ -212,9 +222,13 @@ private IContainerInfo parseContainer(InspectContainerResponse container) { builder.binds(binds); builder.volumes(volumes); if (container.getHostConfig().getMounts() != null) { + Map mountInfo = new HashMap<>(); + for (InspectContainerResponse.Mount mount : container.getMounts()) { + mountInfo.put(mount.getDestination().getPath(), mount); + } for (Mount mount : container.getHostConfig().getMounts()) { if (mount.getType() == MountType.BIND) { - binds.add(new IBind(mount.getSource(), mount.getTarget(), mount.getReadOnly())); + binds.add(new IBind(mount.getSource(), mount.getTarget(), !mountInfo.get(mount.getTarget()).getRW())); } else if (mount.getType() == MountType.VOLUME) { String size = mount.getVolumeOptions().getDriverConfig().getOptions().get("size"); volumes.add(new IVolume(mount.getTarget(), Long.parseLong(size))); @@ -244,9 +258,33 @@ private IContainerInfo parseContainer(InspectContainerResponse container) { return builder.build(); } + private List getDockerIds(List ids) throws ISchedulerException { + return getDockerIds(ids, true); + } + + private List getDockerIds(List ids, boolean safe) throws ISchedulerException { + Map map = new HashMap<>(); + List result = new ArrayList<>(); + List containers = dockerClient.listContainersCmd().withNameFilter(ids).exec(); + for (Container c : containers) { + map.put(c.getNames()[0].substring(1), c.getId()); + } + for (String id : ids) { + if (!map.containsKey(id)) { + if (safe){ + throw new ISchedulerException("Container " + id + " not found"); + } + result.add(null); + } else { + result.add(map.get(id)); + } + } + return result; + } + @Override public String createGroup(String name) throws ISchedulerException { - return name + "-" + newId(); + return fixName(name + "-" + newId()); } @Override @@ -257,12 +295,13 @@ public void destroyGroup(String group) throws ISchedulerException { public String createDriverContainer(String group, String name, IContainerInfo container) throws ISchedulerException { try { CreateContainerCmd dockerContainer = parseContainer(container); + dockerContainer.withName(fixName(group + "-" + name)); String[] env = Arrays.copyOf(dockerContainer.getEnv(), dockerContainer.getEnv().length + 2); env[env.length - 2] = "IGNIS_JOB_ID=" + dockerContainer.getName(); env[env.length - 1] = "IGNIS_JOB_NAME=" + group; dockerContainer.withEnv(env); dockerContainer.withEnv(env); - if (path.startsWith("/")) {//Is a Unix-Socket + if (path != null) {//Is a Unix-Socket List mounts = dockerContainer.getHostConfig().getMounts(); Mount mount = new Mount(); mount.withSource(path); @@ -273,7 +312,7 @@ public String createDriverContainer(String group, String name, IContainerInfo co } String id = dockerContainer.exec().getId(); dockerClient.startContainerCmd(id).exec(); - return id; + return dockerContainer.getName(); } catch (DockerException ex) { throw new ISchedulerException(ex.getMessage(), ex); } @@ -282,16 +321,21 @@ public String createDriverContainer(String group, String name, IContainerInfo co @Override public List createExecutorContainers(String group, String name, IContainerInfo container, int instances) throws ISchedulerException { List ids = new ArrayList<>(); + List names = new ArrayList<>(); try { CreateContainerCmd dockerContainer = parseContainer(container); for (int i = 0; i < instances; i++) { - dockerContainer.withName(group + "-" + name + "." + i); + dockerContainer.withName(fixName(group + "-" + name + "." + i)); + names.add(dockerContainer.getName()); ids.add(dockerContainer.exec().getId()); } - return ids; + for (int i = 0; i < instances; i++) { + dockerClient.startContainerCmd(ids.get(i)).exec(); + } + return names; } catch (DockerException ex) { try { - destroyExecutorInstances(ids); + destroyExecutorInstances(names); } catch (ISchedulerException ex2) { } throw new ISchedulerException(ex.getMessage(), ex); @@ -300,31 +344,19 @@ public List createExecutorContainers(String group, String name, IContain @Override public IContainerStatus getStatus(String id) throws ISchedulerException { - try { - List containers = dockerClient.listContainersCmd().withIdFilter(List.of(id)).exec(); - if (containers.isEmpty()) { - return IContainerStatus.DESTROYED; - } - return TASK_STATUS.getOrDefault(containers.get(0).getState(), IContainerStatus.UNKNOWN); - } catch (DockerException ex) { - throw new ISchedulerException(ex.getMessage(), ex); - } + return getStatus(List.of(id)).get(0); } @Override public List getStatus(List ids) throws ISchedulerException { try { List status = new ArrayList<>(); - Map map = new HashMap<>(); - List containers = dockerClient.listContainersCmd().withIdFilter(ids).exec(); - for (Container c : containers) { - map.put(c.getId(), c); - } - for (String id : ids) { - if (!map.containsKey(id)) { + for (String id : getDockerIds(ids, false)) { + if( id == null){ status.add(IContainerStatus.DESTROYED); - } else { - status.add(TASK_STATUS.getOrDefault(map.get(id).getState(), IContainerStatus.UNKNOWN)); + }else { + String s = dockerClient.inspectContainerCmd(id).exec().getState().getStatus(); + status.add(TASK_STATUS.getOrDefault(s, IContainerStatus.UNKNOWN)); } } return status; @@ -335,33 +367,30 @@ public List getStatus(List ids) throws ISchedulerExcep @Override public IContainerInfo getDriverContainer(String id) throws ISchedulerException { - try { - return parseContainer(dockerClient.inspectContainerCmd(id).exec()); - } catch (DockerException ex) { - throw new ISchedulerException(ex.getMessage(), ex); - } + return getExecutorContainers(List.of(id)).get(0); } @Override public List getExecutorContainers(List ids) throws ISchedulerException { List result = new ArrayList<>(); - for (String id : ids) { - result.add(getDriverContainer(id)); + for (String id : getDockerIds(ids)) { + result.add(parseContainer(dockerClient.inspectContainerCmd(id).exec())); } return result; } @Override public IContainerInfo restartContainer(String id) throws ISchedulerException { + String dockerid = getDockerIds(List.of(id)).get(0); try { try { if (getStatus(id) == IContainerStatus.RUNNING) { return getDriverContainer(id); } - dockerClient.stopContainerCmd(id).exec(); + dockerClient.stopContainerCmd(dockerid).exec(); } catch (Exception ignore) { } - dockerClient.startContainerCmd(id).exec(); + dockerClient.startContainerCmd(dockerid).exec(); return getDriverContainer(id); } catch (DockerException ex) { throw new ISchedulerException(ex.getMessage(), ex); @@ -370,23 +399,17 @@ public IContainerInfo restartContainer(String id) throws ISchedulerException { @Override public void destroyDriverContainer(String id) throws ISchedulerException { - try { - dockerClient.removeContainerCmd(id).withForce(true).withRemoveVolumes(true).exec(); - } catch (NotFoundException ex) { - //Ignore - } catch (DockerException ex) { - throw new ISchedulerException(ex.getMessage(), ex); - } + destroyExecutorInstances(List.of(id)); } @Override public void destroyExecutorInstances(List ids) throws ISchedulerException { DockerException error = null; - for (String id : ids) { + for (String id : getDockerIds(ids, false)) { try { - dockerClient.removeContainerCmd(id).withForce(true).withRemoveVolumes(true).exec(); - } catch (NotFoundException ex) { - //Ignore + if(id != null){ + dockerClient.removeContainerCmd(id).withForce(true).withRemoveVolumes(true).exec(); + } } catch (DockerException ex) { error = ex; } diff --git a/scheduler-slurm/build.gradle b/scheduler-slurm/build.gradle index 70912a46..c8aa45f0 100644 --- a/scheduler-slurm/build.gradle +++ b/scheduler-slurm/build.gradle @@ -29,7 +29,7 @@ artifacts { } archivesBaseName = 'ignis-scheduler-slurm' -version = '1.0' +version = '2.1' publishing { publications { maven(MavenPublication) { diff --git a/scheduler-slurm/src/main/java/org/ignis/scheduler/Slurm.java b/scheduler-slurm/src/main/java/org/ignis/scheduler/Slurm.java index db2e9303..ec02f3da 100644 --- a/scheduler-slurm/src/main/java/org/ignis/scheduler/Slurm.java +++ b/scheduler-slurm/src/main/java/org/ignis/scheduler/Slurm.java @@ -94,10 +94,6 @@ private void parseSingulauryContainerArgs(StringBuilder script, IContainerInfo c script.append('\n'); } - private void parseUdockerContainerArgs(StringBuilder script, IContainerInfo c) throws ISchedulerException { - throw new UnsupportedOperationException("Not implemented yet"); - } - private void parseContainerArgs(StringBuilder script, IContainerInfo c, String wd, boolean driver) throws ISchedulerException { String port = c.getSchedulerParams().get("port"); if (port != null) { @@ -132,18 +128,7 @@ private void parseContainerArgs(StringBuilder script, IContainerInfo c, String w script.append("echo 1 > ").append(file).append(".ok\n"); script.append("{\n"); - String platform = c.getSchedulerParams().get("platform"); - if (platform == null) { - throw new ISchedulerException("ignis.scheduler.param.platform not defined"); - } - - if (platform.equalsIgnoreCase("udocker")) { - parseUdockerContainerArgs(script, c); - } else if (platform.equalsIgnoreCase("singularity")) { - parseSingulauryContainerArgs(script, c); - } else { - throw new ISchedulerException("ignis.scheduler.param.platform=" + platform + " is not valid"); - } + parseSingulauryContainerArgs(script, c); script.append("} > ").append(file).append(".out 2> ").append(file).append(".err\n"); } diff --git a/scheduler-slurm/src/main/java/org/ignis/submitter/SlurmSubmit.java b/scheduler-slurm/src/main/java/org/ignis/submitter/SlurmSubmit.java index 87456213..50d6f61a 100644 --- a/scheduler-slurm/src/main/java/org/ignis/submitter/SlurmSubmit.java +++ b/scheduler-slurm/src/main/java/org/ignis/submitter/SlurmSubmit.java @@ -23,6 +23,7 @@ import java.util.*; import java.util.concurrent.Callable; +@CommandLine.Command(version = "2.1") public class SlurmSubmit implements Callable { private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(SlurmSubmit.class); @@ -73,15 +74,15 @@ public Integer call() throws Exception { props.fromEnv(System.getenv()); defaults.load(getClass().getClassLoader().getResourceAsStream("etc/ignis.conf")); - props.setProperty(IKeys.EXECUTOR_IMAGE, "docker://" + defaults.getProperty(IKeys.EXECUTOR_IMAGE)); + defaults.setProperty(IKeys.EXECUTOR_IMAGE, "docker://" + defaults.getProperty(IKeys.EXECUTOR_IMAGE)); try { - File conf = new File("/etc/ignis/ignis.conf"); + File conf = new File(props.getString(IKeys.HOME), "etc/ignis.conf"); if (conf.exists()) { - props.load(conf.getPath()); + defaults.load(conf.getPath()); } conf = new File(System.getProperty("user.home"), ".ignis/ignis.conf"); if (conf.exists()) { - props.load(conf.getPath()); + defaults.load(conf.getPath()); } } catch (IPropertyException | IOException ex) { LOGGER.error("Error loading ignis.conf, ignoring", ex); @@ -156,7 +157,6 @@ public Integer call() throws Exception { * */ private void deployProperties(IProperties props) { props.setProperty(IKeys.DFS_ID, props.getProperty(IKeys.DFS_ID)); - props.setProperty(IKeys.DFS_HOME, props.getProperty(IKeys.DFS_HOME, "/media/dfs")); props.setProperty(IKeys.SCHEDULER_URL, props.getProperty(IKeys.SCHEDULER_URL, "sbatch")); props.setProperty(IKeys.SCHEDULER_TYPE, props.getProperty(IKeys.SCHEDULER_TYPE, "slurm")); if (props.contains(IKeys.REGISTRY)) { @@ -226,7 +226,7 @@ private IContainerInfo parse(IProperties props, boolean driver) throws Exception */ public static void main(String[] args) { CommandLine cli = new CommandLine(new SlurmSubmit()) - .setCommandName("ignis-slurm") + .setCommandName("Dockerfiles/slurm/ignis-slurm") .setUsageHelpAutoWidth(true); int exitCode = cli.execute(args); System.exit(exitCode); diff --git a/scheduler-slurm/src/main/resources/ignis-slurm b/scheduler-slurm/src/main/resources/ignis-slurm deleted file mode 100644 index a4014c0c..00000000 --- a/scheduler-slurm/src/main/resources/ignis-slurm +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -java -cp "ignis-libs/*" org.ignis.submitter.SlurmSubmit "$@" diff --git a/submitter/build.gradle b/submitter/build.gradle index e2bdd96b..c932fc54 100644 --- a/submitter/build.gradle +++ b/submitter/build.gradle @@ -29,7 +29,7 @@ artifacts { } archivesBaseName = 'ignis-submitter' -version = '1.0' +version = '2.1' publishing { publications { maven(MavenPublication) { @@ -56,6 +56,13 @@ dependencies { annotationProcessor group: 'info.picocli', name: 'picocli', version: '4.6.1' } +task defaultConfig(type: Copy, description: 'Copy /etc into resources'){ + from('../etc') + into('build/resources/main/etc') +} + +processResources.dependsOn defaultConfig + task jarAndLibs(type: Copy, description: 'Copy project dependencies.') { dependsOn "jar" delete("$buildDir/jarAndLibs") diff --git a/submitter/src/main/java/org/ignis/submitter/Submit.java b/submitter/src/main/java/org/ignis/submitter/Submit.java index efdcff9e..a858a48b 100644 --- a/submitter/src/main/java/org/ignis/submitter/Submit.java +++ b/submitter/src/main/java/org/ignis/submitter/Submit.java @@ -43,6 +43,7 @@ /** * @author César Pomar */ +@CommandLine.Command(version = "2.1") public class Submit implements Callable { private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(Submit.class); @@ -87,9 +88,16 @@ public Integer call() throws Exception { IProperties props = new IProperties(defaults); props.fromEnv(System.getenv()); + defaults.load(getClass().getClassLoader().getResourceAsStream("etc/ignis.conf")); try { - String conf = new File(props.getString(IKeys.HOME), "etc/ignis.conf").getPath(); - defaults.load(conf); + File conf = new File(props.getString(IKeys.HOME), "etc/ignis.conf"); + if (conf.exists()) { + defaults.load(conf.getPath()); + } + conf = new File(System.getProperty("user.home"), ".ignis/ignis.conf"); + if (conf.exists()) { + defaults.load(conf.getPath()); + } } catch (IPropertyException | IOException ex) { LOGGER.error("Error loading ignis.conf, ignoring", ex); }