atmos / heaven

:walking: Rails app for GitHub Flow

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Auto Deployment triggers multiple deploys

dblandin opened this issue · comments

We recently enabled Status webhook events to let Heaven handle auto-deployment of passing master builds but we've encountered some odd behavior and had to disable it pretty quickly. First, it seems like multiple deployments are triggered.

Here's a screenshot of my notification output after merging a PR containing just 1 commit:

screen shot 2014-10-30 at 11 35 52 am

I'm not too familiar with the intent behind the Deployment.latest_for_name_with_owner class method but a deployment seems to trigger for each result returned.

We're deploying 3 apps trough heaven currently.

Here are some counts from Deployment.latest_for_name_with_owner:

> Deployment.latest_for_name_with_owner('dscout/dscout').count
=> 4
> Deployment.latest_for_name_with_owner('dscout/dscout-web').count
=> 5
> Deployment.latest_for_name_with_owner('dscout/dscout-efflux').count
=> 6

Are multiple results expected?

There's probably something really awful in there that needs to be revisited. Hopefully I can take a look at all of this next week.

Is this still a thing?

Likely is. I haven't dared to enable this again without writing some specs.

I just turned the Commit status updated from the API. flag back on for our application's webhook and this happened to me too ( turned it back off right quick afterwards 👅 )

Running the latest version of Heaven too

On my case it's triggering two deployments to production because https://github.com/atmos/heaven/blob/master/app/models/deployment.rb#L7-L20 returns two Deployment, one for production and one for staging.

What's the expected behavior for auto deploy with multiple environments? Deploy master to all of them or only to production?

At GitHub we had auto-deploy enable hubot in <env> and auto-deploy disable hubot in <env>. So you could configure different environments as they became available. There are slightly different rules for whether the user who last deployed pushed more commits and whether it was locked. I feel like maybe we need better docs of the behavior so we can clarify the intended behavior w/ the few variables.

@atmos that behavior you described is not happening.

Have a look at

Deployment.latest_for_name_with_owner(name_with_owner).each do |deployment|
Rails.logger.info "tryna deploy #{name_with_owner}@#{sha} to #{deployment.environment}"
AutoDeployment.new(deployment, self).execute
end
then https://github.com/atmos/heaven/blob/master/app/models/deployment.rb#L7-L20 and finally
def create_deployment
description = "Heaven auto deploy triggered by a commit status change"
api.create_deployment(name_with_owner, sha, :payload => updated_payload, :description => description)
end
. Pay attention that on AutoDeployment it's not using the environment when creating a deployment, but CommitStatus triggers deployments for each environment.

Looks like this was fixed with #158. Closing.