Skip to content

Commit

Permalink
Merge pull request #169 from cwjohnston/retry
Browse files Browse the repository at this point in the history
Add retries and retry_delay parameters to java_ark LWRP
  • Loading branch information
carmstrong committed Apr 22, 2014
2 parents 138b6ba + 7c71f05 commit 824df4e
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ driver:

provisioner:
name: chef_solo
attributes:
java:
ark_retries: 2
ark_retry_delay: 10

platforms:
- name: ubuntu-13.10
Expand Down
4 changes: 4 additions & 0 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
default['java']['accept_license_agreement'] = false
default['java']['set_default'] = true

# the following retry parameters apply when downloading oracle java
default['java']['ark_retries'] = 0
default['java']['ark_retry_delay'] = 2

case node['platform_family']
when "windows"
default['java']['install_flavor'] = "windows"
Expand Down
4 changes: 3 additions & 1 deletion providers/ark.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def download_direct_from_oracle(tarball_name, new_resource)
converge_by(description) do
Chef::Log.debug "downloading oracle tarball straight from the source"
cmd = shell_out!(
%Q[ curl --create-dirs -L --cookie "#{cookie}" #{new_resource.url} -o #{download_path} ]
%Q[ curl --create-dirs -L --retry #{new_resource.retries} --retry-delay #{new_resource.retry_delay} --cookie "#{cookie}" #{new_resource.url} -o #{download_path} ]
)
end
else
Expand Down Expand Up @@ -123,6 +123,8 @@ def download_direct_from_oracle(tarball_name, new_resource)
r = remote_file "#{Chef::Config[:file_cache_path]}/#{tarball_name}" do
source new_resource.url
checksum new_resource.checksum
retries new_resource.retries
retry_delay new_resource.retry_delay
mode 0755
action :nothing
end
Expand Down
2 changes: 2 additions & 0 deletions recipes/oracle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
app_home java_home
bin_cmds bin_cmds
alternatives_priority 1062
retries node['java']['ark_retries']
retry_delay node['java']['ark_retry_delay']
action :install
end

Expand Down
2 changes: 2 additions & 0 deletions recipes/oracle_i386.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
checksum tarball_checksum
app_home java_home
bin_cmds bin_cmds
retries node['java']['ark_retries']
retry_delay node['java']['ark_retries']
action :install
default false
end
Expand Down
2 changes: 2 additions & 0 deletions resources/ark.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
attribute :owner, :default => "root"
attribute :default, :equal_to => [true, false], :default => true
attribute :alternatives_priority, :kind_of => Integer, :default => 1
attribute :retries, :kind_of => Integer, :default => 0
attribute :retry_delay, :kind_of => Integer, :default => 2

# we have to set default for the supports attribute
# in initializer since it is a 'reserved' attribute name
Expand Down

0 comments on commit 824df4e

Please sign in to comment.