Commit 0adaf882 authored by Ash McKenzie's avatar Ash McKenzie

Merge branch 'remove-support-for-app-label-matching' into 'master'

[EE] Removes support for matching on `app` label

See merge request gitlab-org/gitlab-ee!14020
parents acd622c6 db7185cf
......@@ -86,8 +86,7 @@ To display the Deploy Boards for a specific [environment] you should:
Kubernetes.
NOTE: **Note:**
The Kubernetes label of `app` is deprecated and may be removed in next major
release, GitLab 12.0.
Matching based on the Kubernetes `app` label was removed in [GitLab 12.1](https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/14020)
![Deploy Boards Kubernetes Label](img/deploy_boards_kubernetes_label.png)
......
---
title: Removes support for matching on app label for Kubernetes deploy boards,
terminals, and pod logs
merge_request: 14020
author:
type: removed
......@@ -5,8 +5,8 @@ module Gitlab
# Calculates the rollout status for a set of kubernetes deployments.
#
# A GitLab environment may be composed of several Kubernetes deployments and
# other resources, unified by an `app=` label. The rollout status sums the
# Kubernetes deployments together.
# other resources. The rollout status sums the Kubernetes deployments
# together.
class RolloutStatus
attr_reader :deployments, :instances, :completion, :status
......
......@@ -12,6 +12,59 @@ describe KubernetesService, models: true, use_clean_rails_memory_store_caching:
subject(:rollout_status) { service.rollout_status(environment) }
context 'legacy deployments based on app label' do
let(:legacy_deployment) do
kube_deployment(name: 'legacy-deployment').tap do |deployment|
deployment['metadata']['annotations'].delete('app.gitlab.com/env')
deployment['metadata']['annotations'].delete('app.gitlab.com/app')
deployment['metadata']['labels']['app'] = environment.slug
end
end
let(:legacy_pod) do
kube_pod(name: 'legacy-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
context 'only legacy deployments' do
before do
stub_reactive_cache(
service,
deployments: [legacy_deployment],
pods: [legacy_pod]
)
end
it 'contains nothing' do
expect(rollout_status).to be_kind_of(::Gitlab::Kubernetes::RolloutStatus)
expect(rollout_status.deployments).to eq([])
end
end
context 'new deployment based on annotations' do
let(:matched_deployment) { kube_deployment(name: 'matched-deployment', environment_slug: environment.slug, project_slug: project.full_path_slug) }
let(:matched_pod) { kube_pod(environment_slug: environment.slug, project_slug: project.full_path_slug) }
before do
stub_reactive_cache(
service,
deployments: [matched_deployment, legacy_deployment],
pods: [matched_pod, legacy_pod]
)
end
it 'contains only matching deployments' do
expect(rollout_status).to be_kind_of(::Gitlab::Kubernetes::RolloutStatus)
expect(rollout_status.deployments.map(&:name)).to contain_exactly('matched-deployment')
end
end
end
context 'with valid deployments' do
let(:matched_deployment) { kube_deployment(environment_slug: environment.slug, project_slug: project.full_path_slug) }
let(:unmatched_deployment) { kube_deployment }
......@@ -38,7 +91,8 @@ describe KubernetesService, models: true, use_clean_rails_memory_store_caching:
before do
stub_reactive_cache(
service,
deployments: []
deployments: [],
pods: []
)
end
......
......@@ -37,15 +37,10 @@ module Gitlab
# Filters an array of pods (as returned by the kubernetes API) by their project and environment
def filter_by_project_environment(items, app, env)
pods = filter_by_annotation(items, {
filter_by_annotation(items, {
'app.gitlab.com/app' => app,
'app.gitlab.com/env' => env
})
return pods unless pods.empty?
filter_by_label(items, {
'app' => env, # deprecated: replaced by app.gitlab.com/env
})
end
# Converts a pod (as returned by the kubernetes API) into a terminal
......
......@@ -59,16 +59,6 @@ describe Gitlab::Kubernetes do
describe '#filter_by_project_environment' do
let(:matching_pod) { kube_pod(environment_slug: 'production', project_slug: 'my-cool-app') }
it 'returns matching legacy env label' do
matching_pod['metadata']['annotations'].delete('app.gitlab.com/app')
matching_pod['metadata']['annotations'].delete('app.gitlab.com/env')
matching_pod['metadata']['labels']['app'] = 'production'
matching_items = [matching_pod]
items = matching_items + [kube_pod]
expect(filter_by_project_environment(items, 'my-cool-app', 'production')).to eq(matching_items)
end
it 'returns matching env label' do
matching_items = [matching_pod]
items = matching_items + [kube_pod]
......
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