lib/bolt/executor.rb in bolt-2.13.0 vs lib/bolt/executor.rb in bolt-2.14.0
- old
+ new
@@ -32,11 +32,12 @@
attr_reader :noop, :transports
attr_accessor :run_as
def initialize(concurrency = 1,
analytics = Bolt::Analytics::NoopClient.new,
- noop = false)
+ noop = false,
+ modified_concurrency = false)
# lazy-load expensive gem code
require 'concurrent'
@analytics = analytics
@logger = Logging.logger[self]
@@ -62,10 +63,13 @@
Concurrent::ThreadPoolExecutor.new(max_threads: concurrency)
else
Concurrent.global_immediate_executor
end
@logger.debug { "Started with #{concurrency} max thread(s)" }
+
+ @concurrency = concurrency
+ @warn_concurrency = modified_concurrency
end
def transport(transport)
impl = @transports[transport || 'ssh']
raise(Bolt::UnknownTransportError, transport) unless impl
@@ -100,9 +104,18 @@
# This is the main driver of execution on a list of targets. It first
# groups targets by transport, then divides each group into batches as
# defined by the transport. Yields each batch, along with the corresponding
# transport, to the block in turn and returns an array of result promises.
def queue_execute(targets)
+ if @warn_concurrency && targets.length > @concurrency
+ @warn_concurrency = false
+ @logger.warn("The ulimit is low, which may cause file limit issues. Default concurrency has been set to "\
+ "'#{@concurrency}' to mitigate those issues, which may cause Bolt to run slow. "\
+ "Disable this warning by configuring ulimit using 'ulimit -n <limit>' in your shell "\
+ "configuration, or by configuring Bolt's concurrency. "\
+ "See https://puppet.com/docs/bolt/latest/bolt_known_issues.html for details.")
+ end
+
targets.group_by(&:transport).flat_map do |protocol, protocol_targets|
transport = transport(protocol)
report_transport(transport, protocol_targets.count)
transport.batches(protocol_targets).flat_map do |batch|
batch_promises = Array(batch).each_with_object({}) do |target, h|