Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion roles/facts/files/memory.fact
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
#!/bin/bash
echo "{ \"total_mb\": $(free -m | grep Mem: | awk '{print $2*0.95}') }"
# printf "%d" keeps the value an integer regardless of locale: the default
# awk print emits a float whose decimal separator follows LC_NUMERIC, which
# on comma-decimal locales produces invalid JSON and breaks the local fact.
echo "{ \"total_mb\": $(free -m | awk '/^Mem:/ {printf "%d", $2*0.95}') }"
4 changes: 4 additions & 0 deletions roles/slurm/templates/etc/slurm/slurm.conf
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ GresTypes=gpu
{% endif %}
{% for node_name in groups['slurm-node'] %}
{% set memory = hostvars[node_name]["ansible_local"]["memory"] -%}
{# If the custom fact failed JSON parsing Ansible hands us a string;
parse it here so a bad fact fails loudly instead of with an opaque
attribute error on total_mb. -#}
{% if memory is string %}{% set memory = memory | from_json -%}{% endif -%}
{% set cpu_topology = hostvars[node_name]["ansible_local"]["topology"]["cpu_topology"] -%}
{% set gpu_topology = hostvars[node_name]["ansible_local"]["topology"]["gpu_topology"] -%}
NodeName={{ node_name }}{{ " " -}}
Expand Down
Loading