From 95242cf1ca6a6d116a6157d24c8af79cf5af3621 Mon Sep 17 00:00:00 2001 From: Leo Gallucci Date: Tue, 24 Dec 2013 16:30:21 -0300 Subject: [PATCH 1/2] Better timeout with a default of 3600 seconds --- attributes/default.rb | 3 +++ recipes/openjdk.rb | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) 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..df64f856 100644 --- a/recipes/openjdk.rb +++ b/recipes/openjdk.rb @@ -34,7 +34,9 @@ end node['java']['openjdk_packages'].each do |pkg| - package pkg + timeout(node['java']['timeout'].to_i) do + package pkg + end end if platform_family?('debian', 'rhel', 'fedora') From 03ca7ca363e14825a1c34992b3a92a5d355d30cb Mon Sep 17 00:00:00 2001 From: Leo Gallucci Date: Wed, 25 Dec 2013 20:28:03 -0300 Subject: [PATCH 2/2] I tried anything. Nothing worked. More info https://github.com/opscode/mixlib-shellout/pull/36 --- recipes/openjdk.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/recipes/openjdk.rb b/recipes/openjdk.rb index df64f856..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,13 +36,18 @@ end node['java']['openjdk_packages'].each do |pkg| - timeout(node['java']['timeout'].to_i) do - 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}