Commit 84eab3c9 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'fix-nil-method-error-metrics-update-service' into 'master'

Fix a NoMethodError in Geo::MetricsUpdateService

See merge request gitlab-org/gitlab-ee!3623
parents 8d85935c 87b8d1a1
......@@ -23,7 +23,7 @@ module Geo
end
def fetch_geo_node_metrics(node)
return unless node.enabled?
return unless node&.enabled?
return unless Gitlab::Geo.primary? || Gitlab::Metrics.prometheus_metrics_enabled?
status = node_status(node)
......
---
title: Fix a bug in the Geo metrics update service
merge_request: 3623
author:
type: fixed
......@@ -3,6 +3,10 @@ require 'spec_helper'
describe Geo::MetricsUpdateService, :geo do
include ::EE::GeoHelpers
set(:primary) { create(:geo_node, :primary) }
set(:secondary) { create(:geo_node) }
set(:another_secondary) { create(:geo_node) }
subject { described_class.new }
let(:event_date) { Time.now.utc }
......@@ -38,11 +42,19 @@ describe Geo::MetricsUpdateService, :geo do
allow(Geo::NodeStatusFetchService).to receive(:get).and_return(request)
end
context 'when node is the primary' do
set(:primary) { create(:geo_node, :primary) }
set(:secondary) { create(:geo_node) }
set(:another_secondary) { create(:geo_node) }
context 'when current node is nil' do
before do
stub_current_geo_node(nil)
end
it 'skips fetching the status' do
expect(Geo::NodeStatusFetchService).to receive(:get).never
subject.execute
end
end
context 'when node is the primary' do
before do
stub_current_geo_node(primary)
end
......@@ -75,8 +87,6 @@ describe Geo::MetricsUpdateService, :geo do
end
context 'when node is a secondary' do
set(:secondary) { create(:geo_node) }
subject { described_class.new }
before 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