Skip to content

Commit 14da1ef

Browse files
committed
(PE-37376) Initialize one JRuby instance first when initializing pool
Puppet may apply a "settings catalog" when it initializes. This will check the filesystem and create any directories specified by settings that do not already exist. This will cause errors if Puppet does need to create directories and is initialized in parallel. To resolve this when priming the pool we now instantiate one instance first before initializing the remaining instances in parallel.
1 parent 23d2d63 commit 14da1ef

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

Diff for: src/clj/puppetlabs/services/jruby_pool_manager/impl/jruby_agents.clj

+9-5
Original file line numberDiff line numberDiff line change
@@ -70,25 +70,29 @@
7070

7171
(schema/defn ^:always-validate
7272
prime-pool!
73-
"Sequentially fill the pool with new JRubyInstances. NOTE: this
74-
function should never be called except by the modify-instance-agent
75-
to create a pool's initial jruby instances."
73+
"Fill the pool with new JRubyInstances. Instantiates the first JRuby (Puppet
74+
will sometimes alter the filesystem on first instantiation) and the remaining
75+
instances in parallel. NOTE: this function should never be called except by
76+
the modify-instance-agent to create a pool's initial jruby instances."
7677
[{:keys [config] :as pool-context} :- jruby-schemas/PoolContext]
7778
(log/debug (format "%s\n%s"
7879
(i18n/trs "Initializing JRubyInstances with the following settings:")
7980
(ks/pprint-to-string config)))
8081
(let [pool (jruby-internal/get-pool pool-context)
8182
creation-service (jruby-internal/get-creation-service pool-context)
8283
total (.remainingCapacity pool)
83-
ids (->> total range (map inc))
84+
[first-id & ids] (->> total range (map inc))
8485
add-instance* (fn [id]
8586
(log/debug (i18n/trs "Priming JRubyInstance {0} of {1}"
8687
id count))
8788
(add-instance pool-context id)
8889
(log/info (i18n/trs "Finished creating JRubyInstance {0} of {1}"
8990
id count)))
91+
initial-task (fn [] (add-instance* first-id))
9092
tasks (for [id ids] (fn [] (add-instance* id)))]
91-
(execute-tasks! tasks creation-service)))
93+
(execute-tasks! [initial-task] creation-service)
94+
(when (seq ids)
95+
(execute-tasks! tasks creation-service))))
9296

9397
(schema/defn ^:always-validate
9498
flush-instance!

0 commit comments

Comments
 (0)