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

Error executing action login on resource docker_registry #114

Closed
psviderski opened this Issue Apr 5, 2014 · 3 comments

Comments

Projects
None yet
2 participants
@psviderski

psviderski commented Apr 5, 2014

I use the latest version of chef-docker cookbook from the master branch. When I try to login to a private repository the following error is occurred:

================================================================================
Error executing action `login` on resource 'docker_registry[https://registry.xxx.com]'
================================================================================


Errno::ENOENT
-------------
No such file or directory - /root/.dockercfg


Cookbook Trace:
---------------
/tmp/vagrant-chef-1/chef-solo-2/cookbooks/docker/libraries/helpers.rb:59:in `read'
/tmp/vagrant-chef-1/chef-solo-2/cookbooks/docker/libraries/helpers.rb:59:in `dockercfg_parse'
/tmp/vagrant-chef-1/chef-solo-2/cookbooks/docker/providers/registry.rb:6:in `load_current_resource'


Resource Declaration:
---------------------
# In /tmp/vagrant-chef-1/chef-solo-1/cookbooks/test/recipes/default.rb

  1: docker_registry 'https://registry.xxx.com' do
  2:   username 'xxx'
  3:   password 'yyy'
  4: end
  5:

Do I have to manually create the missing /root/.dockercfg file?
Btw, when I create it with the content:

{}

it still doesn't solve the problem.
It seems that logged_in? always returns true even if we are not logged in. Because of this, the login function isn't called.

@bflad bflad closed this in 5233b43 Apr 13, 2014

@bflad

This comment has been minimized.

Collaborator

bflad commented Apr 13, 2014

Added two simple fixes, which you can either use from master or 0.34.0 which I'll be releasing momentarily:

  • rescue when .dockercfg doesn't exist and return nil
  • Explicitly set TrueClass or FalseClass in logged_in? method

If you still have trouble, please let me know. Thanks for the detailed report.

bflad added a commit that referenced this issue Apr 13, 2014

@psviderski

This comment has been minimized.

psviderski commented Apr 14, 2014

It seems you didn't fix the issue with logged_in? method. Why are you checking the .server attribute in order to determine whether we are logged in?

attribute :server, :name_attribute => true

.server is a name attribute, so it seems to be assigned on a fresh @current_resource.
I would rather check a .username or a .password attribute.

@bflad

This comment has been minimized.

Collaborator

bflad commented Apr 14, 2014

Hmmm good point... I just figured it wouldn't exist in @current_resource unless this ran: https://github.com/bflad/chef-docker/blob/master/providers/registry.rb#L9

I'll move it to checking username instead.

@bflad bflad reopened this Apr 14, 2014

@bflad bflad closed this in 0f6473f Apr 16, 2014

bflad added a commit that referenced this issue Apr 16, 2014

Merge pull request #134 from psviderski/master
Fix docker_registry login handling, fixes #114
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment