Skip to content
Snippets Groups Projects
Commit 10d1f449 authored by Rémy Coutable's avatar Rémy Coutable
Browse files

Merge branch '3505-disable-key-updates-on-secondaries' into 'master'

Resolve "Geo: Disable updates to Key#last_used_at"

Closes #3505

See merge request gitlab-org/gitlab-ee!2983
parents 86b41da8 a52eff6c
No related branches found
No related tags found
1 merge request!2983Resolve "Geo: Disable updates to Key#last_used_at"
Pipeline #
module Keys
class LastUsedService
prepend ::EE::Keys::LastUsedService
TIMEOUT = 1.day.to_i
 
attr_reader :key
Loading
Loading
module EE
module Keys
module LastUsedService
def update?
raise NotImplementedError unless defined?(super)
!::Gitlab::Geo.secondary? && super
end
end
end
end
require 'spec_helper'
describe Keys::LastUsedService do
it 'does not run on Geo secondaries', :clean_gitlab_redis_shared_state do
key = create(:key, last_used_at: 1.year.ago)
original_time = key.last_used_at
allow(::Gitlab::Geo).to receive(:secondary?).and_return(true)
described_class.new(key).execute
expect(key.reload.last_used_at).to be_like_time(original_time)
end
end
Loading
Loading
@@ -26,12 +26,7 @@
# make sure we _only_ update last_used_at and not always updated_at.
key = create(:key, last_used_at: 1.year.ago)
 
recorder = ActiveRecord::QueryRecorder.new do
described_class.new(key).execute
end
expect(recorder.count).to eq(1)
expect(recorder.log[0]).not_to include('updated_at')
expect { described_class.new(key).execute }.not_to change { key.updated_at }
end
end
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment