Commit 4af45a23 authored by Nick Thomas's avatar Nick Thomas

Merge branch '4055-geo-api-bugs' into 'master'

Fix: Geo API bug. Statistic is not collected when prometheus is disabled

Closes #4055

See merge request gitlab-org/gitlab-ee!3421
parents 95dd5a57 9d5e67c9
...@@ -24,6 +24,7 @@ module Geo ...@@ -24,6 +24,7 @@ module Geo
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?
status = node_status(node) status = node_status(node)
...@@ -33,7 +34,7 @@ module Geo ...@@ -33,7 +34,7 @@ module Geo
end end
update_db_metrics(node, status) if Gitlab::Geo.primary? update_db_metrics(node, status) if Gitlab::Geo.primary?
update_prometheus_metrics(node, status) update_prometheus_metrics(node, status) if Gitlab::Metrics.prometheus_metrics_enabled?
end end
def update_db_metrics(node, status) def update_db_metrics(node, status)
......
...@@ -7,8 +7,6 @@ module Geo ...@@ -7,8 +7,6 @@ module Geo
LEASE_TIMEOUT = 5.minutes LEASE_TIMEOUT = 5.minutes
def perform def perform
return unless Gitlab::Metrics.prometheus_metrics_enabled?
try_obtain_lease { Geo::MetricsUpdateService.new.execute } try_obtain_lease { Geo::MetricsUpdateService.new.execute }
end end
......
---
title: 'Fix: Geo API bug. Statistic is not collected when prometheus is disabled'
merge_request:
author:
type: fixed
...@@ -13,16 +13,7 @@ RSpec.describe Geo::MetricsUpdateWorker, :geo do ...@@ -13,16 +13,7 @@ RSpec.describe Geo::MetricsUpdateWorker, :geo do
stub_current_geo_node(secondary) stub_current_geo_node(secondary)
end end
it 'does not execute when Prometheus metrics are disabled' do it 'executes MetricsUpdateService' do
allow(Gitlab::Metrics).to receive(:prometheus_metrics_enabled?).and_return(false)
expect(Geo::MetricsUpdateService).not_to receive(:new)
subject.perform
end
it 'executes when Prometheus metrics are enabled' do
allow(Gitlab::Metrics).to receive(:prometheus_metrics_enabled?).and_return(true)
service = double(:service, execute: true) service = double(:service, execute: true)
expect(Geo::MetricsUpdateService).to receive(:new).and_return(service) expect(Geo::MetricsUpdateService).to receive(:new).and_return(service)
......
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