Commit 15136825 authored by Thong Kuah's avatar Thong Kuah

Merge branch 'sh-handle-deployments-no-pods' into 'master'

Fix 500 error loading environments index

Closes #216118

See merge request gitlab-org/gitlab!31184
parents b1fdc87d 4b57dfad
---
title: Fix 500 error loading environments index
merge_request: 31184
author:
type: fixed
......@@ -25,8 +25,7 @@ module EE
project = environment.project
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) if data[:pods]&.any?
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: pods, legacy_deployments: legacy_deployments)
......
......@@ -67,6 +67,17 @@ describe Clusters::Platforms::Kubernetes do
end
end
context 'deployment with no pods' do
let(:deployment) { kube_deployment(name: 'some-deployment', environment_slug: environment.slug, project_slug: project.full_path_slug) }
let(:deployments) { [deployment] }
let(:pods) { [] }
it 'returns a valid status with matching deployments' do
expect(rollout_status).to be_kind_of(::Gitlab::Kubernetes::RolloutStatus)
expect(rollout_status.deployments.map(&:name)).to contain_exactly('some-deployment')
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) }
......
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