Skip to content
This repository was archived by the owner on Jul 14, 2021. It is now read-only.

knife and berks create many temp directories #133

Closed
andrewjamesbrown opened this issue Aug 12, 2014 · 9 comments
Closed

knife and berks create many temp directories #133

andrewjamesbrown opened this issue Aug 12, 2014 · 9 comments

Comments

@andrewjamesbrown
Copy link

Issue is related to berkshelf/ridley#262 and affects both ChefDK 0.1.0 and 0.2.0. knife and berks command creates temporary directories in /tmp of the form dYYYYMMDD-$PID-$RANDOM.

Strace confirms that knife.rb or config.json is not being read prior to temporary directories being created.

mkdir("/tmp/d20140812-4197-hxzi9e", 0700) = 0
mkdir("/tmp/d20140812-4197-15hpi32", 0700) = 0
stat("/home/local/knife.rb", 0x7fff317f7090) = -1 ENOENT (No such file or directory)
stat("/home/local/.chef/knife.rb", {st_mode=S_IFREG|0644, st_size=58, ...}) = 0
stat("/home/local/.chef/knife.rb", {st_mode=S_IFREG|0644, st_size=58, ...}) = 0
open("/home/local/.chef/knife.rb", O_RDONLY|O_CLOEXEC) = 7
stat("./.berkshelf/config.json", 0x7fff317f8a30) = -1 ENOENT (No such file or directory)
stat("/home/local/.berkshelf/config.json", 0x7fff317f8a30) = -1 ENOENT (No such file or directory)
stat("./.berkshelf/config.json", 0x7fff317f8410) = -1 ENOENT (No such file or directory)
@poliva83
Copy link

The root cause seems to be with Ridley configuration berkshelf/ridley#262 but this bug has been open for some time. The code in question was introduced all the way back in version 1.0.3 of Ridley so this might not just be affecting chefdk but any workstation with berks/knife installed.

Related Links:
berkshelf/berkshelf#1069 (closed)
https://github.com/RiotGames/ridley/blob/master/lib/ridley/chef/config.rb#L72-L75

@danielsdeleo
Copy link
Contributor

Since this an issue in Berks and the bug is reported upstream, I'm going to close it here. If you also see this problem with knife, then we can create a bug in the Chef project for that (but it looks like here this isn't knife, just berks trying to read knife.rb).

@andrewjamesbrown
Copy link
Author

I noticed that running both knife and berks with Chef 11.14 has the problem; since its actually a bug in Ridley.
I understand that Chef 11.14+ uses Ridley, and thus also has the issue. I did confirm that using knife 11.12 is OK.

In this case, should is actually be closed here?

@sethvargo
Copy link

I understand that Chef 11.14+ uses Ridley

To the best of my knowledge, Chef does not use Ridley

@danielsdeleo
Copy link
Contributor

Chef definitely doesn't use ridley: https://github.com/opscode/chef/blob/281fc5a3a120c2fca42ffe7f8d273debdf530cfe/chef.gemspec#L17-L35

If the issue does exist in Chef then it's probable both codebases have implemented the same bug. We'd need an strace from knife to confirm. You could also run knife with RUBYOPT='-rtracer' to get a ruby-level trace (lots of output) to see if you can find where the call to tmpdir is coming from.

@andrewjamesbrown
Copy link
Author

Thanks for the tip, Dan. Using '-rtracer', I've think I have narrowed it down to the knife-spork plugin, specifically Spork Omni, that's included with ChefDK.

(snipped for brevity)

/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/knife-spork-1.3.2/lib/chef/knife/spork-omni.rb:5::-:   require 'berkshelf'
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/berkshelf-3.1.1/lib/berkshelf.rb:6::-: require 'ridley'
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/ridley-3.1.0/lib/ridley.rb:67::-:   require_relative 'ridley/chef'
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/ridley-3.1.0/lib/ridley/chef.rb:6::-:     require_relative 'chef/config'
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/ridley-3.1.0/lib/ridley/chef/config.rb:60::-:     attribute :cookbook_license,
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/ridley-3.1.0/lib/ridley/chef/config.rb:63::-:     attribute :knife,
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/ridley-3.1.0/lib/ridley/chef/config.rb:72::-:     attribute :syntax_check_cache_path,
/opt/chefdk/embedded/lib/ruby/2.1.0/tmpdir.rb:84:Dir:>:   def Dir.mktmpdir(prefix_suffix=nil, *rest)
/opt/chefdk/embedded/lib/ruby/2.1.0/tmpdir.rb:85:Dir:-:     path = Tmpname.create(prefix_suffix || "d", *rest) {|n| mkdir(n, 0700)}
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/ridley-3.1.0/lib/ridley/chef/config.rb:74::-:     attribute :cache_options,
/opt/chefdk/embedded/lib/ruby/2.1.0/tmpdir.rb:84:Dir:>:   def Dir.mktmpdir(prefix_suffix=nil, *rest)
/opt/chefdk/embedded/lib/ruby/2.1.0/tmpdir.rb:85:Dir:-:     path = Tmpname.create(prefix_suffix || "d", *rest) {|n| mkdir(n, 0700)}

@sethvargo
Copy link

@bb-anbrown out of curiosity - can you please post your knife.rb, scrubbing any sensitive data? I have a suspicion...

@sethvargo
Copy link

Actually, nvm. This is a bug in Ridley. We are making a tmpdir when the attribute is loaded. That needs to be changed to use a proc instead.

@sethvargo
Copy link

@bb-anbrown @danielsdeleo berkshelf/ridley#276

ksubrama pushed a commit that referenced this issue Jan 11, 2016
@chef-boneyard chef-boneyard locked and limited conversation to collaborators Feb 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

4 participants