Commit 9bcd3fd4 authored by Stan Hu's avatar Stan Hu

Merge branch '5555-no-method-error' into 'master'

Resolve "NoMethodError: undefined method `log_info' for Geo::RepositorySyncWorker"

Closes #5555

See merge request gitlab-org/gitlab-ee!5223
parents 552dad1f 2361be18
......@@ -4,6 +4,7 @@ module Geo
include ApplicationWorker
include CronjobQueue
include ::Gitlab::Utils::StrongMemoize
include ::Gitlab::Geo::LogHelpers
HEALTHY_SHARD_CHECKS = [
Gitlab::HealthChecks::FsShardsCheck,
......
......@@ -3,7 +3,10 @@ module Geo
module Primary
class PerShardSchedulerWorker < Geo::Scheduler::PerShardSchedulerWorker
def perform
return unless Gitlab::Geo.primary?
unless Gitlab::Geo.primary?
log_info('Current node not a primary')
return
end
super
end
......
......@@ -4,6 +4,7 @@ module Geo
include ApplicationWorker
include GeoQueue
include ExclusiveLeaseGuard
include ::Gitlab::Geo::LogHelpers
include ::Gitlab::Utils::StrongMemoize
DB_RETRIEVE_BATCH_SIZE = 1000
......@@ -68,7 +69,14 @@ module Geo
private
# Subclasses should override this method to provide additional metadata
# in log messages
def worker_metadata
{}
end
def base_log_data(message)
super(message).merge(worker_metadata)
end
def db_retrieve_batch_size
......@@ -185,18 +193,6 @@ module Geo
Gitlab::Geo.current_node_enabled?
end
end
def log_info(message, extra_args = {})
args = { class: self.class.name, message: message }.merge(extra_args)
args.merge!(worker_metadata) if worker_metadata
Gitlab::Geo::Logger.info(args)
end
def log_error(message, extra_args = {})
args = { class: self.class.name, message: message }.merge(extra_args)
args.merge!(worker_metadata) if worker_metadata
Gitlab::Geo::Logger.error(args)
end
end
end
end
---
title: Fix an exception in the Geo repository sync worker
merge_request: 5223
author:
type: fixed
require 'spec_helper'
describe Geo::Scheduler::PerShardSchedulerWorker do
it 'includes ::Gitlab::Geo::LogHelpers' do
expect(described_class).to include_module(::Gitlab::Geo::LogHelpers)
end
it 'needs many other specs'
end
require 'spec_helper'
describe Geo::Scheduler::SchedulerWorker do
it 'includes ::Gitlab::Geo::LogHelpers' do
expect(described_class).to include_module(::Gitlab::Geo::LogHelpers)
end
it 'needs many other specs'
end
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