Commit 1d07b548 authored by Reuben Pereira's avatar Reuben Pereira Committed by Thong Kuah

Remove the pod_logs_reactive_cache feature flag

Now that the frontend polls the pod logs API, we can enable reactive
caching for the API, which was behind the feature flag.
parent 7009eca0
---
title: Fix pod logs failure when pod contains more than 1 container
merge_request: 18574
author:
type: fixed
...@@ -27,17 +27,13 @@ module EE ...@@ -27,17 +27,13 @@ module EE
end end
def read_pod_logs(pod_name, namespace, container: nil) def read_pod_logs(pod_name, namespace, container: nil)
if ::Feature.enabled?(:pod_logs_reactive_cache) with_reactive_cache(
with_reactive_cache( 'get_pod_log',
'get_pod_log', 'pod_name' => pod_name,
'pod_name' => pod_name, 'namespace' => namespace,
'namespace' => namespace, 'container' => container
'container' => container ) do |result|
) do |result| result
result
end
else
pod_logs(pod_name, namespace, container: container)
end end
end end
...@@ -59,13 +55,11 @@ module EE ...@@ -59,13 +55,11 @@ module EE
private private
def pod_logs(pod_name, namespace, container: nil) def pod_logs(pod_name, namespace, container: nil)
handle_exceptions(_('Pod not found')) do logs = kubeclient.get_pod_log(
logs = kubeclient.get_pod_log( pod_name, namespace, container: container, tail_lines: LOGS_LIMIT
pod_name, namespace, container: container, tail_lines: LOGS_LIMIT ).body
).body
{ logs: logs, status: :success } { logs: logs, status: :success }
end
end end
def handle_exceptions(resource_not_found_error_message, &block) def handle_exceptions(resource_not_found_error_message, &block)
......
...@@ -16,21 +16,18 @@ describe 'Environment > Pod Logs', :js do ...@@ -16,21 +16,18 @@ describe 'Environment > Pod Logs', :js do
before do before do
stub_licensed_features(pod_logs: true) stub_licensed_features(pod_logs: true)
# We're setting this feature flag to false since the FE does not support it
# as yet.
stub_feature_flags(pod_logs_reactive_cache: false)
create(:cluster, :provided_by_gcp, environment_scope: '*', projects: [project]) create(:cluster, :provided_by_gcp, environment_scope: '*', projects: [project])
create(:deployment, :success, environment: environment) create(:deployment, :success, environment: environment)
stub_kubeclient_logs(pod_name, environment.deployment_namespace, container: nil) stub_kubeclient_pod_details(pod_name, environment.deployment_namespace)
stub_kubeclient_logs(pod_name, environment.deployment_namespace, container: 'container-0')
allow_any_instance_of(EE::Environment).to receive(:pod_names).and_return(pod_names) allow_any_instance_of(EE::Environment).to receive(:pod_names).and_return(pod_names)
sign_in(project.owner) sign_in(project.owner)
end end
context 'with logs' do context 'with logs', :use_clean_rails_memory_store_caching do
it "shows pod logs" do it "shows pod logs" do
visit logs_project_environment_path(environment.project, environment, pod_name: pod_name) visit logs_project_environment_path(environment.project, environment, pod_name: pod_name)
......
...@@ -150,7 +150,11 @@ describe Clusters::Platforms::Kubernetes do ...@@ -150,7 +150,11 @@ describe Clusters::Platforms::Kubernetes do
end end
end end
shared_examples 'k8s responses' do context 'with reactive cache' do
before do
synchronous_reactive_cache(service)
end
context 'when kubernetes responds with valid logs' do context 'when kubernetes responds with valid logs' do
before do before do
stub_kubeclient_logs(pod_name, namespace, container: container) stub_kubeclient_logs(pod_name, namespace, container: container)
...@@ -201,34 +205,6 @@ describe Clusters::Platforms::Kubernetes do ...@@ -201,34 +205,6 @@ describe Clusters::Platforms::Kubernetes do
it_behaves_like 'resource not found error', 'Pod not found' it_behaves_like 'resource not found error', 'Pod not found'
end end
end
context 'without pod_logs_reactive_cache feature flag' do
before do
stub_feature_flags(pod_logs_reactive_cache: false)
end
it_behaves_like 'k8s responses'
context 'when container name is not specified' do
subject { service.read_pod_logs(pod_name, namespace) }
before do
stub_kubeclient_logs(pod_name, namespace, container: nil)
end
include_examples 'successful log request'
end
end
context 'with pod_logs_reactive_cache feature flag' do
before do
stub_feature_flags(pod_logs_reactive_cache: true)
synchronous_reactive_cache(service)
end
it_behaves_like 'k8s responses'
context 'when container name is not specified' do context 'when container name is not specified' do
subject { service.read_pod_logs(pod_name, namespace) } subject { service.read_pod_logs(pod_name, namespace) }
...@@ -247,10 +223,6 @@ describe Clusters::Platforms::Kubernetes do ...@@ -247,10 +223,6 @@ describe Clusters::Platforms::Kubernetes do
['get_pod_log', { 'pod_name' => pod_name, 'namespace' => namespace, 'container' => container }] ['get_pod_log', { 'pod_name' => pod_name, 'namespace' => namespace, 'container' => container }]
end end
before do
stub_feature_flags(pod_logs_reactive_cache: true)
end
context 'result is cacheable' do context 'result is cacheable' do
before do before do
stub_kubeclient_logs(pod_name, namespace, container: container) stub_kubeclient_logs(pod_name, namespace, container: container)
......
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