Skip to content

Commit

Permalink
cli: check shared storage for multi-node clusters
Browse files Browse the repository at this point in the history
Signed-off-by: Tibor Šimko <tibor.simko@cern.ch>
  • Loading branch information
tiborsimko committed Jul 2, 2020
1 parent c4d6464 commit bf04dcf
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion reana/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2147,6 +2147,7 @@ def cluster_create(mounts, debug, worker_nodes): # noqa: D301
-m /usr/share/local/mydata:/mydata
--debug
"""
import sys

class literal_str(str):
pass
Expand All @@ -2155,7 +2156,7 @@ def literal_unicode_str(dumper, data):
return dumper.represent_scalar("tag:yaml.org,2002:str", data, style="|")

def add_volume_mounts(node):
"""Add needed volumen mounts to the provided node."""
"""Add needed volumes mounts to the provided node."""

yaml.add_representer(literal_str, literal_unicode_str)

Expand Down Expand Up @@ -2184,6 +2185,20 @@ def add_volume_mounts(node):
]
)

# check whether we mount shared volume for multi-node deployments:
if worker_nodes > 0:
mount_targets = [x["containerPath"].strip("/") for x in mounts]
if "var/reana" in mount_targets or "var" in mount_targets:
pass
else:
click.echo(
"[ERROR] For multi-node deployments, one has to use a shared storage volume for cluster nodes."
)
click.echo(
"[ERROR] Example: reana-dev cluster-create -m /var/reana:/var/reana --worker-nodes 2."
)
sys.exit(1)

nodes = [{"role": "worker"} for _ in range(worker_nodes)] + [control_plane]
for node in nodes:
node["extraMounts"] = mounts
Expand Down

0 comments on commit bf04dcf

Please sign in to comment.