Commit 78579abb authored by Valery Sizov's avatar Valery Sizov

Don't use cached nodes for geo:set_secondary_as_primary task

It can cause some weird behaviour, AR objects are generally
not condsidered to work like that
parent c616816e
......@@ -219,7 +219,7 @@ namespace :geo do
abort GEO_LICENSE_ERROR_TEXT unless Gitlab::Geo.license_allows?
ActiveRecord::Base.transaction do
primary_node = Gitlab::Geo.primary_node
primary_node = GeoNode.primary_node
unless primary_node
abort 'The primary is not set'
......@@ -227,7 +227,7 @@ namespace :geo do
primary_node.destroy
current_node = Gitlab::Geo.current_node
current_node = GeoNode.current_node
unless current_node.secondary?
abort 'This is not a secondary node'
......
......@@ -261,15 +261,20 @@ describe 'geo rake tasks', :geo do
end
end
describe 'geo:set_secondary_as_primary' do
describe 'geo:set_secondary_as_primary', :use_clean_rails_memory_store_caching do
let!(:current_node) { create(:geo_node) }
let!(:primary_node) { create(:geo_node, :primary) }
before do
stub_current_geo_node(current_node)
allow(GeoNode).to receive(:current_node).and_return(current_node)
end
it 'removes primary and sets secondary as primary' do
# Pre-warming the cache. See https://gitlab.com/gitlab-org/gitlab/-/merge_requests/22021
Gitlab::Geo.primary_node
run_rake_task('geo:set_secondary_as_primary')
expect(current_node.primary?).to be_truthy
......
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