Commit 188ad44e authored by Michael Kozono's avatar Michael Kozono

Merge branch 'better_error_handling_of-set_secondary_as_primary' into 'master'

Geo: Better error handling of set_secondary_as_primary rake task

See merge request gitlab-org/gitlab!45568
parents a48f8b08 46a37307
---
title: 'Geo: Better error handling of geo:set_secondary_as_primary rake task'
merge_request: 45568
author:
type: changed
......@@ -23,6 +23,7 @@ module Gitlab
current_node = GeoNode.current_node
abort 'The primary is not set' unless primary_node
abort 'Current node is not identified' unless current_node
abort 'This is not a secondary node' unless current_node.secondary?
primary_node.destroy
......
......@@ -39,6 +39,14 @@ RSpec.describe Gitlab::Geo::GeoTasks do
expect { subject.set_secondary_as_primary }.to raise_error('aborted')
end
it 'aborts if current node is not identified' do
secondary.destroy!
expect(subject).to receive(:abort).with('Current node is not identified').and_raise('aborted')
expect { subject.set_secondary_as_primary }.to raise_error('aborted')
end
it 'aborts if run on a node that is not a secondary' do
primary.update_column(:primary, false)
secondary.update!(primary: true)
......
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