diff --git a/attributes/default.rb b/attributes/default.rb index 543cc2d9..2a62b207 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -26,6 +26,9 @@ default['java']['openjdk_packages'] = [] default['java']['accept_license_agreement'] = false +# better timeout max time +default['java']['timeout'] = 3600 # in seconds + case node['platform_family'] when "windows" default['java']['install_flavor'] = "windows" diff --git a/recipes/openjdk.rb b/recipes/openjdk.rb index b1365da7..5b863bdb 100644 --- a/recipes/openjdk.rb +++ b/recipes/openjdk.rb @@ -19,6 +19,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +BETTER_TIMEOUT = node['java']['timeout'].to_i # TODO: use this + jdk = Opscode::OpenJDK.new(node) java_location = jdk.java_location alternatives_priority = jdk.alternatives_priority @@ -34,11 +36,18 @@ end node['java']['openjdk_packages'].each do |pkg| - package pkg + timeout(7200) do + package pkg do + # Monkey patch default 10mins to 1hour default timeout. Doing this outside doesn't fix it since chef has a recipe compile and copy process. + require 'mixlib/shellout'; module Mixlib; class ShellOut; DEFAULT_READ_TIMEOUT = 7200; end; end + action :install + end + end end if platform_family?('debian', 'rhel', 'fedora') bash 'update-java-alternatives' do + timeout 7200 code <<-EOH.gsub(/^\s+/, '') update-alternatives --install /usr/bin/java java #{java_location} #{alternatives_priority} && \ update-alternatives --set java #{java_location}