Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warnings about conflicting chdir during berks install #28

Closed
stevenoneill opened this issue Aug 2, 2018 · 1 comment
Closed

Warnings about conflicting chdir during berks install #28

stevenoneill opened this issue Aug 2, 2018 · 1 comment

Comments

@stevenoneill
Copy link
Contributor

Version:

0.4.6 via chefdk

Environment:

Windows 10, git-bash, chefdk 3.1.0 or 3.2.2

Scenario:

After running berks install, cookbooks end up in a 'weird' state. For instance, one or more cookbook dirs may get created into the local directory:

$ rm -rf ~/.berkshelf/cookbooks/ Berksfile.lock && berks install
Resolving cookbook dependencies...
Fetching 'something' from source at .
Fetching 'test' from source at test/cookbooks/test
Fetching cookbook index from https://supermarket.myorg.com...
Installing ark (3.1.0) from https://supermarket.myorg.com ([opscode] https://supermarket.myorg.com:443/api/v1)
Installing chocolatey (2.0.0) from https://supermarket.myorg.com ([opscode] https://supermarket.myorg.com:443/api/v1)
Installing build-essential (8.0.0) from https://supermarket.myorg.com ([opscode] https://supermarket.myorg.com:443/api/v1)
C:/opscode/chefdk/embedded/lib/ruby/gems/2.5.0/gems/mixlib-archive-0.4.6/lib/mixlib/archive/lib_archive.rb:29: warning: conflicting chdir during another chdir block
C:/opscode/chefdk/embedded/lib/ruby/gems/2.5.0/gems/mixlib-archive-0.4.6/lib/mixlib/archive/lib_archive.rb:29: warning: conflicting chdir during another chdir block
Installing compat_resource (12.16.3) from https://supermarket.myorg.com ([opscode] https://supermarket.myorg.com:443/api/v1)
Installing consul (3.1.100) from https://supermarket.myorg.com ([opscode] https://supermarket.myorg.com:443/api/v1)
$ ll
total 33
drwxr-xr-x 1 user 1049089    0 Aug  2 09:28 ark/   # <= unexpected !
drwxr-xr-x 1 user 1049089    0 Jul 20 17:38 attributes/
-rw-r--r-- 1 user 1049089  128 Jul 20 17:38 Berksfile
-rw-r--r-- 1 user 1049089 1020 Jul 20 17:38 CHANGELOG.md
-rw-r--r-- 1 user 1049089 1133 Jul 20 17:38 chefignore
-rw-r--r-- 1 user 1049089 3563 Jul 20 17:38 kitchen.yml
drwxr-xr-x 1 user 1049089    0 Jul 20 17:38 libraries/
-rw-r--r-- 1 user 1049089 1017 Jul 20 17:38 metadata.rb
-rw-r--r-- 1 user 1049089 3704 Jul 20 17:38 README.md
drwxr-xr-x 1 user 1049089    0 Jul 20 17:38 recipes/
drwxr-xr-x 1 user 1049089    0 Jul 20 17:38 resources/
drwxr-xr-x 1 user 1049089    0 Jul 20 17:38 templates/
drwxr-xr-x 1 user 1049089    0 Jul 20 17:38 test/
drwxr-xr-x 1 user 1049089    0 Jul 20 17:38 user_data/

Steps to Reproduce:

chefdk 3.1.0, windows, git-bash, and a cookbook with many deps

from a cookbook directory, try: rm -rf ~/.berkshelf/cookbooks Berksfile.lock && berks install

Expected Result:

Expecting no warnings or errors and expecting no misplaced cookbook directories.

Actual Result:

Blank cookbook dirs may be created in local dir. Warning messages produced about conflicting chdir.

@stevenoneill
Copy link
Contributor Author

stevenoneill commented Aug 2, 2018

Following warning to code at:
https://github.com/chef/mixlib-archive/blob/master/lib/mixlib/archive/lib_archive.rb#L23

Coupled with another recent issue like:
test-kitchen/test-kitchen#1416

Thinking maybe the threadsafeness issue applies here.

After applying a monkeypatch like:

    class LibArchive
      attr_reader :options
      attr_reader :archive
	  
	  class << self
		attr_accessor :mutex_chdir
	  end
	  
	  Mixlib::Archive::LibArchive.mutex_chdir = Mutex.new

<...>

	Mixlib::Archive::LibArchive.mutex_chdir.synchronize do
          Dir.chdir(destination) do
            reader = ::Archive::Reader.open_filename(@archive)
		  

....the issue goes away.

Should I attempt a PR for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant