diff --git a/CHANGELOG.md b/CHANGELOG.md index ba8a009f4..0a5c3c017 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ * Migrate from legacy Rails secrets to credentials (#1326) * Rails secrets were [deprecated in Rails 7.1](https://github.com/rails/rails/pull/48472) * [Guide on credentials](https://guides.rubyonrails.org/security.html#custom-credentials) +* 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 + # 0.39.0 diff --git a/README.md b/README.md index e8a6f17f1..a48fa65e7 100644 --- a/README.md +++ b/README.md @@ -357,6 +357,11 @@ For example: fetch: curl --silent https://app.example.com/services/ping/version ``` + +**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), +whose `allow_concurrency` keyword argument defaults to `force`, where `force` is true when emergency mode is enabled. +If you'd like to separate these two from one another, override this method as desired in your service. +

Kubernetes

**kubernetes** allows to specify a Kubernetes namespace and context to deploy to. diff --git a/app/controllers/shipit/deploys_controller.rb b/app/controllers/shipit/deploys_controller.rb index 730c5d6c3..6665043b0 100644 --- a/app/controllers/shipit/deploys_controller.rb +++ b/app/controllers/shipit/deploys_controller.rb @@ -27,6 +27,7 @@ def create current_user, env: deploy_params[:env], force: params[:force].present?, + allow_concurrency: params[:allow_concurrency].present?, ) respond_with(@deploy.stack, @deploy) rescue Task::ConcurrentTaskRunning diff --git a/app/models/shipit/stack.rb b/app/models/shipit/stack.rb index 4f2642f89..23767f254 100644 --- a/app/models/shipit/stack.rb +++ b/app/models/shipit/stack.rb @@ -150,14 +150,14 @@ def trigger_task(definition_id, user, env: nil, force: false) task end - def build_deploy(until_commit, user, env: nil, force: false) + def build_deploy(until_commit, user, env: nil, force: false, allow_concurrency: force) since_commit = last_deployed_commit.presence || commits.first deploys.build( user_id: user.id, until_commit: until_commit, since_commit: since_commit, env: filter_deploy_envs(env&.to_h || {}), - allow_concurrency: force, + allow_concurrency: allow_concurrency, ignored_safeties: force || !until_commit.deployable?, max_retries: retries_on_deploy, ) diff --git a/test/models/deploys_test.rb b/test/models/deploys_test.rb index 51e120cf6..670f28d9b 100644 --- a/test/models/deploys_test.rb +++ b/test/models/deploys_test.rb @@ -960,7 +960,7 @@ def generate_commits(amount:, stack_id:, user_id:, validate:) assert_difference -> { ReleaseStatus.count }, +1 do assert_equal 'unknown', @commit.last_release_status.state - @deploy = @stack.trigger_deploy(@commit, AnonymousUser.new, force: true) + @deploy = @stack.trigger_deploy(@commit, AnonymousUser.new, force: true, allow_concurrency: true) assert_equal 'pending', @commit.last_release_status.state end end diff --git a/test/models/shipit/stack_test.rb b/test/models/shipit/stack_test.rb index a65e82efe..740746258 100644 --- a/test/models/shipit/stack_test.rb +++ b/test/models/shipit/stack_test.rb @@ -279,7 +279,7 @@ def self.deliver(event, stack, payload) end test "#active_task? is false if stack has a concurrent deploy in active state" do - @stack.trigger_deploy(shipit_commits(:third), AnonymousUser.new, force: true) + @stack.trigger_deploy(shipit_commits(:third), AnonymousUser.new, force: true, allow_concurrency: true) refute @stack.active_task? end