Commit c57622a2 authored by Ash McKenzie's avatar Ash McKenzie

Geo: Use sleep_break instead in the log_cursor

parent 0fe56995
......@@ -21,7 +21,7 @@ module Gitlab
until exit?
# Prevent the node from processing events unless it's a secondary
unless Geo.secondary?
sleep(SECONDARY_CHECK_INTERVAL)
sleep_break(SECONDARY_CHECK_INTERVAL)
next
end
......@@ -45,6 +45,14 @@ module Gitlab
private
def sleep_break(seconds)
while seconds > 0
sleep(1)
seconds -= 1
break if exit?
end
end
def handle_events(batch, previous_batch_last_id)
logger.info("Handling events", first_id: batch.first.id, last_id: batch.last.id)
......
......@@ -54,7 +54,7 @@ describe Gitlab::Geo::LogCursor::Daemon, :clean_gitlab_redis_shared_state do
stub_current_geo_node(nil)
is_expected.to receive(:exit?).and_return(false, true)
is_expected.to receive(:sleep).with(1.minute)
is_expected.to receive(:sleep_break).with(1.minute)
is_expected.not_to receive(:run_once!)
daemon.run!
......@@ -64,7 +64,7 @@ describe Gitlab::Geo::LogCursor::Daemon, :clean_gitlab_redis_shared_state do
stub_current_geo_node(primary)
is_expected.to receive(:exit?).and_return(false, true)
is_expected.to receive(:sleep).with(1.minute)
is_expected.to receive(:sleep_break).with(1.minute)
is_expected.not_to receive(:run_once!)
daemon.run!
......@@ -163,7 +163,7 @@ describe Gitlab::Geo::LogCursor::Daemon, :clean_gitlab_redis_shared_state do
expect(Gitlab::Geo::Logger).to receive(:warn)
.with(hash_including(
class: 'Gitlab::Geo::LogCursor::Daemon',
message: 'Unknown event',
message: '#handle_single_event: unknown event',
event_log_id: new_event.id))
daemon.run_once!
......
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