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

Source recipe fails on subsequent converge if package based install used in between #110

Open
fletchowns opened this issue Oct 27, 2016 · 7 comments

Comments

@fletchowns
Copy link

Cookbook version

5.0.1

Chef-client version

12.10.24

Platform Details

CentOS 7.2 Bento Box

Scenario:

Converge fails due to error:

mkdir: cannot create directory ‘git-2.6.2’: File exists

Steps to Reproduce:

We're using the git::source recipe to install git 2.6.2 on CentOS 7.2. Initial converge works great, source based install succeeds, and we have git 2.6.2 on the PATH. I think what's happening is that something else in our converge is inadvertently doing a packaged based install of git, and then the next time git::source the guard passes since git --version returns 1.8.3.1, so git::source thinks it needs to install it again. It fails to extract it because the extracted version already exists in Chef::Config['file_cache_path'].

So it's admittedly a bug in our converge that the package based install of git is happening, but it seems like something that this cookbook should be able to recover from.

Here's the relevant chunk from the converge output: https://gist.github.com/fletchowns/cdab5e1f58722fd4d9cd6f4492fa3e52

Expected Result:

It seems like the git::source recipe should be able to handle the output directory in Chef::Config['file_cache_path'] already existing by using a mkdir -p or something instead of just a mkdir.

Actual Result:

The converge fails because the cache directory already exists.

@fletchowns
Copy link
Author

Actually, looks like the git::source recipe installs the gettext-devel package, which install the ancient version of git.

$ sudo yum install gettext-devel
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: repos.lax.quadranet.com
 * epel: mirror.sjc02.svwh.net
 * extras: mirrors.xmission.com
 * updates: mirrors.ocf.berkeley.edu
Resolving Dependencies
--> Running transaction check
---> Package gettext-devel.x86_64 0:0.18.2.1-4.el7 will be installed
--> Processing Dependency: git for package: gettext-devel-0.18.2.1-4.el7.x86_64
--> Running transaction check
---> Package git.x86_64 0:1.8.3.1-6.el7_2.1 will be installed
--> Processing Dependency: perl-Git = 1.8.3.1-6.el7_2.1 for package: git-1.8.3.1-6.el7_2.1.x86_64
--> Processing Dependency: perl(Git) for package: git-1.8.3.1-6.el7_2.1.x86_64
--> Running transaction check
---> Package perl-Git.noarch 0:1.8.3.1-6.el7_2.1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================================================================================================================================================
 Package                                                     Arch                                                 Version                                                         Repository                                             Size
==============================================================================================================================================================================================================================================
Installing:
 gettext-devel                                               x86_64                                               0.18.2.1-4.el7                                                  base                                                  315 k
Installing for dependencies:
 git                                                         x86_64                                               1.8.3.1-6.el7_2.1                                               updates                                               4.4 M
 perl-Git                                                    noarch                                               1.8.3.1-6.el7_2.1                                               updates                                                53 k

Transaction Summary
==============================================================================================================================================================================================================================================
Install  1 Package (+2 Dependent packages)

Total download size: 4.7 M
Installed size: 24 M
Is this ok [y/d/N]:

@tas50 tas50 added the Type: Bug label Dec 6, 2016
@jpSimkins
Copy link

jpSimkins commented Jun 23, 2017

I too am having this issue with CentOS 7.3. Does anyone know of a work-a-round? I need to be on at least version 2 but I am stuck with 1.8.3. Otherwise, I will have to drop this cookbook and just build a cookbook to build this installation manually.

@fletchowns
Copy link
Author

fletchowns commented Jun 23, 2017

@jpSimkins I am working around the issue with a small wrapper cookbook:

# remove the default out of date package
package "git" do
	action :remove
end

# install tk package so gitk and git gui work
package "tk"

# temporary workaround for https://github.com/chef-cookbooks/git/issues/110
directory "#{Chef::Config['file_cache_path']}/git-#{node["git"]["version"]}" do
	recursive true
	action :delete
end

include_recipe "git::source"

@jpSimkins
Copy link

I have tried your wrapper and still no luck. I am not able to get any other version other then 1.8.3 installed.

Thanks, at this point I'll have to find another solution.

@fletchowns
Copy link
Author

@jpSimkins Sorry to hear it didn't work for you. Are you able to share the converge log?

@jpSimkins
Copy link

jpSimkins commented Jun 29, 2017

Thanks for a quick response. This is the log: https://gist.github.com/jpSimkins/4ab6dd25215de0e886eaa60503f6c129

I don't mind assisting you with this if you want. Also, I am very new to chef (but a veteran to system admin) so I wonder if maybe I am doing something wrong on my end... I am a little confused on how to use the source of this cookbook so I will show you my code. Perhaps it's just a noobie mistake.

Hopefully this will point something out:

attributes/default.rb

default['git']['version'] = '2.13.1'
default['git']['url'] = 'https://github.com/git/git/archive/v2.13.1.tar.gz'
default['git']['checksum'] = 'd3015a679aa2dc5ff2cc8839459cea15fb2644aaa6bb9cc18e835bba2087adab'

I am not using any GUI so I left out the tk package.
cookbook/git.rb

# remove the default out of date package
package "git" do
	action :remove
end

# temporary workaround for https://github.com/chef-cookbooks/git/issues/110
directory "#{Chef::Config['file_cache_path']}/git-#{node["git"]["version"]}" do
	recursive true
	action :delete
end

include_recipe "git::source"

# Is this needed?
git_client 'default' do
    provider Chef::Provider::GitClient::Source
    source_checksum node['git']['checksum']
    source_prefix node['git']['prefix']
    source_url format(node['git']['url'], version: node['git']['version'])
    source_use_pcre node['git']['use_pcre']
    source_version node['git']['version']
    action :install
end

Also, is it possible to have this cookbook install a repo in yum to install git that way? I don't think so but I wanted to confirm. Just a bit confused on how updates will happen for this.

Thanks

@fletchowns
Copy link
Author

@jpSimkins I don't think the git_client is necessary. I don't have it, at least.

I also have default["git"]["prefix"] = "/usr" in the attributes that I set, can't remember why I added that though. May have something to do with getting the cookbook version to appear on the PATH though. How are you verifying the version of git that is installed after converge? What's the output of which git and echo $PATH ? Maybe /usr/local is not on there?

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

4 participants