Commit d18ab4b8 authored by Avielle Wolfe's avatar Avielle Wolfe Committed by Douglas Barbosa Alexandre

Remove cache_vulnerability_history feature flag

The `gitlab-org` and `gitlab-com` groups have been using the cache for
the vulnerability history endpoint consumed by the group security
dashboard for over 3 months and things have been going well. Time to
take off the training wheels.
parent 711c4bec
......@@ -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