Skip to content

Commit 5e3767d

Browse files
committed
Stack: update build_deploy to pass allow_concurrency
1 parent 0834c0b commit 5e3767d

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Migrate from legacy Rails secrets to credentials (#1326)
44
* Rails secrets were [deprecated in Rails 7.1](https://github.com/rails/rails/pull/48472)
55
* [Guide on credentials](https://guides.rubyonrails.org/security.html#custom-credentials)
6+
* For deployments, `allow_concurrency` defaults to the same value as `force`. If wanted, it can be set separately by passing the intended value for `allow_concurrency` to `build_deploy` method
7+
68

79
# 0.39.0
810

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,11 @@ For example:
357357
fetch:
358358
curl --silent https://app.example.com/services/ping/version
359359
```
360+
361+
**Note:** Currently, deployments in emergency mode are configured to occur concurrently via [the `build_deploy` method](https://github.com/Shopify/shipit-engine/blob/main/app/models/shipit/stack.rb),
362+
whose `allow_concurrency` keyword argument defaults to `force`, where `force` is true when emergency mode is enabled.
363+
If you'd like to separate these two from one another, override this method as desired in your service.
364+
360365
<h3 id="kubernetes">Kubernetes</h3>
361366

362367
**<code>kubernetes</code>** allows to specify a Kubernetes namespace and context to deploy to.

app/controllers/shipit/api/deploys_controller.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,16 @@ def index
1111
params do
1212
requires :sha, String, length: { in: 6..40 }
1313
accepts :force, Boolean, default: false
14+
accepts :allow_concurrency, Boolean
1415
accepts :require_ci, Boolean, default: false
1516
accepts :env, Hash, default: {}
1617
end
1718
def create
1819
commit = stack.commits.by_sha(params.sha) || param_error!(:sha, 'Unknown revision')
1920
param_error!(:force, "Can't deploy a locked stack") if !params.force && stack.locked?
2021
param_error!(:require_ci, "Commit is not deployable") if params.require_ci && !commit.deployable?
21-
deploy = stack.trigger_deploy(commit, current_user, env: params.env, force: params.force)
22+
deploy = stack.trigger_deploy(commit, current_user, env: params.env, force: params.force,
23+
allow_concurrency: params.allow_concurrency || params.force)
2224
render_resource(deploy, status: :accepted)
2325
end
2426
end

app/models/shipit/stack.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,14 @@ def trigger_task(definition_id, user, env: nil, force: false)
150150
task
151151
end
152152

153-
def build_deploy(until_commit, user, env: nil, force: false)
153+
def build_deploy(until_commit, user, env: nil, force: false, allow_concurrency: force)
154154
since_commit = last_deployed_commit.presence || commits.first
155155
deploys.build(
156156
user_id: user.id,
157157
until_commit: until_commit,
158158
since_commit: since_commit,
159159
env: filter_deploy_envs(env&.to_h || {}),
160-
allow_concurrency: force,
160+
allow_concurrency: allow_concurrency,
161161
ignored_safeties: force || !until_commit.deployable?,
162162
max_retries: retries_on_deploy,
163163
)

0 commit comments

Comments
 (0)