Cryptic error message on first run of deploy_branch


#1

Ohai there,

I’m getting the following error message when I use the deploy resource for
the first time on a clean Vagrant machine:

FATAL: NoMethodError: deploy_branch[/var/admintool]
(plinga-admintool::deploy line 14) had an error: NoMethodError: undefined
method `[]’ for nil:NilClass

And here’s the relevant recipe snippet:

deploy_branch node[‘plinga-admintool’][‘app_dir’] do
user "root"
group "root"
migrate false
purge_before_symlink([])
create_dirs_before_symlink([])
symlink_before_migrate({})
symlinks({})
repository File.join(repo, branch)
revision node[‘plinga-admintool’][‘svn_revision’]
scm_provider Chef::Provider::Subversion
svn_username node[‘plinga-admintool’][‘svn_username’]
svn_password node[‘plinga-admintool’][‘svn_password’]
action :deploy
end

Has anyone had a similar or related issue before? The only resource I could
find is this IRC log http://likens.us/logs/2012/%23chef.06-20.12.log (search
for dbalatero), and… it doesn’t really help, since no solution was
suggested there.
I’m at a loss regarding how to debug, since I’ve triple-checked my code,
all hints or pointers greatly appreciated! Otherwise my next step will be
to hard-code logs in the deploy provider, but avoiding that pain would be
better :slight_smile:

More info:

  • failed-run-data.json contains all the correct attributes (at least
    concerning this deployment)
  • any subsequent chef-client run on the same machine works perfectly.

Cheers and thanks in advance,


Loic ANTOINE-GOMBEAUD
IT contact & DevOps Engineer

Plinga GmbH | Saarbrücker Straße 20/21 | 10405 Berlin | Germany
E-Mail: loic.gombeaud@plinga.com | skype: loic.plinga
Cell: +49 (0) 160 922 86753

Geschäftsführer: Johannes Kreibohm, Florian Schmidt-Amelung
Eingetragen beim Amtsgericht Charlottenburg, HRB 119994


#2

This error means that you tried to index (using method []) a Nil object. Usually it means that what you thought was going to return an Array or a Hash returned nil instead.

This:

NoMethodError: deploy_branch[/var/admintool]

means that deploy_branch is nil, meaning that either:

  • It is supposed to be nil; or
  • It had not yet been set when it was called

On a side note, are you sure that deploy_branch is supposed to be a Hash, rather than, say, a method? And if so, is this Hash supposed to have a key ‘/var/admintool’? I’m just guessing about the semantics here since I’m not familiar with the rest of the cookbook.

Cheers,

Cassiano Leal

On Thursday, December 20, 2012 at 09:47, Loïc Antoine-Gombeaud wrote:

Ohai there,

I’m getting the following error message when I use the deploy resource for the first time on a clean Vagrant machine:

FATAL: NoMethodError: deploy_branch[/var/admintool] (plinga-admintool::deploy line 14) had an error: NoMethodError: undefined method `[]’ for nil:NilClass

And here’s the relevant recipe snippet:

deploy_branch node[‘plinga-admintool’][‘app_dir’] do
user "root"
group "root"
migrate false
purge_before_symlink([])
create_dirs_before_symlink([])
symlink_before_migrate({})
symlinks({})
repository File.join(repo, branch)
revision node[‘plinga-admintool’][‘svn_revision’]
scm_provider Chef::Provider::Subversion
svn_username node[‘plinga-admintool’][‘svn_username’]
svn_password node[‘plinga-admintool’][‘svn_password’]
action :deploy
end

Has anyone had a similar or related issue before? The only resource I could find is this IRC log (http://likens.us/logs/2012/%23chef.06-20.12.log) (search for dbalatero), and… it doesn’t really help, since no solution was suggested there.
I’m at a loss regarding how to debug, since I’ve triple-checked my code, all hints or pointers greatly appreciated! Otherwise my next step will be to hard-code logs in the deploy provider, but avoiding that pain would be better :slight_smile:

More info:

  • failed-run-data.json contains all the correct attributes (at least concerning this deployment)
  • any subsequent chef-client run on the same machine works perfectly.

Cheers and thanks in advance,


Loic ANTOINE-GOMBEAUD
IT contact & DevOps Engineer

Plinga GmbH | Saarbrücker Straße 20/21 | 10405 Berlin | Germany
E-Mail: loic.gombeaud@plinga.com (mailto:loic.gombeaud@plinga.com) | skype: loic.plinga
Cell: +49 (0) 160 922 86753 (tel:%2B49%20%280%29%20160%20922%2086753)

www.plinga.com (http://www.plinga.com/)

Geschäftsführer: Johannes Kreibohm, Florian Schmidt-Amelung
Eingetragen beim Amtsgericht Charlottenburg, HRB 119994


#3

If I had to guess I would say that node[‘plinga-admintool’] wasn’t set as a Hash for some reason. Once you look up node[‘plinga-admintool’][‘app_dir’] it fails.

Jeffrey Hulten
Principal Consultant at Automated Labs, LLC
jeffh@automatedlabs.com 206-853-5216
Skype: jeffhulten

On Dec 20, 2012, at 7:36 AM, Cassiano Leal wrote:

This error means that you tried to index (using method []) a Nil object. Usually it means that what you thought was going to return an Array or a Hash returned nil instead.

This:

NoMethodError: deploy_branch[/var/admintool]

means that deploy_branch is nil, meaning that either:

  • It is supposed to be nil; or
  • It had not yet been set when it was called

On a side note, are you sure that deploy_branch is supposed to be a Hash, rather than, say, a method? And if so, is this Hash supposed to have a key ‘/var/admintool’? I’m just guessing about the semantics here since I’m not familiar with the rest of the cookbook.

Cheers,

Cassiano Leal

On Thursday, December 20, 2012 at 09:47, Loïc Antoine-Gombeaud wrote:

Ohai there,

I’m getting the following error message when I use the deploy resource for the first time on a clean Vagrant machine:

FATAL: NoMethodError: deploy_branch[/var/admintool] (plinga-admintool::deploy line 14) had an error: NoMethodError: undefined method `[]’ for nil:NilClass

And here’s the relevant recipe snippet:

deploy_branch node[‘plinga-admintool’][‘app_dir’] do
user "root"
group "root"
migrate false
purge_before_symlink([])
create_dirs_before_symlink([])
symlink_before_migrate({})
symlinks({})
repository File.join(repo, branch)
revision node[‘plinga-admintool’][‘svn_revision’]
scm_provider Chef::Provider::Subversion
svn_username node[‘plinga-admintool’][‘svn_username’]
svn_password node[‘plinga-admintool’][‘svn_password’]
action :deploy
end

Has anyone had a similar or related issue before? The only resource I could find is this IRC log (search for dbalatero), and… it doesn’t really help, since no solution was suggested there.
I’m at a loss regarding how to debug, since I’ve triple-checked my code, all hints or pointers greatly appreciated! Otherwise my next step will be to hard-code logs in the deploy provider, but avoiding that pain would be better :slight_smile:

More info:

  • failed-run-data.json contains all the correct attributes (at least concerning this deployment)
  • any subsequent chef-client run on the same machine works perfectly.

Cheers and thanks in advance,


Loic ANTOINE-GOMBEAUD
IT contact & DevOps Engineer

Plinga GmbH | Saarbrücker Straße 20/21 | 10405 Berlin | Germany
E-Mail: loic.gombeaud@plinga.com | skype: loic.plinga
Cell: +49 (0) 160 922 86753

www.plinga.com

Geschäftsführer: Johannes Kreibohm, Florian Schmidt-Amelung
Eingetragen beim Amtsgericht Charlottenburg, HRB 119994


#4

To further your answer: it would be understandable that resource names
are evaluated at an earlier point of the run than their options, and
before the variable node itself is (set if nil).
Looks like a possible bug, I’ll look at the code and report my finds here.

On 12/20/12, Jeffrey Hulten jeffh@automatedlabs.com wrote:

If I had to guess I would say that node[‘plinga-admintool’] wasn’t set as a
Hash for some reason. Once you look up node[‘plinga-admintool’][‘app_dir’]
it fails.

Jeffrey Hulten
Principal Consultant at Automated Labs, LLC
jeffh@automatedlabs.com 206-853-5216
Skype: jeffhulten

On Dec 20, 2012, at 7:36 AM, Cassiano Leal wrote:

This error means that you tried to index (using method []) a Nil object.
Usually it means that what you thought was going to return an Array or a
Hash returned nil instead.

This:

NoMethodError: deploy_branch[/var/admintool]

means that deploy_branch is nil, meaning that either:

  • It is supposed to be nil; or
  • It had not yet been set when it was called

On a side note, are you sure that deploy_branch is supposed to be a Hash,
rather than, say, a method? And if so, is this Hash supposed to have a key
’/var/admintool’? I’m just guessing about the semantics here since I’m not
familiar with the rest of the cookbook.

Cheers,

Cassiano Leal

On Thursday, December 20, 2012 at 09:47, Loïc Antoine-Gombeaud wrote:

Ohai there,

I’m getting the following error message when I use the deploy resource
for the first time on a clean Vagrant machine:

FATAL: NoMethodError: deploy_branch[/var/admintool]
(plinga-admintool::deploy line 14) had an error: NoMethodError: undefined
method `[]’ for nil:NilClass

And here’s the relevant recipe snippet:

deploy_branch node[‘plinga-admintool’][‘app_dir’] do
user "root"
group "root"
migrate false
purge_before_symlink([])
create_dirs_before_symlink([])
symlink_before_migrate({})
symlinks({})
repository File.join(repo, branch)
revision node[‘plinga-admintool’][‘svn_revision’]
scm_provider Chef::Provider::Subversion
svn_username node[‘plinga-admintool’][‘svn_username’]
svn_password node[‘plinga-admintool’][‘svn_password’]
action :deploy
end

Has anyone had a similar or related issue before? The only resource I
could find is this IRC log (search for dbalatero), and… it doesn’t
really help, since no solution was suggested there.
I’m at a loss regarding how to debug, since I’ve triple-checked my code,
all hints or pointers greatly appreciated! Otherwise my next step will be
to hard-code logs in the deploy provider, but avoiding that pain would be
better :slight_smile:

More info:

  • failed-run-data.json contains all the correct attributes (at least
    concerning this deployment)
  • any subsequent chef-client run on the same machine works perfectly.

Cheers and thanks in advance,


Loic ANTOINE-GOMBEAUD
IT contact & DevOps Engineer

Plinga GmbH | Saarbrücker Straße 20/21 | 10405 Berlin | Germany
E-Mail: loic.gombeaud@plinga.com | skype: loic.plinga
Cell: +49 (0) 160 922 86753

www.plinga.com

Geschäftsführer: Johannes Kreibohm, Florian Schmidt-Amelung
Eingetragen beim Amtsgericht Charlottenburg, HRB 119994


Loic ANTOINE-GOMBEAUD
IT contact & DevOps Engineer

Plinga GmbH | Saarbrücker Straße 20/21 | 10405 Berlin | Germany
E-Mail: loic.gombeaud@plinga.com | skype: loic.plinga
Cell: +49 (0) 160 922 86753

Geschäftsführer: Johannes Kreibohm, Florian Schmidt-Amelung
Eingetragen beim Amtsgericht Charlottenburg, HRB 119994


#5

Just did a bit of testing, turns out you were absolutely right (thank you,
by the way): node[‘plinga-admintool’] is nil at compile-time for some
reason. It’s probably a run_context problem, I spent some time walking
around in the code but am not familiar enough with Ruby’s evaluation
contexts to pinpoint the problem.

It’s a problem, because the deploy_branch resource doesn’t have a
destination attribute: it has to be the name… A workaround would be to
add the destination attribute, but that doesn’t fix the general problem:
under certain conditions (to be precised), node[‘whatever’] evaluates to
nil when used in a resource name.

Looking a bit deeper, I found this commit that solves
dbalaterohttp://likens.us/logs/2012/%23chef.06-20.12.log’s
problem:


No time to investigate right now unfortunately, but… I’ll be back ^^

Cheers,

Loïc

On Fri, Dec 21, 2012 at 9:38 AM, Loïc Antoine-Gombeaud <
loic.gombeaud@plinga.com> wrote:

To further your answer: it would be understandable that resource names
are evaluated at an earlier point of the run than their options, and
before the variable node itself is (set if nil).
Looks like a possible bug, I’ll look at the code and report my finds here.

On 12/20/12, Jeffrey Hulten jeffh@automatedlabs.com wrote:

If I had to guess I would say that node[‘plinga-admintool’] wasn’t set
as a
Hash for some reason. Once you look up
node[‘plinga-admintool’][‘app_dir’]
it fails.

Jeffrey Hulten
Principal Consultant at Automated Labs, LLC
jeffh@automatedlabs.com 206-853-5216
Skype: jeffhulten

On Dec 20, 2012, at 7:36 AM, Cassiano Leal wrote:

This error means that you tried to index (using method []) a Nil object.
Usually it means that what you thought was going to return an Array or a
Hash returned nil instead.

This:

NoMethodError: deploy_branch[/var/admintool]

means that deploy_branch is nil, meaning that either:

  • It is supposed to be nil; or
  • It had not yet been set when it was called

On a side note, are you sure that deploy_branch is supposed to be a
Hash,

rather than, say, a method? And if so, is this Hash supposed to have a
key

‘/var/admintool’? I’m just guessing about the semantics here since I’m
not

familiar with the rest of the cookbook.

Cheers,

Cassiano Leal

On Thursday, December 20, 2012 at 09:47, Loïc Antoine-Gombeaud wrote:

Ohai there,

I’m getting the following error message when I use the deploy resource
for the first time on a clean Vagrant machine:

FATAL: NoMethodError: deploy_branch[/var/admintool]
(plinga-admintool::deploy line 14) had an error: NoMethodError:
undefined

method `[]’ for nil:NilClass

And here’s the relevant recipe snippet:

deploy_branch node[‘plinga-admintool’][‘app_dir’] do
user "root"
group "root"
migrate false
purge_before_symlink([])
create_dirs_before_symlink([])
symlink_before_migrate({})
symlinks({})
repository File.join(repo, branch)
revision node[‘plinga-admintool’][‘svn_revision’]
scm_provider Chef::Provider::Subversion
svn_username node[‘plinga-admintool’][‘svn_username’]
svn_password node[‘plinga-admintool’][‘svn_password’]
action :deploy
end

Has anyone had a similar or related issue before? The only resource I
could find is this IRC log (search for dbalatero), and… it doesn’t
really help, since no solution was suggested there.
I’m at a loss regarding how to debug, since I’ve triple-checked my
code,

all hints or pointers greatly appreciated! Otherwise my next step will
be

to hard-code logs in the deploy provider, but avoiding that pain would
be

better :slight_smile:

More info:

  • failed-run-data.json contains all the correct attributes (at least
    concerning this deployment)
  • any subsequent chef-client run on the same machine works perfectly.

Cheers and thanks in advance,


Loic ANTOINE-GOMBEAUD
IT contact & DevOps Engineer

Plinga GmbH | Saarbrücker Straße 20/21 | 10405 Berlin | Germany
E-Mail: loic.gombeaud@plinga.com | skype: loic.plinga
Cell: +49 (0) 160 922 86753

www.plinga.com

Geschäftsführer: Johannes Kreibohm, Florian Schmidt-Amelung
Eingetragen beim Amtsgericht Charlottenburg, HRB 119994


Loic ANTOINE-GOMBEAUD
IT contact & DevOps Engineer

Plinga GmbH | Saarbrücker Straße 20/21 | 10405 Berlin | Germany
E-Mail: loic.gombeaud@plinga.com | skype: loic.plinga
Cell: +49 (0) 160 922 86753

www.plinga.com

Geschäftsführer: Johannes Kreibohm, Florian Schmidt-Amelung
Eingetragen beim Amtsgericht Charlottenburg, HRB 119994


Loic ANTOINE-GOMBEAUD
IT contact & DevOps Engineer

Plinga GmbH | Saarbrücker Straße 20/21 | 10405 Berlin | Germany
E-Mail: loic.gombeaud@plinga.com | skype: loic.plinga
Cell: +49 (0) 160 922 86753

Geschäftsführer: Johannes Kreibohm, Florian Schmidt-Amelung
Eingetragen beim Amtsgericht Charlottenburg, HRB 119994