From d4a18d464072639633162d49839c8d57e3c76739 Mon Sep 17 00:00:00 2001 From: Xuanqi He Date: Mon, 9 Oct 2023 00:51:51 -0400 Subject: [PATCH] Address comments --- .../config_check_login_stopped_script.rb | 27 +++++++++++++++++++ .../recipes/config/config_head_node.rb | 16 +---------- .../recipes/update/update_head_node.rb | 18 ++----------- 3 files changed, 30 insertions(+), 31 deletions(-) create mode 100644 cookbooks/aws-parallelcluster-slurm/recipes/config/config_check_login_stopped_script.rb diff --git a/cookbooks/aws-parallelcluster-slurm/recipes/config/config_check_login_stopped_script.rb b/cookbooks/aws-parallelcluster-slurm/recipes/config/config_check_login_stopped_script.rb new file mode 100644 index 0000000000..47d600ba27 --- /dev/null +++ b/cookbooks/aws-parallelcluster-slurm/recipes/config/config_check_login_stopped_script.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +# Copyright:: 2013-2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the +# License. A copy of the License is located at +# +# http://aws.amazon.com/apache2.0/ +# +# or in the "LICENSE.txt" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES +# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions and +# limitations under the License. +# rubocop:disable Style/SingleArgumentDig +template "#{node['cluster']['scripts_dir']}/slurm/check_login_nodes_stopped.sh" do + source 'slurm/head_node/check_login_nodes_stopped.sh.erb' + owner 'root' + group 'root' + mode '0700' + variables( + cluster_name: node['cluster']['cluster_name'] || node['cluster']['stack_name'], + login_nodes_pool_name: lazy { node['cluster']['config'].dig(:LoginNodes, :Pools, 0, :Name) }, + region: node['cluster']['region'] + ) + only_if do + node['cluster']['config'].dig(:LoginNodes) + end +end diff --git a/cookbooks/aws-parallelcluster-slurm/recipes/config/config_head_node.rb b/cookbooks/aws-parallelcluster-slurm/recipes/config/config_head_node.rb index 08022852f8..37414cdcbf 100644 --- a/cookbooks/aws-parallelcluster-slurm/recipes/config/config_head_node.rb +++ b/cookbooks/aws-parallelcluster-slurm/recipes/config/config_head_node.rb @@ -14,7 +14,6 @@ # or in the "LICENSE.txt" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES # OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions and # limitations under the License. -# rubocop:disable Style/SingleArgumentDig include_recipe 'aws-parallelcluster-slurm::config_munge_key' @@ -283,20 +282,7 @@ retry_delay 2 end unless redhat_on_docker? -template "#{node['cluster']['scripts_dir']}/slurm/check_login_nodes_stopped.sh" do - source 'slurm/head_node/check_login_nodes_stopped.sh.erb' - owner 'root' - group 'root' - mode '0700' - variables( - cluster_name: node['cluster']['cluster_name'] || node['cluster']['stack_name'], - login_nodes_pool_name: lazy { node['cluster']['config'].dig(:LoginNodes, :Pools, 0, :Name) }, - region: node['cluster']['region'] - ) - only_if do - node['cluster']['config'].dig(:LoginNodes) - end -end +include_recipe 'aws-parallelcluster-slurm::config_check_login_stopped_script' template "#{node['cluster']['scripts_dir']}/slurm/update_munge_key.sh" do source 'slurm/head_node/update_munge_key.sh.erb' diff --git a/cookbooks/aws-parallelcluster-slurm/recipes/update/update_head_node.rb b/cookbooks/aws-parallelcluster-slurm/recipes/update/update_head_node.rb index 324d89fb09..dec1b9689c 100644 --- a/cookbooks/aws-parallelcluster-slurm/recipes/update/update_head_node.rb +++ b/cookbooks/aws-parallelcluster-slurm/recipes/update/update_head_node.rb @@ -14,7 +14,6 @@ # or in the "LICENSE.txt" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES # OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions and # limitations under the License. -# rubocop:disable Style/SingleArgumentDig execute 'stop clustermgtd' do command "#{cookbook_virtualenv_path}/bin/supervisorctl stop clustermgtd" @@ -203,21 +202,8 @@ def update_nodes_in_queue(strategy, queues) end unless on_docker? # Update check login nodes status script to update pool name -template "#{node['cluster']['scripts_dir']}/slurm/check_login_nodes_stopped.sh" do - source 'slurm/head_node/check_login_nodes_stopped.sh.erb' - owner 'root' - group 'root' - mode '0700' - variables( - cluster_name: node['cluster']['cluster_name'] || node['cluster']['stack_name'], - login_nodes_pool_name: lazy { node['cluster']['config'].dig(:LoginNodes, :Pools, 0, :Name) }, - region: node['cluster']['region'] - ) - only_if do - node['cluster']['config'].dig(:LoginNodes) && - ::File.exist?(node['cluster']['previous_cluster_config_path']) && - is_login_nodes_pool_name_updated? - end +if ::File.exist?(node['cluster']['previous_cluster_config_path']) && is_login_nodes_pool_name_updated? + include_recipe 'aws-parallelcluster-slurm::config_check_login_stopped_script' end file "#{node['cluster']['scripts_dir']}/slurm/check_login_nodes_stopped.sh" do