Commit 10c13f05 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch 'fp-lower-frequency-trace-update' into 'master'

Lower the frequency of which job trace updates occur [RUN ALL RSPEC] [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!56743
parents ce053017 9a4b5e2e
---
name: ci_lower_frequency_trace_update
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/56743
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/324768
milestone: '13.11'
type: development
group: group::continuous integration
default_enabled: false
...@@ -11,7 +11,8 @@ module Gitlab ...@@ -11,7 +11,8 @@ module Gitlab
LOCK_SLEEP = 0.001.seconds LOCK_SLEEP = 0.001.seconds
WATCH_FLAG_TTL = 10.seconds WATCH_FLAG_TTL = 10.seconds
UPDATE_FREQUENCY_DEFAULT = 30.seconds LEGACY_UPDATE_FREQUENCY_DEFAULT = 30.seconds
UPDATE_FREQUENCY_DEFAULT = 60.seconds
UPDATE_FREQUENCY_WHEN_BEING_WATCHED = 3.seconds UPDATE_FREQUENCY_WHEN_BEING_WATCHED = 3.seconds
ArchiveError = Class.new(StandardError) ArchiveError = Class.new(StandardError)
...@@ -114,7 +115,15 @@ module Gitlab ...@@ -114,7 +115,15 @@ module Gitlab
end end
def update_interval def update_interval
being_watched? ? UPDATE_FREQUENCY_WHEN_BEING_WATCHED : UPDATE_FREQUENCY_DEFAULT if being_watched?
UPDATE_FREQUENCY_WHEN_BEING_WATCHED
else
if Feature.enabled?(:ci_lower_frequency_trace_update, job.project, default_enabled: :yaml)
UPDATE_FREQUENCY_DEFAULT
else
LEGACY_UPDATE_FREQUENCY_DEFAULT
end
end
end end
def being_watched! def being_watched!
......
...@@ -63,8 +63,14 @@ RSpec.describe Gitlab::Ci::Trace, :clean_gitlab_redis_shared_state, factory_defa ...@@ -63,8 +63,14 @@ RSpec.describe Gitlab::Ci::Trace, :clean_gitlab_redis_shared_state, factory_defa
describe '#update_interval' do describe '#update_interval' do
context 'it is not being watched' do context 'it is not being watched' do
it 'returns 30 seconds' do it { expect(trace.update_interval).to eq(60.seconds) }
expect(trace.update_interval).to eq(30.seconds)
context 'when feature flag ci_lower_frequency_trace_update is disabled' do
before do
stub_feature_flags(ci_lower_frequency_trace_update: false)
end
it { expect(trace.update_interval).to eq(30.seconds) }
end end
end end
......
...@@ -210,7 +210,19 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do ...@@ -210,7 +210,19 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do
end end
context 'when build trace is not being watched' do context 'when build trace is not being watched' do
it 'returns X-GitLab-Trace-Update-Interval as 30' do it 'returns the interval in X-GitLab-Trace-Update-Interval' do
patch_the_trace
expect(response).to have_gitlab_http_status(:accepted)
expect(response.header['X-GitLab-Trace-Update-Interval']).to eq('60')
end
context 'when ci_lower_frequency_trace_update feature flag is disabled' do
before do
stub_feature_flags(ci_lower_frequency_trace_update: false)
end
it 'returns the legacy interval in X-GitLab-Trace-Update-Interval' do
patch_the_trace patch_the_trace
expect(response).to have_gitlab_http_status(:accepted) expect(response).to have_gitlab_http_status(:accepted)
...@@ -218,6 +230,7 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do ...@@ -218,6 +230,7 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do
end end
end end
end end
end
context 'when Runner makes a force-patch' do context 'when Runner makes a force-patch' do
before do before do
......
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