Skip to content

Commit

Permalink
Fix database naming for slurm clusters (#280)
Browse files Browse the repository at this point in the history
DB name needs to be escaped differently from clusternames
because db names cannot have "-" as mysql rejects it.
  • Loading branch information
aditigaur4 authored Sep 23, 2024
1 parent 8ce9684 commit 4aed268
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions slurm/install/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,18 @@ def __init__(self, config: Dict, platform_family: str, mode: str) -> None:
# We use a "safe" form of the CycleCloud ClusterName
# First we lowercase the cluster name, then replace anything
# that is not letters, digits and '-' with a '-'
# eg My Cluster == my-cluster
# eg My Cluster == my-cluster.
# This is needed because cluster names are used to create hostnames
# hostname conventions do not allow underscores and spaces
# https://en.wikipedia.org/wiki/Hostname#Restrictions_on_valid_host_names.
# Since this PR: https://github.com/Azure/cyclecloud-slurm/pull/241 we now have
# to use cluster name to create a database name if one is not provided. But database naming
# conventions conflict witn hostname naming conventions and it cannot contain "-" hyphens.
# For now we use a second sanitized cluster name that derives from the escaped cluster name
# but converts all hyphens to underscores.
self.slurm_cluster_name = _escape(self.cyclecloud_cluster_name)
self.slurm_db_cluster_name = re.sub(r'-', '_', self.slurm_cluster_name)

self.node_name = config["node_name"]
self.hostname = config["hostname"]
self.ipv4 = config["ipaddress"]
Expand Down Expand Up @@ -293,7 +303,7 @@ def _accounting_primary(s: InstallSettings) -> None:
if s.acct_cert_url
else "#StorageParameters=",
"slurmver": s.slurmver,
"storageloc": s.acct_storageloc or f"{s.slurm_cluster_name}_acct_db",
"storageloc": s.acct_storageloc or f"{s.slurm_db_cluster_name}_acct_db",
},
)

Expand Down

0 comments on commit 4aed268

Please sign in to comment.