Skip to content

Commit 65ace85

Browse files
committed
Fix :max_revision config bug
1 parent 36edf68 commit 65ace85

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

conf/codedeployagent.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@
66
:root_dir: '/opt/codedeploy-agent/deployment-root'
77
:verbose: false
88
:wait_between_runs: 1
9-
:proxy_uri:
9+
:proxy_uri:
10+
:max_revisions: 5

lib/instance_agent/plugins/codedeploy/command_executor.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def initialize(options = {})
2929
begin
3030
max_revisions = ProcessManager::Config.config[:max_revisions]
3131
@archives_to_retain = max_revisions.nil?? ARCHIVES_TO_RETAIN : Integer(max_revisions)
32-
if @archives_to_retain < 0
32+
if @archives_to_retain < 1
3333
raise ArgumentError
3434
end
3535
rescue ArgumentError
@@ -68,7 +68,7 @@ def command_method(command_name)
6868
end
6969

7070
command "DownloadBundle" do |cmd, deployment_spec|
71-
cleanup_old_archives(deployment_spec.deployment_group_id)
71+
cleanup_old_archives(deployment_spec)
7272
log(:debug, "Executing DownloadBundle command for execution #{cmd.deployment_execution_id}")
7373

7474
case deployment_spec.revision_source
@@ -336,15 +336,17 @@ def update_last_successful_install(deployment_spec)
336336
end
337337

338338
private
339-
def cleanup_old_archives(deployment_group)
339+
def cleanup_old_archives(deployment_spec)
340+
deployment_group = deployment_spec.deployment_group_id
340341
deployment_archives = Dir.entries(File.join(ProcessManager::Config.config[:root_dir], deployment_group))
341342
# remove . and ..
342343
deployment_archives.delete(".")
343344
deployment_archives.delete("..")
344345

345346
full_path_deployment_archives = deployment_archives.map{ |f| File.join(ProcessManager::Config.config[:root_dir], deployment_group, f)}
347+
full_path_deployment_archives.delete(deployment_root_dir(deployment_spec))
346348

347-
extra = full_path_deployment_archives.size - @archives_to_retain
349+
extra = full_path_deployment_archives.size - @archives_to_retain + 1
348350
return unless extra > 0
349351

350352
# Never remove the last successful deployment

0 commit comments

Comments
 (0)