Skip to content

Commit

Permalink
Timing out cfn-hup if it hangs (#2807)
Browse files Browse the repository at this point in the history
Co-authored-by: Himani Deshpande <himanidp@amazon.com>
  • Loading branch information
himani2411 and Himani Deshpande committed Sep 16, 2024
1 parent 34b4b9d commit 13a71b4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,6 @@
owner 'root'
group 'root'
mode '0744'
variables(cfn_bootstrap_virtualenv_path: virtualenv_path)
variables(cfn_bootstrap_virtualenv_path: virtualenv_path,
node_bootstrap_timeout: node['cluster']['compute_node_bootstrap_timeout'] || node['cluster']['Timeout'])
end
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
cached(:python_version) { '3.9.20' }
cached(:system_pyenv_root) { 'system_pyenv_root' }
cached(:virtualenv_path) { "system_pyenv_root/versions/#{python_version}/envs/cfn_bootstrap_virtualenv" }
cached(:timeout) { 1800 }

context "when cfn_bootstrap virtualenv not installed yet" do
cached(:chef_run) do
runner = runner(platform: platform, version: version) do |node|
node.override['cluster']['system_pyenv_root'] = system_pyenv_root
node.override['cluster']['region'] = 'non_china'
node.override['cluster']['compute_node_bootstrap_timeout'] = timeout
end
runner.converge(described_recipe)
end
Expand Down Expand Up @@ -79,7 +81,7 @@
owner: 'root',
group: 'root',
mode: '0744',
variables: { cfn_bootstrap_virtualenv_path: virtualenv_path }
variables: { cfn_bootstrap_virtualenv_path: virtualenv_path, node_bootstrap_timeout: timeout }
)
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
set -ex
set -x

# This script is used to run cfn-hup is a way that is suitable to be managed by supervisord.
# In particular, cfn-hup is executed in no-daemon mode.
Expand All @@ -9,6 +9,6 @@ set -ex
[ -f /etc/profile.d/proxy.sh ] && . /etc/profile.d/proxy.sh

while true; do
<%= @cfn_bootstrap_virtualenv_path %>/bin/cfn-hup --no-daemon --verbose
timeout <%= @node_bootstrap_timeout %> <%= @cfn_bootstrap_virtualenv_path %>/bin/cfn-hup --no-daemon --verbose
sleep 60
done

0 comments on commit 13a71b4

Please sign in to comment.