Commit f3a53fc2 authored by Michael Kozono's avatar Michael Kozono

Merge branch...

Merge branch '285475-cannot-list-container-repository-registries-and-images-on-geo-secondary' into 'master'

Does not track package events on a read-only instance

See merge request gitlab-org/gitlab!48257
parents 5401d000 853ecc0e
...@@ -7,7 +7,7 @@ module Packages ...@@ -7,7 +7,7 @@ module Packages
::Gitlab::UsageDataCounters::HLLRedisCounter.track_event(current_user.id, redis_event_name) ::Gitlab::UsageDataCounters::HLLRedisCounter.track_event(current_user.id, redis_event_name)
end end
if Feature.enabled?(:collect_package_events) if Feature.enabled?(:collect_package_events) && Gitlab::Database.read_write?
::Packages::Event.create!( ::Packages::Event.create!(
event_type: event_name, event_type: event_name,
originator: current_user&.id, originator: current_user&.id,
......
---
title: Does not track package events on a read-only instance
merge_request: 48257
author:
type: fixed
...@@ -25,7 +25,7 @@ RSpec.describe Packages::CreateEventService do ...@@ -25,7 +25,7 @@ RSpec.describe Packages::CreateEventService do
stub_feature_flags(collect_package_events: false) stub_feature_flags(collect_package_events: false)
end end
it 'does not create an event object' do it 'does not create an event' do
expect { subject }.not_to change { Packages::Event.count } expect { subject }.not_to change { Packages::Event.count }
end end
end end
...@@ -43,6 +43,16 @@ RSpec.describe Packages::CreateEventService do ...@@ -43,6 +43,16 @@ RSpec.describe Packages::CreateEventService do
expect(subject.event_scope).to eq(expected_scope) expect(subject.event_scope).to eq(expected_scope)
expect(subject.event_type).to eq(event_name) expect(subject.event_type).to eq(event_name)
end end
context 'on a read-only instance' do
before do
allow(Gitlab::Database).to receive(:read_only?).and_return(true)
end
it 'does not create an event' do
expect { subject }.not_to change { Packages::Event.count }
end
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