Commit a7895ff7 authored by Mikolaj Wawrzyniak's avatar Mikolaj Wawrzyniak

Skip secure product metrics in service ping

Since broken index_security_ci_builds_on_name_and_id_parser_features
index has not yet been fixed and release is approaching in order
to avoid breaking self-hosted service ping reoprting for whole
release decision was made to skip affected metrics unless
feature is enabled

Changelog: performance
EE: true
parent f93e436d
--- ---
name: quarantine_security_products_usage_metrics name: allow_quarantined_security_products_usage_metrics
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/71722 introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/71722
rollout_issue_url: rollout_issue_url:
milestone: '14.4' milestone: '14.4'
......
...@@ -143,10 +143,10 @@ module EE ...@@ -143,10 +143,10 @@ module EE
def security_products_usage def security_products_usage
results = SECURE_PRODUCT_TYPES.each_with_object({}) do |(secure_type, attribs), response| results = SECURE_PRODUCT_TYPES.each_with_object({}) do |(secure_type, attribs), response|
response[attribs[:name]] = if ::Feature.enabled?(:quarantine_security_products_usage_metrics, type: :ops, default_enabled: :yaml) response[attribs[:name]] = if ::Feature.enabled?(:allow_quarantined_security_products_usage_metrics, type: :ops, default_enabled: :yaml)
::Gitlab::Database::BatchCounter::FALLBACK
else
count(::Ci::Build.where(name: secure_type)) # rubocop:disable CodeReuse/ActiveRecord count(::Ci::Build.where(name: secure_type)) # rubocop:disable CodeReuse/ActiveRecord
else
::Gitlab::Database::BatchCounter::FALLBACK
end end
end end
......
...@@ -128,48 +128,48 @@ RSpec.describe Gitlab::UsageData do ...@@ -128,48 +128,48 @@ RSpec.describe Gitlab::UsageData do
expect(count_data[:epic_issues]).to eq(2) expect(count_data[:epic_issues]).to eq(2)
end end
context 'with quarantine_security_products_usage_metrics turned on' do context 'with allow_quarantined_security_products_usage_metrics turned on' do
it 'returns fallback value for quarantined security products usage data' do it 'gathers security products usage data' do
expect(count_data[:container_scanning_jobs]).to eq(-1) expect(count_data[:container_scanning_jobs]).to eq(1)
expect(count_data[:dast_jobs]).to eq(-1) expect(count_data[:dast_jobs]).to eq(1)
expect(count_data[:dependency_scanning_jobs]).to eq(-1) expect(count_data[:dependency_scanning_jobs]).to eq(1)
expect(count_data[:license_management_jobs]).to eq(-1) expect(count_data[:license_management_jobs]).to eq(2)
expect(count_data[:sast_jobs]).to eq(-1) expect(count_data[:sast_jobs]).to eq(1)
expect(count_data[:secret_detection_jobs]).to eq(-1) expect(count_data[:secret_detection_jobs]).to eq(1)
expect(count_data[:coverage_fuzzing_jobs]).to eq(-1) expect(count_data[:coverage_fuzzing_jobs]).to eq(1)
expect(count_data[:api_fuzzing_jobs]).to eq(-1) expect(count_data[:api_fuzzing_jobs]).to eq(1)
expect(count_data[:api_fuzzing_dnd_jobs]).to eq(-1) expect(count_data[:api_fuzzing_dnd_jobs]).to eq(1)
expect(count_data[:dast_on_demand_pipelines]).to eq(1) expect(count_data[:dast_on_demand_pipelines]).to eq(1)
end end
it 'avoid counting metrics' do it 'counts metrics data' do
expect(described_class).not_to receive(:count) expect(described_class).to receive(:count).exactly(10).times
described_class.security_products_usage described_class.security_products_usage
end end
end end
context 'with quarantine_security_products_usage_metrics turned off' do context 'with allow_quarantined_security_products_usage_metrics turned off' do
before do before do
stub_feature_flags(quarantine_security_products_usage_metrics: false) stub_feature_flags(allow_quarantined_security_products_usage_metrics: false)
end end
it 'counts metrics data' do it 'avoid counting metrics' do
expect(described_class).to receive(:count).exactly(10).times expect(described_class).not_to receive(:count)
described_class.security_products_usage described_class.security_products_usage
end end
it 'gathers security products usage data' do it 'returns fallback value for quarantined security products usage data' do
expect(count_data[:container_scanning_jobs]).to eq(1) expect(count_data[:container_scanning_jobs]).to eq(-1)
expect(count_data[:dast_jobs]).to eq(1) expect(count_data[:dast_jobs]).to eq(-1)
expect(count_data[:dependency_scanning_jobs]).to eq(1) expect(count_data[:dependency_scanning_jobs]).to eq(-1)
expect(count_data[:license_management_jobs]).to eq(2) expect(count_data[:license_management_jobs]).to eq(-1)
expect(count_data[:sast_jobs]).to eq(1) expect(count_data[:sast_jobs]).to eq(-1)
expect(count_data[:secret_detection_jobs]).to eq(1) expect(count_data[:secret_detection_jobs]).to eq(-1)
expect(count_data[:coverage_fuzzing_jobs]).to eq(1) expect(count_data[:coverage_fuzzing_jobs]).to eq(-1)
expect(count_data[:api_fuzzing_jobs]).to eq(1) expect(count_data[:api_fuzzing_jobs]).to eq(-1)
expect(count_data[:api_fuzzing_dnd_jobs]).to eq(1) expect(count_data[:api_fuzzing_dnd_jobs]).to eq(-1)
expect(count_data[:dast_on_demand_pipelines]).to eq(1) expect(count_data[:dast_on_demand_pipelines]).to eq(1)
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