Commit 8e6519b2 authored by Valery Sizov's avatar Valery Sizov

Fix: Geo: rake gitlab:geo:check on the primary is cluttered

We only check secondary related things when node is secondary
or when the current not is misconfigured
parent 59ac8880
---
title: "[Geo] Fix: rake gitlab:geo:check on the primary is cluttered"
merge_request: 19460
author:
type: changed
......@@ -44,6 +44,10 @@ module Gitlab
self.enabled? && self.current_node&.secondary?
end
def self.current_node_misconfigured?
self.enabled? && self.current_node.nil?
end
def self.current_node_enabled?
# No caching of the enabled! If we cache it and an admin disables
# this node, an active Geo::RepositorySyncWorker would keep going for up
......
......@@ -11,15 +11,15 @@ module SystemCheck
end
def self.checks
return secondary_checks if Gitlab::Geo.secondary? || Gitlab::Geo.current_node_misconfigured?
common_checks
end
def self.common_checks
[
SystemCheck::Geo::LicenseCheck,
SystemCheck::Geo::EnabledCheck,
SystemCheck::Geo::GeoDatabaseConfiguredCheck,
SystemCheck::Geo::DatabaseReplicationEnabledCheck,
SystemCheck::Geo::DatabaseReplicationWorkingCheck,
SystemCheck::Geo::FdwEnabledCheck,
SystemCheck::Geo::FdwSchemaUpToDateCheck,
SystemCheck::Geo::HttpConnectionCheck,
SystemCheck::Geo::HTTPCloneEnabledCheck,
SystemCheck::Geo::ClocksSynchronizationCheck,
SystemCheck::App::GitUserDefaultSSHConfigCheck,
......@@ -29,6 +29,17 @@ module SystemCheck
SystemCheck::App::HashedStorageAllProjectsCheck
]
end
def self.secondary_checks
[
SystemCheck::Geo::GeoDatabaseConfiguredCheck,
SystemCheck::Geo::DatabaseReplicationEnabledCheck,
SystemCheck::Geo::DatabaseReplicationWorkingCheck,
SystemCheck::Geo::FdwEnabledCheck,
SystemCheck::Geo::FdwSchemaUpToDateCheck,
SystemCheck::Geo::HttpConnectionCheck
] + common_checks
end
end
end
end
......@@ -80,6 +80,30 @@ describe Gitlab::Geo, :geo, :request_store do
end
end
describe '.current_node_misconfigured?' do
it 'returns true when current node is not set' do
expect(described_class.current_node_misconfigured?).to be_truthy
end
it 'returns false when primary' do
stub_current_geo_node(primary_node)
expect(described_class.current_node_misconfigured?).to be_falsey
end
it 'returns false when secondary' do
stub_current_geo_node(secondary_node)
expect(described_class.current_node_misconfigured?).to be_falsey
end
it 'returns false when Geo is disabled' do
GeoNode.delete_all
expect(described_class.current_node_misconfigured?).to be_falsey
end
end
describe '.secondary?' do
context 'when current node is a secondary node' do
before do
......
# frozen_string_literal: true
require 'spec_helper'
describe SystemCheck::RakeTask::GeoTask do
include ::EE::GeoHelpers
let(:common_checks) do
[
SystemCheck::Geo::LicenseCheck,
SystemCheck::Geo::EnabledCheck,
SystemCheck::Geo::HTTPCloneEnabledCheck,
SystemCheck::Geo::ClocksSynchronizationCheck,
SystemCheck::App::GitUserDefaultSSHConfigCheck,
SystemCheck::Geo::AuthorizedKeysCheck,
SystemCheck::Geo::AuthorizedKeysFlagCheck,
SystemCheck::App::HashedStorageEnabledCheck,
SystemCheck::App::HashedStorageAllProjectsCheck
]
end
let(:secondary_checks) do
[
SystemCheck::Geo::GeoDatabaseConfiguredCheck,
SystemCheck::Geo::DatabaseReplicationEnabledCheck,
SystemCheck::Geo::DatabaseReplicationWorkingCheck,
SystemCheck::Geo::FdwEnabledCheck,
SystemCheck::Geo::FdwSchemaUpToDateCheck,
SystemCheck::Geo::HttpConnectionCheck
] + common_checks
end
describe '.checks' do
context 'primary node' do
it 'secondary checks is skipped' do
primary = create(:geo_node, :primary)
stub_current_geo_node(primary)
expect(described_class.checks).to eq(common_checks)
end
end
context 'secondary node' do
it 'secondary checks is called' do
secondary = create(:geo_node)
stub_current_geo_node(secondary)
expect(described_class.checks).to eq(secondary_checks)
end
end
context 'Geo disabled' do
it 'secondary checks is skipped' do
expect(described_class.checks).to eq(common_checks)
end
end
context 'Geo is enabled but node is not identified' do
it 'secondary checks is called' do
create(:geo_node)
expect(described_class.checks).to eq(secondary_checks)
end
end
end
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