Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
05bed98a
Commit
05bed98a
authored
Oct 31, 2017
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Gitlab::Database.read_only? works correctly for EE version (specs included)
parent
917e7187
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
37 additions
and
15 deletions
+37
-15
changelogs/unreleased-ee/3876-can-push-code-to-geo-secondaries.yml
...s/unreleased-ee/3876-can-push-code-to-geo-secondaries.yml
+5
-0
ee/lib/ee/gitlab/database.rb
ee/lib/ee/gitlab/database.rb
+0
-11
lib/gitlab/database.rb
lib/gitlab/database.rb
+1
-3
lib/tasks/migrate/setup_postgresql.rake
lib/tasks/migrate/setup_postgresql.rake
+0
-1
spec/lib/gitlab/database_spec.rb
spec/lib/gitlab/database_spec.rb
+31
-0
No files found.
changelogs/unreleased-ee/3876-can-push-code-to-geo-secondaries.yml
0 → 100644
View file @
05bed98a
---
title
:
'
Geo:
read-only
safeguards
was
not
working
on
Secondary
node'
merge_request
:
3227
author
:
type
:
fixed
ee/lib/ee/gitlab/database.rb
deleted
100644 → 0
View file @
917e7187
module
EE
module
Gitlab
module
Database
def
self
.
read_only?
raise
NotImplementedError
unless
defined?
(
super
)
Gitlab
::
Geo
.
secondary?
||
super
end
end
end
end
lib/gitlab/database.rb
View file @
05bed98a
module
Gitlab
module
Database
extend
::
EE
::
Gitlab
::
Database
# The max value of INTEGER type is the same between MySQL and PostgreSQL:
# https://www.postgresql.org/docs/9.2/static/datatype-numeric.html
# http://dev.mysql.com/doc/refman/5.7/en/integer-types.html
...
...
@@ -33,7 +31,7 @@ module Gitlab
# Overridden in EE
def
self
.
read_only?
false
Gitlab
::
Geo
.
secondary?
end
def
self
.
read_write?
...
...
lib/tasks/migrate/setup_postgresql.rake
View file @
05bed98a
require
Rails
.
root
.
join
(
'ee/lib/ee/gitlab/database'
)
require
Rails
.
root
.
join
(
'lib/gitlab/database'
)
require
Rails
.
root
.
join
(
'lib/gitlab/database/migration_helpers'
)
require
Rails
.
root
.
join
(
'db/migrate/20151007120511_namespaces_projects_path_lower_indexes'
)
...
...
spec/lib/gitlab/database_spec.rb
View file @
05bed98a
...
...
@@ -273,4 +273,35 @@ describe Gitlab::Database do
expect
(
config
[
'prepared_statements'
]).
to
eq
(
false
)
end
end
describe
'.read_only?'
do
context
'with Geo enabled'
do
before
do
allow
(
Gitlab
::
Geo
).
to
receive
(
:enabled?
)
{
true
}
allow
(
Gitlab
::
Geo
).
to
receive
(
:current_node
)
{
geo_node
}
end
context
'is Geo secondary node'
do
let
(
:geo_node
)
{
create
(
:geo_node
)
}
it
'returns true'
do
expect
(
described_class
.
read_only?
).
to
be_truthy
end
end
context
'is Geo primary node'
do
let
(
:geo_node
)
{
create
(
:geo_node
,
:primary
)
}
it
'returns false when is Geo primary node'
do
expect
(
described_class
.
read_only?
).
to
be_falsey
end
end
end
context
'with Geo disabled'
do
it
'returns false'
do
expect
(
described_class
.
read_only?
).
to
be_falsey
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment