Commit 2f6efef1 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch '8690-geo-require-hashed-storage' into 'master'

Resolve "Geo: Make hashed storage a hard requirement in 12.0"

Closes #8690

See merge request gitlab-org/gitlab-ee!14102
parents 6f9ee533 1960fee8
......@@ -37,7 +37,8 @@ class GeoNode < ApplicationRecord
validates :verification_max_capacity, numericality: { greater_than_or_equal_to: 0 }
validates :minimum_reverification_interval, numericality: { greater_than_or_equal_to: 1 }
validate :check_not_adding_primary_as_secondary, if: :secondary?
validate :require_current_node_to_be_primary, if: :secondary?
validate :require_hashed_storage, on: :create
after_save :expire_cache!
after_destroy :expire_cache!
......@@ -287,12 +288,19 @@ class GeoNode < ApplicationRecord
end
# Prevent locking yourself out
def check_not_adding_primary_as_secondary
def require_current_node_to_be_primary
if name == self.class.current_node_name
errors.add(:base, 'Current node must be the primary node or you will be locking yourself out')
end
end
# Prevent creating a Geo Node unless Hashed Storage is enabled
def require_hashed_storage
unless Gitlab::CurrentSettings.hashed_storage_enabled?
errors.add(:base, 'Hashed Storage must be enabled to use Geo')
end
end
def update_clone_url
self.clone_url_prefix = Gitlab.config.gitlab_shell.ssh_path_prefix
end
......
---
title: Require Hashed Storage to be enabled to create new Geo Nodes
merge_request: 14102
author:
type: changed
......@@ -94,6 +94,22 @@ describe GeoNode, :geo, type: :model do
it { is_expected.not_to be_valid }
end
end
context 'when validating requirement for hashed storage' do
subject { build(:geo_node) }
context 'when hashed storage is enabled' do
it { is_expected.to be_valid }
end
context 'when hashed_storage is disabled' do
before do
stub_application_setting(hashed_storage_enabled: false)
end
it { is_expected.to be_invalid }
end
end
end
context 'default values' do
......@@ -110,7 +126,7 @@ describe GeoNode, :geo, type: :model do
context 'prevent locking yourself out' do
it 'does not accept adding a non primary node with same details as current_node' do
stub_geo_setting(node_name: 'foo')
node = build(:geo_node, :primary, primary: false, name: 'foo')
node = build(:geo_node, primary: false, name: 'foo')
expect(node).not_to be_valid
expect(node.errors.full_messages.count).to eq(1)
......
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