Commit 4066a1bc authored by Thong Kuah's avatar Thong Kuah

Stop matching on legacy app label

From now on, only match on the annotations, instead of falling back to
legacy app label. This enables users to use the app label for other
purposes such as helm charts.
parent a62fdae5
---
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
......
......@@ -38,10 +38,10 @@ describe KubernetesService, models: true, use_clean_rails_memory_store_caching:
)
end
it 'contains legacy deployments' do
it 'contains nothing' do
expect(rollout_status).to be_kind_of(::Gitlab::Kubernetes::RolloutStatus)
expect(rollout_status.deployments.map(&:name)).to contain_exactly('legacy-deployment')
expect(rollout_status.deployments).to eq([])
end
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