@@ -557,25 +557,30 @@ def retry_on(host, command, opts = {}, &)
557557 retry_interval = option_retry_interval == 0 ? 1 : option_retry_interval
558558 verbose = true . to_s == opts [ :verbose ]
559559
560- log_prefix = host . log_prefix
561- logger . debug "\n #{ log_prefix } #{ Time . new . strftime ( '%H:%M:%S' ) } $ #{ command } "
562- logger . debug " Trying command #{ max_retries } times."
563- logger . debug "." , add_newline : false
564-
565- result = on ( host , command , { :accept_all_exit_codes => true , :silent => !verbose } , &)
566- num_retries = 0
567- until desired_exit_codes . include? ( result . exit_code )
568- sleep retry_interval
569- result = on ( host , command , { :accept_all_exit_codes => true , :silent => !verbose } , &)
570- num_retries += 1
560+ block_opts = { }
561+ block_opts [ :run_in_parallel ] = opts [ :run_in_parallel ] if opts . key? ( :run_in_parallel )
562+
563+ block_on host , block_opts do |single_host |
564+ log_prefix = single_host . log_prefix
565+ logger . debug "\n #{ log_prefix } #{ Time . new . strftime ( '%H:%M:%S' ) } $ #{ command } "
566+ logger . debug " Trying command #{ max_retries } times."
571567 logger . debug "." , add_newline : false
572- if ( num_retries > max_retries )
573- logger . debug " Command \` #{ command } \` failed."
574- fail ( "Command \` #{ command } \` failed." )
568+
569+ result = on ( single_host , command , { :accept_all_exit_codes => true , :silent => !verbose } , &)
570+ num_retries = 0
571+ until desired_exit_codes . include? ( result . exit_code )
572+ sleep retry_interval
573+ result = on ( single_host , command , { :accept_all_exit_codes => true , :silent => !verbose } , &)
574+ num_retries += 1
575+ logger . debug "." , add_newline : false
576+ if ( num_retries > max_retries )
577+ logger . debug " Command \` #{ command } \` failed."
578+ fail ( "Command \` #{ command } \` failed." )
579+ end
575580 end
581+ logger . debug "\n #{ log_prefix } #{ Time . new . strftime ( '%H:%M:%S' ) } $ #{ command } ostensibly successful."
582+ result
576583 end
577- logger . debug "\n #{ log_prefix } #{ Time . new . strftime ( '%H:%M:%S' ) } $ #{ command } ostensibly successful."
578- result
579584 end
580585
581586 # FIX: this should be moved into host/platform
0 commit comments