Commit 418f2511 authored by Andy Soiron's avatar Andy Soiron

Merge branch 'remove-ff-ci-minutes-track-live-consumption' into 'master'

Remove feature flag `ci_minutes_track_live_consumption`

See merge request gitlab-org/gitlab!71072
parents 07cec86b 55adb3a7
---
name: ci_minutes_track_live_consumption
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/59263
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/329197
milestone: '13.12'
type: development
group: group::pipeline execution
default_enabled: false
......@@ -133,7 +133,6 @@ The following metrics are available:
| `pipeline_graph_links_total` | Histogram | 13.9 | Number of links per graph | |
| `pipeline_graph_links_per_job_ratio` | Histogram | 13.9 | Ratio of links to job per graph | |
| `gitlab_ci_pipeline_security_orchestration_policy_processing_duration_seconds` | Histogram | 13.12 | Time in seconds it takes to process Security Policies in CI/CD pipeline | |
| `gitlab_ci_difference_live_vs_actual_minutes` | Histogram | 13.12 | Difference between CI minute consumption counted while jobs were running (live) vs when jobs are complete (actual). Used to enforce CI minute consumption limits on long running jobs. | `plan` |
| `gitlab_spamcheck_request_duration_seconds` | Histogram | 13.12 | The duration for requests between Rails and the anti-spam engine | |
| `service_desk_thank_you_email` | Counter | 14.0 | Total number of email responses to new service desk emails | |
| `service_desk_new_note_email` | Counter | 14.0 | Total number of email notifications on new service desk comment | |
......
......@@ -73,9 +73,7 @@ module Ci
attr_reader :build
def validate_preconditions
if !feature_enabled?
ServiceResponse.error(message: 'Feature not enabled')
elsif !build.running?
if !build.running?
ServiceResponse.error(message: 'Build is not running')
elsif !build.cost_factor_enabled?
ServiceResponse.error(message: 'Cost factor not enabled for build')
......@@ -84,10 +82,6 @@ module Ci
end
end
def feature_enabled?
Feature.enabled?(:ci_minutes_track_live_consumption, build.project, default_enabled: :yaml)
end
def consumption_since_last_update
last_tracking = time_last_tracked_consumption!(Time.current.utc)
duration = Time.current.utc - last_tracking
......
......@@ -15,7 +15,6 @@ module Ci
return unless consumption > 0
update_minutes(consumption, build)
compare_with_live_consumption(build, consumption)
end
private
......@@ -24,23 +23,9 @@ module Ci
::Ci::Minutes::UpdateProjectAndNamespaceUsageWorker.perform_async(consumption, project.id, namespace.id, build.id)
end
def compare_with_live_consumption(build, consumption)
live_consumption = ::Ci::Minutes::TrackLiveConsumptionService.new(build).live_consumption
return if live_consumption == 0
difference = consumption.to_f - live_consumption.to_f
observe_ci_minutes_difference(difference, plan: namespace.actual_plan_name)
end
def namespace
project.shared_runners_limit_namespace
end
def observe_ci_minutes_difference(difference, plan:)
::Gitlab::Ci::Pipeline::Metrics
.gitlab_ci_difference_live_vs_actual_minutes
.observe({ plan: plan }, difference)
end
end
end
end
......@@ -139,14 +139,6 @@ RSpec.describe Ci::Minutes::TrackLiveConsumptionService do
it_behaves_like 'limit exceeded'
end
context 'when feature flag is disabled' do
before do
stub_feature_flags(ci_minutes_track_live_consumption: false)
end
it_behaves_like 'returns early', 'Feature not enabled'
end
end
end
......
......@@ -47,13 +47,6 @@ RSpec.describe Ci::Minutes::UpdateBuildMinutesService do
expect { subject }.not_to change { Ci::Minutes::ProjectMonthlyUsage.count }
end
it 'does not observe the difference between actual vs live consumption' do
expect(::Gitlab::Ci::Pipeline::Metrics)
.not_to receive(:gitlab_ci_difference_live_vs_actual_minutes)
subject
end
it 'does not send an email' do
allow(Gitlab).to receive(:com?).and_return(true)
......@@ -200,27 +193,8 @@ RSpec.describe Ci::Minutes::UpdateBuildMinutesService do
build.update!(status: :success)
end
it 'observes the difference between actual vs live consumption' do
histogram = double(:histogram)
expect(::Gitlab::Ci::Pipeline::Metrics)
.to receive(:gitlab_ci_difference_live_vs_actual_minutes)
.and_return(histogram)
expect(histogram).to receive(:observe).with({ plan: 'free' }, 5 * cost_factor)
subject
end
it_behaves_like 'new tracking matches legacy tracking'
end
context 'when live tracking does not exist for the build' do
it 'does not observe the difference' do
expect(::Gitlab::Ci::Pipeline::Metrics).not_to receive(:gitlab_ci_difference_live_vs_actual_minutes)
subject
end
end
end
context 'for specific runner' do
......
......@@ -92,14 +92,6 @@ module Gitlab
Gitlab::Metrics.counter(name, comment)
end
def self.gitlab_ci_difference_live_vs_actual_minutes
name = :gitlab_ci_difference_live_vs_actual_minutes
comment = 'Comparison between CI minutes consumption from live tracking vs actual consumption'
labels = {}
buckets = [-120.0, -60.0, -30.0, -10.0, -5.0, -3.0, -1.0, 0.0, 1.0, 3.0, 5.0, 10.0, 30.0, 60.0, 120.0]
::Gitlab::Metrics.histogram(name, comment, labels, buckets)
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