Load needed (dynamic) dependencies for provisioners at creation time. #358
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The need for this change was initated with #293 which runs every
instance action in a thread of execution, even in serial mode. The issue
is that on the Mac platform MRI Ruby 1.9 and 2.0 (not confirmed for
2.1), dynamic (i.e. native) code needs to be loaded in the main thread
otherwise causing a "Trace/BPT trap: 5" crash.
References:
For Berkshelf 2.0.x at least, there are multiple transitive dependencies
that could load native code, meaning that
require 'berkshelf'
couldvery well lead to a VM crash if performed in a thread other than main.
This commit pushes library loading code ahead to Provisioner creation
time. In other words, by the time you have a Provisioner object
reference either Berkshelf, Librarian-Chef, or nothing has been required
(assuming a Chef provisioner).
A drawback to this approach is that these dynamic dependencies will be
eagerly loaded when Test Kitchen is booting for trivial CLI commands
such as
kitchen list
andkitchen diagnose
. Further work is needed toensure that
kitchen diagnose
remains viable even in the face of afailure to load these dependencies.
Finally, the loaded version of Berkshelf or Librarian-Chef will be
displayed to the user on INFO for converge action and DEBUG on code
loading for troubleshooting.
Closes #357
/cc @reset, @ivey, @sethvargo