Skip to content

Commit 1b4eea2

Browse files
committed
Use systemd timers to trigger updates
1 parent c501d6d commit 1b4eea2

File tree

7 files changed

+20
-11
lines changed

7 files changed

+20
-11
lines changed

cookbooks/aws-parallelcluster-computefleet/files/check_update/check-update.service

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Description=Check for recent file modifications
33

44
[Service]
55
Type=oneshot
6-
ExecStart=/bin/bash -c 'cat /opt/slurm/etc/pcluster/.slurm_plugin/clustermgtd_heartbeat'
6+
ExecStart=/bin/bash -c 'if [ $(( $(date +%%s) - $(stat -c %%Y /home/testfile) )) -lt 60 ]; then /opt/parallelcluster/scripts/cfn-hup-update-action.sh; fi'
77

88
[Install]
99
WantedBy=multi-user.target

cookbooks/aws-parallelcluster-computefleet/recipes/config/config_check_update_systemd_service.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@
1515
# OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions and
1616
# limitations under the License.
1717

18-
cookbook_file '/etc/systemd/system/check-update.service' do
19-
source 'check_update/check-update.service'
18+
template '/etc/systemd/system/check-update.service' do
19+
source 'check_update/check-update.service.erb'
2020
owner 'root'
2121
group 'root'
2222
mode '0644'
23-
action :create
2423
end
2524

2625
cookbook_file '/etc/systemd/system/check-update.timer' do
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[Unit]
2+
Description=Check for recent file modifications
3+
4+
[Service]
5+
Type=oneshot
6+
ExecStart=/bin/bash -c 'if [ $(( $(date +%%s) - $(stat -c %%Y <%= node['cluster']['shared_update_path'] %>) )) -lt 60 ]; then <%= node['cluster']['scripts_dir'] %>/cfn-hup-update-action.sh; fi'
7+
8+
[Install]
9+
WantedBy=multi-user.target

cookbooks/aws-parallelcluster-environment/resources/cfn_hup_configuration.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@
9494
mode '0700'
9595
variables(
9696
monitor_shared_dir: monitor_shared_dir,
97-
launch_template_resource_id: node['cluster']['launch_template_id']
97+
launch_template_resource_id: node['cluster']['launch_template_id'],
98+
update_dir: node['cluster']['shared_update_path']
9899
)
99100
end
100101
end

cookbooks/aws-parallelcluster-environment/templates/cfn_hup_configuration/cfn-hook-update.conf.erb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ triggers=post.update
33
<% case node['cluster']['node_type'] -%>
44
<% when 'HeadNode', 'LoginNode' -%>
55
path=Resources.<%= @launch_template_resource_id %>.Metadata.AWS::CloudFormation::Init
6-
action=PATH=/usr/local/bin:/bin:/usr/bin:/opt/aws/bin; . /etc/parallelcluster/pcluster_cookbook_environment.sh; $CFN_BOOTSTRAP_VIRTUALENV_PATH/cfn-init -v --stack <%= @stack_id %> --resource <%= @launch_template_resource_id %> --configsets update --region <%= @region %> --url <%= @cloudformation_url %> --role <%= @cfn_init_role %>
7-
<% when 'ComputeFleet' -%>
8-
path=Resources.<%= @launch_template_resource_id %>
9-
action=timeout <%= @node_bootstrap_timeout %> <%= @update_hook_script_dir %>/cfn-hup-update-action.sh
6+
action=PATH=/usr/local/bin:/bin:/usr/bin:/opt/aws/bin; . /etc/parallelcluster/pcluster_cookbook_environment.sh; $CFN_BOOTSTRAP_VIRTUALENV_PATH/cfn-init -v --stack <%= @stack_id %> --resource <%= @launch_template_resource_id %> --configsets update --region <%= @region %> --url <%= @cloudformation_url %> --role <%= @cfn_init_role %>; echo "Update triggered at $(date)" >> <%= @update_dir %>
107
<% end %>
118
runas=root

cookbooks/aws-parallelcluster-platform/templates/supervisord/parallelcluster_supervisord.conf.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Generated by Chef for AWS ParallelCluster <%= node['cluster']['node_type'] -%>
22
# Local modifications could be overwritten.
3-
<%# HeadNode, ComputeFleet, LoginNode -%>
4-
<% if @cfnhup_enabled -%>
3+
<% case node['cluster']['node_type'] -%>
4+
<% when 'HeadNode'-%>
55
[program:cfn-hup]
66
command = <%= node['cluster']['scripts_dir']%>/cfn-hup-runner.sh
77
autorestart = true

cookbooks/aws-parallelcluster-shared/attributes/cluster.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
default['cluster']['log_base_dir'] = '/var/log/parallelcluster'
1010
default['cluster']['etc_dir'] = '/etc/parallelcluster'
1111

12+
# Shared file used to manage inplace updates
13+
default['cluster']['shared_update_path'] = "#{node['cluster']['shared_dir']}/check_update"
14+
1215
# Slurm_plugin_dir is used by slurm cookbook and custom_actions recipe
1316
default['cluster']['slurm_plugin_dir'] = "#{node['cluster']['etc_dir']}/slurm_plugin"
1417

0 commit comments

Comments
 (0)