Skip to content

Commit f51ef58

Browse files
authored
Merge pull request #130 from stackhpc/feature/partition_params
Support defining any partition parameters
2 parents cc31876 + 1a867b7 commit f51ef58

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

.ansible-lint

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
skip_list:
22
- '106' # Role name {} does not match ``^[a-z][a-z0-9_]+$`` pattern'
3+
- 'fqcn-builtins'

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ package in the image.
5252
* `default`: Optional. A boolean flag for whether this partion is the default. Valid settings are `YES` and `NO`.
5353
* `maxtime`: Optional. A partition-specific time limit in hours, minutes and seconds ([slurm.conf](https://slurm.schedmd.com/slurm.conf.html) parameter `MaxTime`). The default value is
5454
given by `openhpc_job_maxtime`.
55+
* `partition_params`: Optional. Mapping of additional parameters and values for [partition configuration](https://slurm.schedmd.com/slurm.conf.html#SECTION_PARTITION-CONFIGURATION).
5556

5657
For each group (if used) or partition any nodes in an ansible inventory group `<cluster_name>_<group_name>` will be added to the group/partition. Note that:
5758
- Nodes may have arbitrary hostnames but these should be lowercase to avoid a mismatch between inventory and actual hostname.
@@ -64,7 +65,7 @@ For each group (if used) or partition any nodes in an ansible inventory group `<
6465

6566
`openhpc_cluster_name`: name of the cluster
6667

67-
`openhpc_config`: Mapping of additional parameters and values for `slurm.conf`. Note these will override any included in `templates/slurm.conf.j2`.
68+
`openhpc_config`: Optional. Mapping of additional parameters and values for `slurm.conf`. Note these will override any included in `templates/slurm.conf.j2`.
6869

6970
`openhpc_ram_multiplier`: Optional, default `0.95`. Multiplier used in the calculation: `total_memory * openhpc_ram_multiplier` when setting `RealMemory` for the partition in slurm.conf. Can be overriden on a per partition basis using `openhpc_slurm_partitions.ram_multiplier`. Has no effect if `openhpc_slurm_partitions.ram_mb` is set.
7071

filter_plugins/slurm_conf.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,16 @@ def error(condition, msg):
8080
if not condition:
8181
raise errors.AnsibleFilterError(msg)
8282

83+
def dict2parameters(d):
84+
""" Convert a dict into a str in 'k1=v1 k2=v2 ...' format """
85+
parts = ['%s=%s' % (k, v) for k, v in d.items()]
86+
return ' '.join(parts)
87+
8388
class FilterModule(object):
8489

8590
def filters(self):
8691
return {
8792
'hostlist_expression': hostlist_expression,
8893
'error': error,
94+
'dict2parameters': dict2parameters,
8995
}

templates/slurm.conf.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ NodeName={{ hostlist }} State=UNKNOWN RealMemory={{ group.get('ram_mb', ram_mb)
131131
{% set nodelist = ['-nonesuch'] %}
132132
NodeName={{ nodelist[0] }}
133133
{% endif %}
134-
PartitionName={{part.name}} Default={{ part.get('default', 'YES') }} MaxTime={{ part.get('maxtime', openhpc_job_maxtime) }} State=UP Nodes={{ nodelist | join(',') }}
134+
PartitionName={{part.name}} Default={{ part.get('default', 'YES') }} MaxTime={{ part.get('maxtime', openhpc_job_maxtime) }} State=UP Nodes={{ nodelist | join(',') }} {{ part.partition_params | default({}) | dict2parameters }}
135135
{% endfor %}{# partitions #}
136136

137137
# Want nodes that drop out of SLURM's configuration to be automatically

0 commit comments

Comments
 (0)