Commit c1387ac8 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch '33899-remove-history-cache-ff' into 'master'

Remove cache_vulnerability_history feature flag

See merge request gitlab-org/gitlab!21349
parents 711c4bec d18ab4b8
......@@ -27,9 +27,9 @@ module Security
# Silently swallow errors if there are any problems caching vulnerabilities
def cache_vulnerabilities
project = @pipeline.project
if Feature.enabled?(:cache_vulnerability_history, project.group)
Gitlab::Vulnerabilities::HistoryCache.new(project.group, project.id).fetch(Gitlab::Vulnerabilities::History::HISTORY_RANGE, force: true)
end
Gitlab::Vulnerabilities::HistoryCache.new(project.group, project.id)
.fetch(Gitlab::Vulnerabilities::History::HISTORY_RANGE, force: true)
rescue => err
error("Failed to cache vulnerabilities for pipeline #{@pipeline.id}: #{err}")
end
......
---
title: Cache vulnerability findings history endpoint for security dashboards
merge_request: 21349
author:
type: added
......@@ -15,7 +15,7 @@ module Gitlab
end
def findings_counter
return cached_vulnerability_history if use_vulnerability_cache?
return cached_vulnerability_history unless dynamic_filters_included?
findings = vulnerability_findings.count_by_day_and_severity(HISTORY_RANGE)
::Vulnerabilities::HistorySerializer.new.represent(findings)
......@@ -48,10 +48,6 @@ module Gitlab
history
end
def use_vulnerability_cache?
Feature.enabled?(:cache_vulnerability_history, group) && !dynamic_filters_included?
end
def dynamic_filters_included?
dynamic_filters = [:report_type, :confidence, :severity]
filters.keys.any? { |key| dynamic_filters.include?(key.to_sym) }
......
......@@ -16,30 +16,6 @@ describe Gitlab::Vulnerabilities::History do
describe '#findings_counter', :use_clean_rails_memory_store_caching do
subject(:counter) { described_class.new(group, filters).findings_counter }
context 'feature disabled' do
before do
stub_feature_flags(cache_vulnerability_history: false)
end
it 'does not call Gitlab::Vulnerabilities::HistoryCache' do
expect(Gitlab::Vulnerabilities::HistoryCache).not_to receive(:new)
counter
end
it 'returns the proper format for the history' do
Timecop.freeze do
expect(counter[:total]).to eq({ Date.today => 3 })
expect(counter[:high]).to eq({ Date.today => 2 })
end
end
end
context 'feature enabled' do
before do
stub_feature_flags(cache_vulnerability_history: true)
end
context 'filters are passed' do
let(:filters) { { report_type: :sast } }
......@@ -79,7 +55,6 @@ describe Gitlab::Vulnerabilities::History do
end
end
end
end
def create_vulnerabilities(count, project, options = {})
report_type = options[:report_type] || :sast
......
......@@ -62,23 +62,6 @@ describe Security::StoreReportsService do
expect { subject }.not_to raise_error
end
context 'feature disabled' do
before do
stub_feature_flags(cache_vulnerability_history: false)
end
it 'does not cache vulnerability history' do
expect_any_instance_of(Gitlab::Vulnerabilities::HistoryCache).not_to receive(:fetch)
subject
end
end
context 'feature enabled' do
before do
stub_feature_flags(cache_vulnerability_history: true)
end
it 'caches vulnerability history' do
expect_any_instance_of(Gitlab::Vulnerabilities::HistoryCache).to receive(:fetch)
......@@ -86,5 +69,4 @@ describe Security::StoreReportsService do
end
end
end
end
end
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