Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

"rake <env> deploy" does deploy four times? #149

Open
jikamens opened this Issue Jun 28, 2013 · 6 comments

Comments

Projects
None yet
3 participants

We are using heroku_san with mongoid_rails_migrations (fixed version at git://github.com/quantopian/mongoid_rails_migrations) for a Ruby on Rails application built on top of ruby 2.0.0, rails 3.2.13, and MongoDB.

When we run "rake staging deploy" or "rake production deploy", it does the entire deploy process four times.

When we do the deploy with "-t", it claims that all four deployments are happening within a single invocation of the deploy rule.

We thought perhaps it was running the deployment separately on each dyno, but our staging environment has only 2: 1 web dyno and 1 worker. On the other hand, our production environment has 3 web dynos and 1 worker. I don't know if any of this is relevant.

Oddly, it doesn't always do this. For example, it doesn't seem to do it in automated builds run by our Jenkins server, even though those builds are using the same "rake staging deploy" command we type on the command line.

Has anyone else seen this before? Any pointers for how to troubleshoot it further?

Contributor

kmayer commented Aug 2, 2013

heroku_san knows nothing about dynos

When you "deploy" what do you see? A deploy is simply a git push, after that, it's all up to Heroku.

HerokuSan creates targets, "staging", "production", etc. based on what's in your heroku.yml file. Perhaps you have multiple stages with the same name? Naming one of them "deploy" would also be terribly bad.

I'm seeing this, too. I have this in my Rakefile (we have a rails app):

if defined? HerokuSan
  require 'deploy/our_strategy'
  require 'deploy/our_stage'
  config_file = File.join(File.expand_path(File.dirname(__FILE__)), 'config', 'heroku.yml')
  HerokuSan.project = HerokuSan::Project.new(config_file, deploy: OurStrategy)
  HerokuSan.project.configuration = HerokuSan::Configuration.new(HerokuSan.project, OurStage)

  load 'heroku_san/tasks.rb'
end

If I comment out load 'heroku_san/tasks.rb' from heroku_san's railtie everything works as expected.

The rake task itself runs twice, and in each of those runs the target is duplicated. Or that's how it seems since there is blank line between runs 1 and 2, and runs 3 and 4 (presumably caused by this).

The way I was able to fix this was to require: false the heroku_san gem in my Gemfile, and then amend my Rakefile to look like:

if Rails.env.development?
  require 'heroku_san'

  require 'deploy/our_strategy'
  require 'deploy/our_stage'
  config_file = File.join(File.expand_path(File.dirname(__FILE__)), 'config', 'heroku.yml')
  HerokuSan.project = HerokuSan::Project.new(config_file, deploy: OurStrategy)
  HerokuSan.project.configuration = HerokuSan::Configuration.new(HerokuSan.project, OurStage)

  load 'heroku_san/tasks.rb'
end

I'm not sure my solution is the best way to get around this issue, but it seems to work for us.

Contributor

kmayer commented Mar 23, 2014

creating tasks are cumulative, so if tasks.rb is getting loaded twice, then
the dependencies will be as well. hmmm

so you don't need to load tasks.rb in your rake file , that's only for
Sinatra-like apps that don't have rail ties to load it for you.

On Sat, Mar 22, 2014 at 1:41 PM, Brent Wheeldon notifications@github.comwrote:

I'm seeing this, too. I have this in my Rakefile (we have a rails app):

if defined? HerokuSan
require 'deploy/our_strategy'
require 'deploy/our_stage'
config_file = File.join(File.expand_path(File.dirname(FILE)), 'config', 'heroku.yml')
HerokuSan.project = HerokuSan::Project.new(config_file, deploy: OurStrategy)
HerokuSan.project.configuration = HerokuSan::Configuration.new(HerokuSan.project, OurStage)

load 'heroku_san/tasks.rb'
end

If I comment out load 'heroku_san/tasks.rb' from heroku_san's railtiehttps://github.com/fastestforward/heroku_san/blob/master/lib/railtie.rb#L6everything works as expected.

The rake task itself runs twice, and in each of those runs the target is
duplicated. Or that's how it seems since there is blank line between runs 1
and 2, and runs 3 and 4 (presumably caused by thishttps://github.com/fastestforward/heroku_san/blob/master/lib/heroku_san/tasks.rb#L322
).

The way I was able to fix this was to require: false the heroku_san gem
in my Gemfile, and then amend my Rakefile to look like:

if Rails.env.development?
require 'heroku_san'

require 'deploy/our_strategy'
require 'deploy/our_stage'
config_file = File.join(File.expand_path(File.dirname(FILE)), 'config', 'heroku.yml')
HerokuSan.project = HerokuSan::Project.new(config_file, deploy: OurStrategy)
HerokuSan.project.configuration = HerokuSan::Configuration.new(HerokuSan.project, OurStage)

load 'heroku_san/tasks.rb'
end

I'm not sure my solution is the best way to get around this issue, but it
seems to work for us.

Reply to this email directly or view it on GitHubhttps://github.com/fastestforward/heroku_san/issues/149#issuecomment-38363438
.

ken@bitwrangler.com | (808) 722-6142 (c)

I was just following the instructions in the example. The fix I outlined above actually didn't work. I'll dig in more tomorrow and report back.

On Mar 22, 2014, at 8:59 PM, Ken Mayer notifications@github.com wrote:

creating tasks are cumulative, so if tasks.rb is getting loaded twice, then
the dependencies will be as well. hmmm

so you don't need to load tasks.rb in your rake file , that's only for
Sinatra-like apps that don't have rail ties to load it for you.

On Sat, Mar 22, 2014 at 1:41 PM, Brent Wheeldon notifications@github.comwrote:

I'm seeing this, too. I have this in my Rakefile (we have a rails app):

if defined? HerokuSan
require 'deploy/our_strategy'
require 'deploy/our_stage'
config_file = File.join(File.expand_path(File.dirname(FILE)), 'config', 'heroku.yml')
HerokuSan.project = HerokuSan::Project.new(config_file, deploy: OurStrategy)
HerokuSan.project.configuration = HerokuSan::Configuration.new(HerokuSan.project, OurStage)

load 'heroku_san/tasks.rb'
end

If I comment out load 'heroku_san/tasks.rb' from heroku_san's railtiehttps://github.com/fastestforward/heroku_san/blob/master/lib/railtie.rb#L6everything works as expected.

The rake task itself runs twice, and in each of those runs the target is
duplicated. Or that's how it seems since there is blank line between runs 1
and 2, and runs 3 and 4 (presumably caused by thishttps://github.com/fastestforward/heroku_san/blob/master/lib/heroku_san/tasks.rb#L322
).

The way I was able to fix this was to require: false the heroku_san gem
in my Gemfile, and then amend my Rakefile to look like:

if Rails.env.development?
require 'heroku_san'

require 'deploy/our_strategy'
require 'deploy/our_stage'
config_file = File.join(File.expand_path(File.dirname(FILE)), 'config', 'heroku.yml')
HerokuSan.project = HerokuSan::Project.new(config_file, deploy: OurStrategy)
HerokuSan.project.configuration = HerokuSan::Configuration.new(HerokuSan.project, OurStage)

load 'heroku_san/tasks.rb'
end

I'm not sure my solution is the best way to get around this issue, but it
seems to work for us.

Reply to this email directly or view it on GitHubhttps://github.com/fastestforward/heroku_san/issues/149#issuecomment-38363438
.

ken@bitwrangler.com | (808) 722-6142 (c)

Reply to this email directly or view it on GitHub.

Contributor

kmayer commented Mar 23, 2014

I think I need a better example for rails apps; they just need new objects defined.

Sent from my iPhone

On Mar 22, 2014, at 6:08 PM, Brent Wheeldon notifications@github.com wrote:

I was just following the instructions in the example. The fix I outlined above actually didn't work. I'll dig in more tomorrow and report back.

On Mar 22, 2014, at 8:59 PM, Ken Mayer notifications@github.com wrote:

creating tasks are cumulative, so if tasks.rb is getting loaded twice, then
the dependencies will be as well. hmmm

so you don't need to load tasks.rb in your rake file , that's only for
Sinatra-like apps that don't have rail ties to load it for you.

On Sat, Mar 22, 2014 at 1:41 PM, Brent Wheeldon notifications@github.comwrote:

I'm seeing this, too. I have this in my Rakefile (we have a rails app):

if defined? HerokuSan
require 'deploy/our_strategy'
require 'deploy/our_stage'
config_file = File.join(File.expand_path(File.dirname(FILE)), 'config', 'heroku.yml')
HerokuSan.project = HerokuSan::Project.new(config_file, deploy: OurStrategy)
HerokuSan.project.configuration = HerokuSan::Configuration.new(HerokuSan.project, OurStage)

load 'heroku_san/tasks.rb'
end

If I comment out load 'heroku_san/tasks.rb' from heroku_san's railtiehttps://github.com/fastestforward/heroku_san/blob/master/lib/railtie.rb#L6everything works as expected.

The rake task itself runs twice, and in each of those runs the target is
duplicated. Or that's how it seems since there is blank line between runs 1
and 2, and runs 3 and 4 (presumably caused by thishttps://github.com/fastestforward/heroku_san/blob/master/lib/heroku_san/tasks.rb#L322
).

The way I was able to fix this was to require: false the heroku_san gem
in my Gemfile, and then amend my Rakefile to look like:

if Rails.env.development?
require 'heroku_san'

require 'deploy/our_strategy'
require 'deploy/our_stage'
config_file = File.join(File.expand_path(File.dirname(FILE)), 'config', 'heroku.yml')
HerokuSan.project = HerokuSan::Project.new(config_file, deploy: OurStrategy)
HerokuSan.project.configuration = HerokuSan::Configuration.new(HerokuSan.project, OurStage)

load 'heroku_san/tasks.rb'
end

I'm not sure my solution is the best way to get around this issue, but it
seems to work for us.

Reply to this email directly or view it on GitHubhttps://github.com/fastestforward/heroku_san/issues/149#issuecomment-38363438
.

ken@bitwrangler.com | (808) 722-6142 (c)

Reply to this email directly or view it on GitHub.

Reply to this email directly or view it on GitHub.

Yep, redefining HerokuSan.project (and HerokuSan.project.configuration in our case) did the trick.

I've just looked over the example again and it doesn't mention requiring/loading the gem's rake tasks, so I must have been reading the wrong section somehow. Sorry about that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment