diff options
author | Kamil TrzciĆski <ayufan@ayufan.eu> | 2018-12-27 09:58:41 +0000 |
---|---|---|
committer | GitLab Release Tools Bot <robert+release-tools@gitlab.com> | 2019-01-02 17:36:21 +0000 |
commit | 019f616c7275db84a798dd933ac7d3317ffa0b50 (patch) | |
tree | 895a480862cd26a8c0fc00b946e271c24e1a4227 | |
parent | 15627ccb09aec7601af29c842448ccaeaf112aa2 (diff) | |
download | gitlab-ce-019f616c7275db84a798dd933ac7d3317ffa0b50.tar.gz |
Merge branch '55551-nomethoderror-undefined-method-for-nil-nilclass' into 'master'
Handle nil terminals in Clusters::Platforms::Kubernetes
Closes #55551
See merge request gitlab-org/gitlab-ce!23925
(cherry picked from commit 6b02f502c84450d5e23866fef0d3da600d7c78ae)
6d4c2529 Handle nil terminals in Clusters::Platforms::Kubernetes
-rw-r--r-- | app/models/clusters/platforms/kubernetes.rb | 2 | ||||
-rw-r--r-- | spec/models/clusters/platforms/kubernetes_spec.rb | 3 |
2 files changed, 3 insertions, 2 deletions
diff --git a/app/models/clusters/platforms/kubernetes.rb b/app/models/clusters/platforms/kubernetes.rb index 867f0edcb07..e06cb9be89f 100644 --- a/app/models/clusters/platforms/kubernetes.rb +++ b/app/models/clusters/platforms/kubernetes.rb @@ -106,7 +106,7 @@ module Clusters def terminals(environment) with_reactive_cache do |data| pods = filter_by_label(data[:pods], app: environment.slug) - terminals = pods.flat_map { |pod| terminals_for_pod(api_url, actual_namespace, pod) } + terminals = pods.flat_map { |pod| terminals_for_pod(api_url, actual_namespace, pod) }.compact terminals.each { |terminal| add_terminal_auth(terminal, terminal_auth) } end end diff --git a/spec/models/clusters/platforms/kubernetes_spec.rb b/spec/models/clusters/platforms/kubernetes_spec.rb index 062d2fd0768..b30f80a4b3e 100644 --- a/spec/models/clusters/platforms/kubernetes_spec.rb +++ b/spec/models/clusters/platforms/kubernetes_spec.rb @@ -325,12 +325,13 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching context 'with valid pods' do let(:pod) { kube_pod(app: environment.slug) } + let(:pod_with_no_terminal) { kube_pod(app: environment.slug, status: "Pending") } let(:terminals) { kube_terminals(service, pod) } before do stub_reactive_cache( service, - pods: [pod, pod, kube_pod(app: "should-be-filtered-out")] + pods: [pod, pod, pod_with_no_terminal, kube_pod(app: "should-be-filtered-out")] ) end |