Skip to content
Snippets Groups Projects
Commit 97a02d99 authored by Balasankar C's avatar Balasankar C
Browse files

Merge branch 'rename-is-slave' into 'master'

Rename is_slave? method to be is_standby?

See merge request gitlab-org/omnibus-gitlab!4362
parents 1c3bf0f0 ae4f75dc
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -47,7 +47,7 @@ class BasePgHelper < BaseHelper
 
def extension_can_be_enabled?(extension_name, db_name)
is_running? &&
!is_slave? &&
!is_standby? &&
extension_exists?(extension_name) &&
database_exists?(db_name) &&
!extension_enabled?(extension_name, db_name)
Loading
Loading
@@ -208,16 +208,16 @@ class BasePgHelper < BaseHelper
end
end
 
def is_slave?
def is_standby?
psql_cmd(["-d 'template1'",
"-c 'select pg_is_in_recovery()' -A",
"|grep -x t"])
end
 
alias_method :is_replica?, :is_slave?
alias_method :is_replica?, :is_standby?
 
def is_offline_or_readonly?
!is_running? || is_slave?
!is_running? || is_standby?
end
 
# Returns an array of function names for the given database
Loading
Loading
Loading
Loading
@@ -156,21 +156,21 @@ if node['gitlab']['gitlab-rails']['enable']
postgresql_user gitlab_sql_user do
password "md5#{gitlab_sql_user_password}" unless gitlab_sql_user_password.nil?
action :create
not_if { pg_helper.is_slave? }
not_if { pg_helper.is_standby? }
end
 
execute "create #{database_name} database" do
command "/opt/gitlab/embedded/bin/createdb --port #{pg_port} -h #{node['postgresql']['unix_socket_directory']} -O #{gitlab_sql_user} #{database_name}"
user postgresql_username
retries 30
not_if { !pg_helper.is_running? || pg_helper.database_exists?(database_name) || pg_helper.is_slave? }
not_if { !pg_helper.is_running? || pg_helper.database_exists?(database_name) || pg_helper.is_standby? }
end
 
postgresql_user sql_replication_user do
password "md5#{sql_replication_password}" unless sql_replication_password.nil?
options %w(replication)
action :create
not_if { pg_helper.is_slave? }
not_if { pg_helper.is_standby? }
end
end
 
Loading
Loading
Loading
Loading
@@ -40,7 +40,7 @@ end
 
postgresql_user replication_user do
options %w(SUPERUSER)
not_if { pg_helper.is_slave? }
not_if { pg_helper.is_standby? }
end
 
postgresql_database node['repmgr']['database'] do
Loading
Loading
Loading
Loading
@@ -724,7 +724,7 @@ describe 'postgresql 9.6' do
 
context 'when database is a secondary' do
before do
allow_any_instance_of(PgHelper).to receive(:is_slave?).and_return(true)
allow_any_instance_of(PgHelper).to receive(:is_standby?).and_return(true)
end
 
it 'should not create users' do
Loading
Loading
Loading
Loading
@@ -99,7 +99,7 @@ describe BasePgHelper do
describe '#extension_can_be_enabled?' do
before do
allow(subject).to receive(:is_running?).and_return(true)
allow(subject).to receive(:is_slave?).and_return(false)
allow(subject).to receive(:is_standby?).and_return(false)
allow(subject).to receive(:extension_exists?).and_return(true)
allow(subject).to receive(:database_exists?).and_return(true)
allow(subject).to receive(:extension_enabled?).and_return(false)
Loading
Loading
@@ -115,7 +115,7 @@ describe BasePgHelper do
end
 
it 'cannot be done on a slave' do
allow(subject).to receive(:is_slave?).and_return(true)
allow(subject).to receive(:is_standby?).and_return(true)
expect(subject.extension_can_be_enabled?('extension', 'db')).to be_falsey
end
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment