Skip to content

Commit 842b2c8

Browse files
author
Katyal
committed
increasing termination max wait time for child thread to 2 hours
cr https://code.amazon.com/reviews/CR-1318207
1 parent 1ef74b5 commit 842b2c8

File tree

4 files changed

+7
-9
lines changed

4 files changed

+7
-9
lines changed

lib/instance_agent/config.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def initialize
3131
:wait_between_runs => 30,
3232
:wait_after_error => 30,
3333
:codedeploy_test_profile => 'prod',
34+
:kill_agent_max_wait_time_seconds => 7200,
3435
:on_premises_config_file => '/etc/codedeploy-agent/conf/codedeploy.onpremises.yml',
3536
:proxy_uri => nil,
3637
:enable_deployments_log => true

lib/instance_agent/plugins/codedeploy/command_poller.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ class CommandPoller < InstanceAgent::Agent::Base
2323
"AfterAllowTraffic"=>["AfterAllowTraffic"],
2424
"ValidateService"=>["ValidateService"]}
2525

26-
WAIT_FOR_ALL_THREADS_TIMEOUT_SECONDS = 60 * 60 # One hour timeout in seconds
27-
2826
def initialize
2927
test_profile = InstanceAgent::Config.config[:codedeploy_test_profile]
3028
unless ["beta", "gamma"].include?(test_profile.downcase)
@@ -89,12 +87,12 @@ def perform
8987
end
9088

9189
def graceful_shutdown
92-
log(:info, "Gracefully shutting down agent child threads now, will wait up to #{WAIT_FOR_ALL_THREADS_TIMEOUT_SECONDS} seconds")
90+
log(:info, "Gracefully shutting down agent child threads now, will wait up to #{ProcessManager::Config.config[:kill_agent_max_wait_time_seconds]} seconds")
9391
# tell the pool to shutdown in an orderly fashion, allowing in progress work to complete
9492
@thread_pool.shutdown
9593
# now wait for all work to complete, wait till the timeout value
9694
# TODO: Make the timeout configurable in the agent configuration
97-
@thread_pool.wait_for_termination WAIT_FOR_ALL_THREADS_TIMEOUT_SECONDS
95+
@thread_pool.wait_for_termination ProcessManager::Config.config[:kill_agent_max_wait_time_seconds]
9896
log(:info, 'All agent child threads have been shut down')
9997
end
10098

lib/instance_agent/runner/master.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ module InstanceAgent
66
module Runner
77
class Master < ProcessManager::Daemon::Master
88

9-
ChildTerminationMaxWaitTime = 80
10-
119
def self.description(pid = $$)
1210
"master #{pid}"
1311
end
@@ -40,7 +38,7 @@ def stop
4038
end
4139

4240
begin
43-
Timeout.timeout(ChildTerminationMaxWaitTime) do
41+
Timeout.timeout(ProcessManager::Config.config[:kill_agent_max_wait_time_seconds]) do
4442
loop do
4543
begin
4644
Process.kill(0, pid)
@@ -68,7 +66,7 @@ def kill_children(sig)
6866
end
6967

7068
begin
71-
Timeout.timeout(ChildTerminationMaxWaitTime) do
69+
Timeout.timeout(ProcessManager::Config.config[:kill_agent_max_wait_time_seconds]) do
7270
children.each do |index, child_pid|
7371
begin
7472
Process.wait(child_pid)

test/instance_agent/config_test.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ class InstanceAgentConfigTest < InstanceAgentTestCase
2929
:codedeploy_test_profile => 'prod',
3030
:on_premises_config_file => '/etc/codedeploy-agent/conf/codedeploy.onpremises.yml',
3131
:proxy_uri => nil,
32-
:enable_deployments_log => true
32+
:enable_deployments_log => true,
33+
:kill_agent_max_wait_time_seconds => 7200
3334
}, InstanceAgent::Config.config)
3435
end
3536

0 commit comments

Comments
 (0)