Skip to content

Commit

Permalink
add missing availability zones (#11)
Browse files Browse the repository at this point in the history
* add missing availability zones
Signed-off-by: vsoch <[email protected]>
  • Loading branch information
vsoch authored Jan 14, 2023
1 parent 94cd5eb commit 5040f49
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
16 changes: 16 additions & 0 deletions fluxcloud/main/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def run_timed(self, name, cmd, cleanup_func=None):
"""
Run a timed command, and handle nonzero exit codes.
"""
logger.debug("\nRunning Timed Command:" + " ".join(cmd))
res = utils.run_command(cmd)

# An optional cleanup function (also can run if not successful)
Expand All @@ -54,6 +55,7 @@ def get_script(self, name, cloud=None):
cloud = cloud or self.name
script = os.path.join(here, "clouds", cloud, "scripts", name)
if os.path.exists(script):
logger.debug(f"Found template script {script}")
return script

def get_shared_script(self, name):
Expand Down Expand Up @@ -81,6 +83,13 @@ def experiment_is_run(self, setup, experiment):
# If all job output files exist, experiment is considered run
for size in minicluster["size"]:

# We can't run if the minicluster > the experiment size
if size > experiment["size"]:
logger.warning(
f"Cluster of size {experiment['size']} cannot handle a MiniCluster of size {size}, not considering."
)
continue

# Jobname is used for output
for jobname, _ in jobs.items():

Expand Down Expand Up @@ -151,6 +160,13 @@ def apply(self, setup, experiment):
# NOTE if this changes here, also check self.experiment_is_run
for size in minicluster["size"]:

# We can't run if the minicluster > the experiment size
if size > experiment["size"]:
logger.warning(
f"Cluster of size {experiment['size']} cannot handle a MiniCluster of size {size}, skipping."
)
continue

# Jobname is used for output
for jobname, job in jobs.items():

Expand Down
8 changes: 7 additions & 1 deletion fluxcloud/main/clouds/aws/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,13 @@ def generate_config(self, setup, experiment):
values["kubernetes_version"] = setup.settings.kubernetes["version"]
values["size"] = setup.get_size(experiment)
values["ssh_key"] = self.settings.aws.get("ssh_key")
values["availability_zones"] = self.settings.aws.get("availability_zones") or []
zones = self.settings.aws.get("availability_zones")

# If we don't have availability zones, provide a and b (min)
if not zones:
zones = ["%sa" % self.region, "%sb" % self.region]

values["availability_zones"] = zones

# All extra custom variables
values["variables"] = experiment.get("variables", {})
Expand Down
2 changes: 1 addition & 1 deletion fluxcloud/main/clouds/aws/templates/cluster-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ metadata:
"{{ tag[0] }}": "{{ tag[1] }}"
{% endfor %}{% endif %}

availabilityZones: [{% for zone in availability_zones %}"{{ zone }}"{% if loop.last %}{% else %}.{% endif %}{% endfor %}]
availabilityZones: [{% for zone in availability_zones %}"{{ zone }}"{% if loop.last %}{% else %}, {% endif %}{% endfor %}]
managedNodeGroups:
- name: workers
instanceType: {{ machine }}
Expand Down

0 comments on commit 5040f49

Please sign in to comment.