Commit 7ee20cb9 authored by Thong Kuah's avatar Thong Kuah

Merge branch 'remove-dedupe-instances-feature-flag' into 'master'

Rollout Deploy Board Duplicate Instances Fix to Self-Managed

See merge request gitlab-org/gitlab!46374
parents 18cbc266 264a850a
---
name: deploy_boards_dedupe_instances
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/40768
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/258214
type: development
group: group::progressive delivery
default_enabled: false
...@@ -41,9 +41,9 @@ knowledge. In particular, you should be familiar with: ...@@ -41,9 +41,9 @@ knowledge. In particular, you should be familiar with:
- [Kubernetes namespaces](https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/) - [Kubernetes namespaces](https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/)
- [Kubernetes canary deployments](https://kubernetes.io/docs/concepts/cluster-administration/manage-deployment/#canary-deployments) - [Kubernetes canary deployments](https://kubernetes.io/docs/concepts/cluster-administration/manage-deployment/#canary-deployments)
NOTE: **Note:** In GitLab 13.5 and earlier, apps that consist of multiple deployments are shown as
Apps that consist of multiple deployments are shown as duplicates on the deploy board. duplicates on the deploy board. This is [fixed](https://gitlab.com/gitlab-org/gitlab/-/issues/8463)
Follow [this issue](https://gitlab.com/gitlab-org/gitlab/-/issues/8463) for details. in GitLab 13.6.
## Use cases ## Use cases
......
---
title: Fix duplicate instances in deploy boards when multiple deployments have the same track
merge_request: 46374
author:
type: fixed
...@@ -54,13 +54,7 @@ module Gitlab ...@@ -54,13 +54,7 @@ module Gitlab
def initialize(deployments, pods: [], ingresses: [], status: :found) def initialize(deployments, pods: [], ingresses: [], status: :found)
@status = status @status = status
@deployments = deployments @deployments = deployments
@instances = RolloutInstances.new(deployments, pods).pod_instances
@instances = if ::Feature.enabled?(:deploy_boards_dedupe_instances)
RolloutInstances.new(deployments, pods).pod_instances
else
deployments.flat_map(&:instances)
end
@canary_ingress = ingresses.find(&:canary?) @canary_ingress = ingresses.find(&:canary?)
@completion = @completion =
......
...@@ -30,7 +30,6 @@ RSpec.describe Gitlab::Kubernetes::RolloutStatus do ...@@ -30,7 +30,6 @@ RSpec.describe Gitlab::Kubernetes::RolloutStatus do
subject(:rollout_status) { described_class.from_deployments(*specs, pods_attrs: pods, ingresses: ingresses) } subject(:rollout_status) { described_class.from_deployments(*specs, pods_attrs: pods, ingresses: ingresses) }
shared_examples 'rollout status' do
describe '#deployments' do describe '#deployments' do
it 'stores the deployments' do it 'stores the deployments' do
expect(rollout_status.deployments).to be_kind_of(Array) expect(rollout_status.deployments).to be_kind_of(Array)
...@@ -148,6 +147,17 @@ RSpec.describe Gitlab::Kubernetes::RolloutStatus do ...@@ -148,6 +147,17 @@ RSpec.describe Gitlab::Kubernetes::RolloutStatus do
expect(rollout_status.completion).to eq(0) expect(rollout_status.completion).to eq(0)
end end
it 'sets the completion percentage when a quarter of the pods are complete' do
deployments = [
kube_deployment(name: 'one', track: 'stable', replicas: 6),
kube_deployment(name: 'two', track: 'stable', replicas: 2)
]
pods = create_pods(name: 'one', track: 'stable', count: 2)
rollout_status = described_class.from_deployments(*deployments, pods_attrs: pods)
expect(rollout_status.completion).to eq(25)
end
end end
context 'with two deployments, one with track set to "stable" and one with no track label' do context 'with two deployments, one with track set to "stable" and one with no track label' do
...@@ -171,6 +181,17 @@ RSpec.describe Gitlab::Kubernetes::RolloutStatus do ...@@ -171,6 +181,17 @@ RSpec.describe Gitlab::Kubernetes::RolloutStatus do
expect(rollout_status.completion).to eq(0) expect(rollout_status.completion).to eq(0)
end end
it 'sets the completion percentage when a third of the pods are complete' do
deployments = [
kube_deployment(name: 'one', track: 'stable', replicas: 2),
kube_deployment(name: 'two', track: nil, replicas: 7)
]
pods = create_pods(name: 'one', track: 'stable', count: 2) + create_pods(name: 'two', track: nil, count: 1)
rollout_status = described_class.from_deployments(*deployments, pods_attrs: pods)
expect(rollout_status.completion).to eq(33)
end
end end
end end
...@@ -243,47 +264,6 @@ RSpec.describe Gitlab::Kubernetes::RolloutStatus do ...@@ -243,47 +264,6 @@ RSpec.describe Gitlab::Kubernetes::RolloutStatus do
end end
end end
end end
end
context 'deploy_boards_dedupe_instances is disabled' do
before do
stub_feature_flags(deploy_boards_dedupe_instances: false)
end
it_behaves_like 'rollout status'
end
context 'deploy_boards_dedupe_instances is enabled' do
before do
stub_feature_flags(deploy_boards_dedupe_instances: true)
end
it_behaves_like 'rollout status'
describe '#completion' do
it 'sets the completion percentage when a quarter of the pods are complete' do
deployments = [
kube_deployment(name: 'one', track: 'stable', replicas: 6),
kube_deployment(name: 'two', track: 'stable', replicas: 2)
]
pods = create_pods(name: 'one', track: 'stable', count: 2)
rollout_status = described_class.from_deployments(*deployments, pods_attrs: pods)
expect(rollout_status.completion).to eq(25)
end
it 'sets the completion percentage when a third of the pods are complete' do
deployments = [
kube_deployment(name: 'one', track: 'stable', replicas: 2),
kube_deployment(name: 'two', track: nil, replicas: 7)
]
pods = create_pods(name: 'one', track: 'stable', count: 2) + create_pods(name: 'two', track: nil, count: 1)
rollout_status = described_class.from_deployments(*deployments, pods_attrs: pods)
expect(rollout_status.completion).to eq(33)
end
end
end
def create_pods(name:, count:, track: nil, status: 'Running' ) def create_pods(name:, count:, track: nil, status: 'Running' )
Array.new(count, kube_pod(name: name, status: status, track: track)) Array.new(count, kube_pod(name: name, status: status, track: track))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment