Skip to content
This repository has been archived by the owner on Jan 28, 2020. It is now read-only.

Does not work with latest version of the application cookbook #4

Open
duro opened this issue Dec 11, 2013 · 6 comments
Open

Does not work with latest version of the application cookbook #4

duro opened this issue Dec 11, 2013 · 6 comments

Comments

@duro
Copy link

duro commented Dec 11, 2013

I am trying to use this with version 4.1.4 of the application cookbook, and I get a failure.

================================================================================
Error executing action `force_deploy` on resource 'deploy_revision[app]'
================================================================================


NoMethodError
-------------
undefined method `application' for Chef::Resource::DeployRevision


Cookbook Trace:
---------------
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/application_nodejs/providers/nodejs.rb:34:in `block (2 levels) in class_from_file'
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/application/providers/default.rb:144:in `instance_eval'
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/application/providers/default.rb:144:in `block (3 levels) in run_deploy'
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/application/providers/default.rb:141:in `each'
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/application/providers/default.rb:141:in `block (2 levels) in run_deploy'


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

123:   @deploy_resource = send(new_resource.strategy.to_sym, new_resource.name) do
124:     action force ? :force_deploy : :deploy
125:     scm_provider new_resource.scm_provider
126:     revision new_resource.revision
127:     repository new_resource.repository
128:     enable_submodules new_resource.enable_submodules
129:     user new_resource.owner
130:     group new_resource.group
131:     deploy_to new_resource.path
132:     ssh_wrapper "#{new_resource.path}/deploy-ssh-wrapper" if new_resource.deploy_key
133:     shallow_clone new_resource.shallow_clone
134:     rollback_on_error new_resource.rollback_on_error
135:     all_environments = ([new_resource.environment]+new_resource.sub_resources.map{|res| res.environment}).inject({}){|acc, val| acc.merge(val)}
136:     environment all_environments
137:     migrate new_resource.migrate
138:     all_migration_commands = ([new_resource.migration_command]+new_resource.sub_resources.map{|res| res.migration_command}).select{|cmd| cmd && !cmd.empty?}
139:     migration_command all_migration_commands.join(' && ')
140:     restart_command do
141:       ([new_resource]+new_resource.sub_resources).each do |res|
142:         cmd = res.restart_command
143:         if cmd.is_a? Proc
144:           app_provider.deploy_provider.instance_eval(&cmd) # @see libraries/default.rb
145:         elsif cmd && !cmd.empty?
146:           execute cmd do
147:             user new_resource.owner
148:             group new_resource.group
149:             environment all_environments
150:           end
151:         end
152:       end
153:     end
154:     purge_before_symlink (new_resource.purge_before_symlink + new_resource.sub_resources.map(&:purge_before_symlink)).flatten



Compiled Resource:
------------------
# Declared in /tmp/vagrant-chef-1/chef-solo-1/cookbooks/application/providers/default.rb:123:in `run_deploy'

deploy_revision("app") do
  provider Chef::Provider::Deploy::Revision
  action [:force_deploy]
  retries 0
  retry_delay 2
  deploy_to "/opt/app"
  environment {"NODE_ENV"=>"cookbook"}
  repository_cache "cached-copy"
  revision "dev"
  rollback_on_error true
  remote "origin"
  shallow_clone true
  scm_provider Chef::Provider::Git
  keep_releases 5
  cookbook_name :"app"
  repo "git@github.com:zehnergroup/xxx.git"
  user "xxx"
  group "xxx"
  git_ssh_wrapper "/opt/app/deploy-ssh-wrapper"
  restart_command #<Proc:0x00000004374098@/tmp/vagrant-chef-1/chef-solo-1/cookbooks/application/providers/default.rb:140>
  before_migrate #<Proc:0x000000043806b8@/tmp/vagrant-chef-1/chef-solo-1/cookbooks/application/providers/default.rb:160>
  before_symlink #<Proc:0x00000004380488@/tmp/vagrant-chef-1/chef-solo-1/cookbooks/application/providers/default.rb:163>
  before_restart #<Proc:0x00000004380258@/tmp/vagrant-chef-1/chef-solo-1/cookbooks/application/providers/default.rb:166>
  after_restart #<Proc:0x00000004380028@/tmp/vagrant-chef-1/chef-solo-1/cookbooks/application/providers/default.rb:169>
  shared_path "/opt/app/shared"
  destination "/opt/app/shared/cached-copy"
  current_path "/opt/app/current"
end



[2013-12-11T02:13:41+00:00] INFO: Running queued delayed notifications before re-raising exception
[2013-12-11T02:13:41+00:00] ERROR: Running exception handlers
[2013-12-11T02:13:41+00:00] ERROR: Exception handlers complete
[2013-12-11T02:13:41+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2013-12-11T02:13:41+00:00] FATAL: NoMethodError: deploy_revision[app] (/tmp/vagrant-chef-1/chef-solo-1/cookbooks/application/providers/default.rb line 123) had an error: NoMethodError: undefined method `application' for Chef::Resource::DeployRevision
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.

Everything in my cookbook works until I introduce the nodejs sub-resource

  application node["app"]["api"]["app_name"] do
    path              node["app"]["api"]["deploy_to"]
    owner             node["app"]["api"]["user"]
    group             node["app"]["api"]["group"]
    repository        node["app"]["api"]["repo"]["url"]
    revision          node["app"]["api"]["repo"]["branch"]
    deploy_key        node["app"]["api"]["repo"]["deploy_key"]
    environment_name  node["environment"]

    nodejs do
      npm true
      entry_point "server"
    end

    action :force_deploy
  end
gravitystorm added a commit to gravitystorm/application_nodejs that referenced this issue Jan 20, 2014
I've no real idea what's going on here, so let's try lifting something
similar to what happened in
https://github.com/poise/application_ruby/pull/42/files
@conradev
Copy link
Collaborator

@gravitystorm, any luck in fixing the issue?

@gravitystorm
Copy link
Contributor

@conradev the commit linked above is working well for me, but I hesitate to make a PR since I'm not really sure why it works. It's just copying what happened in application_ruby.

Of course, if it works, and there's lots of people encountering the bug, maybe it's worth merging anyway? I'll leave that decision to you!

gravitystorm added a commit to NaturalHistoryMuseum/nhm-windshaft-chef that referenced this issue Jan 23, 2014
@moreandres
Copy link

Any luck on understanding if the fix was good enough to be pulled?
I was updating my cookbooks and bumped into this thread due the issue.

@paulczar
Copy link

paulczar commented Jun 1, 2014

👍 it would be great to see this patched and merged in.

craftzdog added a commit to craftzdog/application_nodejs that referenced this issue Jan 22, 2015
@Azrael808
Copy link
Contributor

@conradev IDK if you're still maintaining this, but I just raised PR that seems to fix this issue:

#16

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

No branches or pull requests

6 participants