Commit a2c6dacc authored by Gabriel Mazetto's avatar Gabriel Mazetto

rename Geo node term: readonly -> secondary

parent 20a9335c
......@@ -107,7 +107,7 @@ class ApplicationController < ActionController::Base
end
def after_sign_out_path_for(resource)
if Gitlab::Geo.readonly?
if Gitlab::Geo.secondary?
Gitlab::Geo.primary_node.url
else
current_application_settings.after_sign_out_path || new_user_session_path
......
......@@ -91,7 +91,7 @@ class SessionsController < Devise::SessionsController
end
def gitlab_geo_login
if !signed_in? && Gitlab::Geo.enabled? && Gitlab::Geo.readonly?
if !signed_in? && Gitlab::Geo.enabled? && Gitlab::Geo.secondary?
# share full url with primary node by shared session
user_return_to = URI.join(root_url, session[:user_return_to]).to_s
session[:geo_node_return_to] = @redirect_to || user_return_to
......
......@@ -24,7 +24,7 @@ module Gitlab
RequestStore.store[:geo_node_primary?] ||= self.enabled? && self.current_node && self.current_node.primary?
end
def self.readonly?
def self.secondary?
RequestStore.store[:geo_node_readonly?] ||= self.enabled? && self.current_node && !self.current_node.primary?
end
......
......@@ -94,7 +94,7 @@ module Gitlab
def push_access_check(changes)
if Gitlab::Geo.enabled? && Gitlab::Geo.readonly?
if Gitlab::Geo.enabled? && Gitlab::Geo.secondary?
return build_status_object(false, "You can't push code on a secondary Gitlab Geo node.")
end
......@@ -336,8 +336,8 @@ module Gitlab
return build_status_object(false, "Repository does not exist")
end
if Gitlab::Geo.enabled? && Gitlab::Geo.readonly?
return build_status_object(false, "You can't use git-annex with Gitlab Geo secondary node.")
if Gitlab::Geo.enabled? && Gitlab::Geo.secondary?
return build_status_object(false, "You can't use git-annex with a secondary Gitlab Geo node.")
end
if user.can?(:push_code, project)
......
module Gitlab
class GitAccessWiki < GitAccess
def change_access_check(change)
if Gitlab::Geo.enabled? && Gitlab::Geo.readonly?
build_status_object(false, "You can't push code on a secondary Gitlab Geo node.")
if Gitlab::Geo.enabled? && Gitlab::Geo.secondary?
build_status_object(false, "You can't push code to a secondary Gitlab Geo node.")
elsif user.can?(:create_wiki, project)
build_status_object(true)
else
......
......@@ -10,10 +10,10 @@ module Gitlab
def call(env)
@env = env
if disallowed_request? && Gitlab::Geo.readonly?
if disallowed_request? && Gitlab::Geo.secondary?
Rails.logger.debug('Gitlab Geo: preventing possible non readonly operation')
rack_flash.alert = 'You cannot do writing operations on a readonly Gitlab Geo instance'
rack_flash.alert = 'You cannot do writing operations on a secondary Gitlab Geo instance'
rack_session['flash'] = rack_flash.to_session_value
return [301, { 'Location' => last_visited_url }, []]
......
......@@ -45,7 +45,7 @@ describe Gitlab::Geo, lib: true do
it 'returns true' do
allow(described_class).to receive(:current_node) { secondary_node }
expect(described_class.readonly?).to be_truthy
expect(described_class.secondary?).to be_truthy
end
end
......@@ -54,7 +54,7 @@ describe Gitlab::Geo, lib: true do
it 'returns false when ' do
allow(described_class).to receive(:current_node) { primary_node }
expect(described_class.readonly?).to be_falsey
expect(described_class.secondary?).to be_falsey
end
end
end
......
......@@ -260,10 +260,10 @@ describe Gitlab::GitAccess, lib: true do
end
end
context "when in a readonly gitlab geo node" do
context "when in a secondary gitlab geo node" do
before do
allow(Gitlab::Geo).to receive(:enabled?) { true }
allow(Gitlab::Geo).to receive(:readonly?) { true }
allow(Gitlab::Geo).to receive(:secondary?) { true }
end
permissions_matrix.keys.each do |role|
......@@ -285,11 +285,11 @@ describe Gitlab::GitAccess, lib: true do
context "when using git annex" do
before { project.team << [user, :master] }
describe 'and gitlab geo is enabled in a readonly node' do
describe 'and gitlab geo is enabled in a secondary node' do
before do
allow(Gitlab.config.gitlab_shell).to receive(:git_annex_enabled).and_return(true)
allow(Gitlab::Geo).to receive(:enabled?) { true }
allow(Gitlab::Geo).to receive(:readonly?) { true }
allow(Gitlab::Geo).to receive(:secondary?) { true }
end
it { expect(access.push_access_check(git_annex_changes)).not_to be_allowed }
......
......@@ -17,10 +17,10 @@ describe Gitlab::GitAccessWiki, lib: true do
it { expect(subject.allowed?).to be_truthy }
context 'when in a readonly gitlab geo node' do
context 'when in a secondary gitlab geo node' do
before do
allow(Gitlab::Geo).to receive(:enabled?) { true }
allow(Gitlab::Geo).to receive(:readonly?) { true }
allow(Gitlab::Geo).to receive(:secondary?) { true }
end
it { expect(subject.allowed?).to be_falsey }
......
......@@ -31,8 +31,8 @@ describe Gitlab::Middleware::ReadonlyGeo, lib: true do
let(:fake_app) { lambda { |env| [200, { 'Content-Type' => 'text/plain' }, ['OK']] } }
let(:request) { @request ||= Rack::MockRequest.new(rack_stack) }
context 'when in Gitlab Geo readonly node' do
before(:each) { allow(Gitlab::Geo).to receive(:readonly?) { true } }
context 'when in secondary Gitlab Geo node' do
before(:each) { allow(Gitlab::Geo).to receive(:secondary?) { true } }
it 'expects PATCH requests to be disallowed' do
response = request.patch('/test_request')
......
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