Commit 4cc13e63 authored by Toon Claes's avatar Toon Claes

Prunes whole Geo event when there's only a primary

When there is only a primary node configured, but no secondary nodes,
prune the complete Geo event log.

Closes https://gitlab.com/gitlab-org/gitlab-ee/issues/9712
parent 328f36f3
...@@ -13,7 +13,7 @@ module Geo ...@@ -13,7 +13,7 @@ module Geo
return if Gitlab::Database.read_only? return if Gitlab::Database.read_only?
return unless Gitlab::Database.healthy? return unless Gitlab::Database.healthy?
unless ::GeoNode.any? unless ::GeoNode.secondary_nodes.any?
Geo::PruneEventLogService.new(:all).execute Geo::PruneEventLogService.new(:all).execute
return return
end end
......
---
title: Prunes whole Geo event when there's only a primary
merge_request: 9630
author:
type: fixed
...@@ -59,10 +59,9 @@ describe Geo::PruneEventLogWorker, :geo do ...@@ -59,10 +59,9 @@ describe Geo::PruneEventLogWorker, :geo do
worker.perform worker.perform
end end
context 'no Geo nodes' do context 'no Geo secondary nodes' do
before do before do
secondary.destroy secondary.destroy
primary.destroy
end end
it 'deletes everything from the Geo event log' do it 'deletes everything from the Geo event log' do
...@@ -72,6 +71,20 @@ describe Geo::PruneEventLogWorker, :geo do ...@@ -72,6 +71,20 @@ describe Geo::PruneEventLogWorker, :geo do
worker.perform worker.perform
end end
context 'no Geo primary node' do
before do
primary.destroy
end
it 'deletes everything from the Geo event log' do
create_list(:geo_event_log, 2)
expect(Geo::PruneEventLogService).to receive(:new).with(:all).and_call_original
worker.perform
end
end
end end
context 'multiple secondary nodes' do context 'multiple secondary nodes' 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