Commit d9cacdc2 authored by Thong Kuah's avatar Thong Kuah

Merge branch 'remove_support_for_showing_app_label_warning' into 'master'

Removes fallback warning for legacy deploy board labels

See merge request gitlab-org/gitlab!43376
parents 3934a31b d1535ead
......@@ -184,7 +184,6 @@ export default {
:deploy-boards-help-path="deployBoardsHelpPath"
:is-loading="model.isLoadingDeployBoard"
:is-empty="model.isEmptyDeployBoard"
:has-legacy-app-label="model.hasLegacyAppLabel"
:logs-path="model.logs_path"
/>
</div>
......
......@@ -17,7 +17,7 @@ import {
GlSafeHtmlDirective as SafeHtml,
} from '@gitlab/ui';
import deployBoardSvg from 'ee_empty_states/icons/_deploy_board.svg';
import { n__, s__, sprintf } from '~/locale';
import { n__ } from '~/locale';
import { STATUS_MAP, CANARY_STATUS } from '../constants';
export default {
......@@ -53,27 +53,11 @@ export default {
required: false,
default: '',
},
hasLegacyAppLabel: {
type: Boolean,
required: false,
default: false,
},
},
computed: {
canRenderDeployBoard() {
return !this.isEmpty && !isEmpty(this.deployBoardData);
},
legacyLabelWarningMessage() {
return sprintf(
s__(
'DeployBoard|Matching on the %{appLabel} label has been removed for deploy boards. To see all instances on your board, you must update your chart and redeploy.',
),
{
appLabel: '<code>app</code>',
},
false,
);
},
canRenderEmptyState() {
return this.isEmpty;
},
......@@ -117,13 +101,6 @@ export default {
<div class="js-deploy-board deploy-board">
<gl-loading-icon v-if="isLoading" class="loading-icon" />
<template v-else>
<div v-if="hasLegacyAppLabel" class="bs-callout bs-callout-warning mb-0 mt-0">
<span v-safe-html="legacyLabelWarningMessage"></span>
<gl-link target="_blank" :href="deployBoardsHelpPath">
<strong>{{ __('More Information') }}</strong>
</gl-link>
</div>
<div v-if="canRenderDeployBoard" class="deploy-board-information p-3">
<div class="deploy-board-information">
<section class="deploy-board-status">
......
......@@ -18,7 +18,6 @@ export const setDeployBoard = (oldEnvironmentState, environment) => {
environment.rollout_status.status === 'found' ? environment.rollout_status : {},
isLoadingDeployBoard: environment.rollout_status.status === 'loading',
isEmptyDeployBoard: environment.rollout_status.status === 'not_found',
hasLegacyAppLabel: environment.rollout_status.has_legacy_app_label,
};
}
return parsedEnvironment;
......
......@@ -26,9 +26,8 @@ module EE
deployments = filter_by_project_environment(data[:deployments], project.full_path_slug, environment.slug)
pods = filter_by_project_environment(data[:pods], project.full_path_slug, environment.slug)
legacy_deployments = filter_by_legacy_label(data[:deployments], project.full_path_slug, environment.slug)
::Gitlab::Kubernetes::RolloutStatus.from_deployments(*deployments, pods_attrs: pods, legacy_deployments: legacy_deployments)
::Gitlab::Kubernetes::RolloutStatus.from_deployments(*deployments, pods_attrs: pods)
end
private
......
......@@ -4,7 +4,11 @@ class RolloutStatusEntity < Grape::Entity
include RequestAwareEntity
expose :status, as: :status
expose :has_legacy_app_label?, as: :has_legacy_app_label
# To be removed in API v5
expose :has_legacy_app_label do |_rollout_status|
false
end
expose :instances, if: -> (rollout_status, _) { rollout_status.found? }
expose :completion, if: -> (rollout_status, _) { rollout_status.found? }
......
---
title: Removes fallback warning for legacy deploy board labels
merge_request: 43376
author:
type: changed
......@@ -22,31 +22,26 @@ module Gitlab
@status == :not_found
end
def has_legacy_app_label?
legacy_deployments.present?
end
def found?
@status == :found
end
def self.from_deployments(*deployments, pods_attrs: [], legacy_deployments: [])
return new([], status: :not_found, legacy_deployments: legacy_deployments) if deployments.empty?
def self.from_deployments(*deployments, pods_attrs: {})
return new([], status: :not_found) if deployments.empty?
deployments = deployments.map { |deploy| ::Gitlab::Kubernetes::Deployment.new(deploy, pods: pods_attrs) }
deployments.sort_by!(&:order)
new(deployments, legacy_deployments: legacy_deployments)
new(deployments)
end
def self.loading
new([], status: :loading)
end
def initialize(deployments, status: :found, legacy_deployments: [])
def initialize(deployments, status: :found)
@status = status
@deployments = deployments
@instances = deployments.flat_map(&:instances)
@legacy_deployments = legacy_deployments
@completion =
if @instances.empty?
......@@ -58,10 +53,6 @@ module Gitlab
(finished / @instances.count.to_f * 100).to_i
end
end
private
attr_reader :legacy_deployments
end
end
end
......@@ -89,28 +89,6 @@ describe('Deploy Board', () => {
});
});
describe('with hasLegacyAppLabel equal true', () => {
beforeEach(done => {
wrapper = createComponent({
isLoading: false,
isEmpty: false,
logsPath,
hasLegacyAppLabel: true,
deployBoardData: {},
});
wrapper.vm.$nextTick(done);
});
it('should render legacy label warning message', () => {
const warningMessage = wrapper.find('.bs-callout-warning');
expect(warningMessage).toBeTruthy();
expect(warningMessage.text()).toContain(
'Matching on the app label has been removed for deploy boards.',
);
});
});
describe('has legend component', () => {
let statuses = [];
beforeEach(done => {
......@@ -118,7 +96,6 @@ describe('Deploy Board', () => {
isLoading: false,
isEmpty: false,
logsPath: environment.log_path,
hasLegacyAppLabel: true,
deployBoardData: deployBoardMockData,
});
({ statuses } = wrapper.vm);
......
......@@ -60,26 +60,6 @@ describe('Store', () => {
expect(store.state.environments[0].deployBoardData).toEqual(deployBoardMockData);
});
it('should set hasLegacyAppLabel property', () => {
expect(store.state.environments[0].deployBoardData).toEqual(deployBoardMockData);
const environment = {
name: 'foo',
size: 1,
latest: {
id: 1,
},
rollout_status: {
...deployBoardMockData,
status: 'not_found',
has_legacy_app_label: true,
},
};
store.storeEnvironments([environment]);
expect(store.state.environments[0].hasLegacyAppLabel).toBe(true);
});
});
describe('canaryCallout', () => {
......
......@@ -7,7 +7,6 @@ RSpec.describe Gitlab::Kubernetes::RolloutStatus do
let(:track) { nil }
let(:specs) { specs_all_finished }
let(:legacy_deployments) { [] }
let(:pods) do
create_pods(name: "one", count: 3, track: 'stable') + create_pods(name: "two", count: 3, track: "canary")
......@@ -27,26 +26,7 @@ RSpec.describe Gitlab::Kubernetes::RolloutStatus do
]
end
subject(:rollout_status) { described_class.from_deployments(*specs, pods_attrs: pods, legacy_deployments: legacy_deployments) }
describe '#has_legacy_app_label?' do
let(:specs) { [] }
let(:pods) { [] }
context 'no legacy deployments' do
it { is_expected.not_to be_has_legacy_app_label }
end
context 'with legacy deployment' do
let(:legacy_deployments) do
[
kube_deployment(name: 'legacy')
]
end
it { is_expected.to be_has_legacy_app_label }
end
end
subject(:rollout_status) { described_class.from_deployments(*specs, pods_attrs: pods) }
describe '#deployments' do
it 'stores the deployments' do
......
......@@ -61,10 +61,6 @@ RSpec.describe Clusters::Platforms::Kubernetes do
expect(rollout_status.deployments).to eq([])
end
it 'has the has_legacy_app_label flag' do
expect(rollout_status).to be_has_legacy_app_label
end
end
context 'deployment with no pods' do
......@@ -89,35 +85,6 @@ RSpec.describe Clusters::Platforms::Kubernetes do
expect(rollout_status.deployments.map(&:name)).to contain_exactly('matched-deployment')
end
it 'does have the has_legacy_app_label flag' do
expect(rollout_status).to be_has_legacy_app_label
end
end
context 'deployment with app label not matching the environment' do
let(:other_deployment) do
kube_deployment(name: 'other-deployment').tap do |deployment|
deployment['metadata']['annotations'].delete('app.gitlab.com/env')
deployment['metadata']['annotations'].delete('app.gitlab.com/app')
deployment['metadata']['labels']['app'] = 'helm-app-label'
end
end
let(:other_pod) do
kube_pod(name: 'other-pod').tap do |pod|
pod['metadata']['annotations'].delete('app.gitlab.com/env')
pod['metadata']['annotations'].delete('app.gitlab.com/app')
pod['metadata']['labels']['app'] = environment.slug
end
end
let(:deployments) { [other_deployment] }
let(:pods) { [other_pod] }
it 'does not have the has_legacy_app_label flag' do
expect(rollout_status).not_to be_has_legacy_app_label
end
end
end
......
......@@ -8595,9 +8595,6 @@ msgstr ""
msgid "Deploy to..."
msgstr ""
msgid "DeployBoard|Matching on the %{appLabel} label has been removed for deploy boards. To see all instances on your board, you must update your chart and redeploy."
msgstr ""
msgid "DeployFreeze|Freeze end"
msgstr ""
......
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