@@ -429,14 +429,11 @@ def gather_facts(log, starttime)
429429 err ( '110' , 'os_patching/zypper_params' , 'Unsafe content in zypper_params' , starttime )
430430end
431431# Set the timeout for the patch run
432- if params [ 'timeout' ]
433- if params [ 'timeout' ] > 0
434- timeout = params [ 'timeout' ]
435- else
436- err ( '121' , 'os_patching/timeout' , "timeout set to #{ timeout } seconds - invalid" , starttime )
437- end
432+
433+ if params [ 'timeout' ] . positive?
434+ timeout = params [ 'timeout' ]
438435else
439- timeout = 3600
436+ err ( '121' , 'os_patching/ timeout' , "timeout set to #{ timeout } seconds - invalid" , starttime )
440437end
441438
442439# Is the patching blocker flag set?
@@ -573,8 +570,6 @@ def gather_facts(log, starttime)
573570 log . info 'Patching complete'
574571elsif os [ 'family' ] == 'Debian'
575572 # Are we doing security only patching?
576- apt_mode = ''
577- pkg_list = [ ]
578573 if security_only == true
579574 pkg_list = os_patching [ 'security_package_updates' ]
580575 apt_mode = 'install ' + pkg_list . join ( ' ' )
@@ -587,8 +582,8 @@ def gather_facts(log, starttime)
587582 log . debug "Running apt #{ apt_mode } "
588583 deb_front = 'DEBIAN_FRONTEND=noninteractive'
589584 deb_opts = '-o Apt::Get::Purge=false -o Dpkg::Options::=--force-confold -o Dpkg::Options::=--force-confdef --no-install-recommends'
590- apt_std_out , stderr , status = Open3 . capture3 ( "#{ deb_front } apt-get #{ dpkg_params } -y #{ deb_opts } #{ apt_mode } " )
591- err ( status , 'os_patching/apt' , stderr , starttime ) if status != 0
585+ apt_std_out , status = run_with_timeout ( "#{ deb_front } apt-get #{ dpkg_params } -y #{ deb_opts } #{ apt_mode } " , timeout , 2 )
586+ err ( status , 'os_patching/apt' , apt_std_out , starttime ) if status != 0
592587
593588 output ( 'Success' , reboot , security_only , 'Patching complete' , pkg_list , apt_std_out , '' , pinned_pkgs , starttime , log )
594589 log . info 'Patching complete'
0 commit comments