Skip to content

[Improvement] Run static fleet checks only if there are static nodes #2960

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 10 commits into from
Closed
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
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
#!/bin/bash

sinfo_output=$(<%= node['cluster']['slurm']['install_dir'] %>/bin/sinfo -h -o '%N %t' | grep -v -E '(idle|alloc|mix|maint)$')
while IFS= read -r line; do
nodelist=$(echo "$line" | awk '{print $1}')
<%= node['cluster']['slurm']['install_dir'] %>/bin/scontrol show hostnames "$nodelist" | { grep -E '^[a-z0-9\-]+\-st\-[a-z0-9\-]+\-[0-9]+.*' || true; }
done <<< "$sinfo_output"


cluster_static_node_count=$1
if [[ -z "$cluster_static_node_count" ]]; then
cluster_static_node_count=1
fi

if [[ "$cluster_static_node_count" -ge "1" ]]; then
sinfo_output=$(<%= node['cluster']['slurm']['install_dir'] %>/bin/sinfo -h -o '%N %t' | grep -v -E '(idle|alloc|mix|maint)$')
while IFS= read -r line; do
nodelist=$(echo "$line" | awk '{print $1}')
<%= node['cluster']['slurm']['install_dir'] %>/bin/scontrol show hostnames "$nodelist" | { grep -E '^[a-z0-9\-]+\-st\-[a-z0-9\-]+\-[0-9]+.*' || true; }
done <<< "$sinfo_output"
fi
21 changes: 20 additions & 1 deletion cookbooks/aws-parallelcluster-slurm/libraries/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,21 @@ def wait_cluster_ready
end
end

def get_static_node_count
require 'yaml'
cluster_config = YAML.safe_load(File.read(node['cluster']['cluster_config_path']))
total_min_count = 0
slurm_queues_section = cluster_config.dig("Scheduling", "SlurmQueues")
if slurm_queues_section
slurm_queues_section.each do |queue_config|
queue_config['ComputeResources'].each do |compute_resource_config|
total_min_count += compute_resource_config['MinCount'].to_i
end
end
end
total_min_count
end

def wait_static_fleet_running
ruby_block "wait for static fleet capacity" do
block do
Expand All @@ -203,11 +218,15 @@ def check_for_protected_mode(fleet_status_command) # rubocop:disable Lint/Nested
fleet_status_command = Shellwords.escape(
"/usr/local/bin/get-compute-fleet-status.sh"
)

total_static_node_count = get_static_node_count
Chef::Log.info("Count of cluster static nodes is #{total_static_node_count}")

# Example output for sinfo
# sinfo -h -o '%N %t'
# queue-0-dy-compute-resource-g4dn-0-[1-10],queue-1-dy-compute-resource-g4dn-1-[1-10] idle~
# queue-2-dy-compute-resource-g4dn-2-[1-10],queue-3-dy-compute-resource-g4dn-3-[1-10] idle
until shell_out!("/bin/bash -c /usr/local/bin/is_fleet_ready.sh").stdout.strip.empty?
until shell_out!("/bin/bash /usr/local/bin/is_fleet_ready.sh #{total_static_node_count}").stdout.strip.empty?
check_for_protected_mode(fleet_status_command)

Chef::Log.info("Waiting for static fleet capacity provisioning")
Expand Down
Loading