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 ...@@ -23,7 +23,7 @@ module Geo
end end
def fetch_geo_node_metrics(node) def fetch_geo_node_metrics(node)
return unless node.enabled? return unless node&.enabled?
return unless Gitlab::Geo.primary? || Gitlab::Metrics.prometheus_metrics_enabled? return unless Gitlab::Geo.primary? || Gitlab::Metrics.prometheus_metrics_enabled?
status = node_status(node) 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' ...@@ -3,6 +3,10 @@ require 'spec_helper'
describe Geo::MetricsUpdateService, :geo do describe Geo::MetricsUpdateService, :geo do
include ::EE::GeoHelpers include ::EE::GeoHelpers
set(:primary) { create(:geo_node, :primary) }
set(:secondary) { create(:geo_node) }
set(:another_secondary) { create(:geo_node) }
subject { described_class.new } subject { described_class.new }
let(:event_date) { Time.now.utc } let(:event_date) { Time.now.utc }
...@@ -38,11 +42,19 @@ describe Geo::MetricsUpdateService, :geo do ...@@ -38,11 +42,19 @@ describe Geo::MetricsUpdateService, :geo do
allow(Geo::NodeStatusFetchService).to receive(:get).and_return(request) allow(Geo::NodeStatusFetchService).to receive(:get).and_return(request)
end end
context 'when node is the primary' do context 'when current node is nil' do
set(:primary) { create(:geo_node, :primary) } before do
set(:secondary) { create(:geo_node) } stub_current_geo_node(nil)
set(:another_secondary) { create(:geo_node) } 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 before do
stub_current_geo_node(primary) stub_current_geo_node(primary)
end end
...@@ -75,8 +87,6 @@ describe Geo::MetricsUpdateService, :geo do ...@@ -75,8 +87,6 @@ describe Geo::MetricsUpdateService, :geo do
end end
context 'when node is a secondary' do context 'when node is a secondary' do
set(:secondary) { create(:geo_node) }
subject { described_class.new } subject { described_class.new }
before do 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