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
ba2749f6
Commit
ba2749f6
authored
Sep 13, 2017
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only set status variables if Geo node is a secondary
parent
c472e8f6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
2 deletions
+21
-2
app/models/geo_node_status.rb
app/models/geo_node_status.rb
+6
-2
spec/models/geo_node_status_spec.rb
spec/models/geo_node_status_spec.rb
+15
-0
No files found.
app/models/geo_node_status.rb
View file @
ba2749f6
...
...
@@ -15,7 +15,9 @@ class GeoNodeStatus
end
def
db_replication_lag
@db_replication_lag
||=
Gitlab
::
Geo
::
HealthCheck
.
db_replication_lag
return
@db_replication_lag
if
defined?
(
@db_replication_lag
)
@db_replication_lag
=
Gitlab
::
Geo
::
HealthCheck
.
db_replication_lag
if
Gitlab
::
Geo
.
secondary?
end
def
db_replication_lag
=
(
value
)
...
...
@@ -39,7 +41,9 @@ class GeoNodeStatus
end
def
cursor_last_event_id
@cursor_last_event_id
||=
cursor_last_processed
&
.
event_id
return
@cursor_last_event_id
if
defined?
(
@cursor_last_event_id
)
@cursor_last_event_id
=
cursor_last_processed
&
.
event_id
if
Gitlab
::
Geo
.
secondary?
end
def
cursor_last_event_id
=
(
value
)
...
...
spec/models/geo_node_status_spec.rb
View file @
ba2749f6
...
...
@@ -104,6 +104,13 @@ describe GeoNodeStatus do
expect
(
subject
.
db_replication_lag
).
to
eq
(
1000
)
end
it
"doesn't attempt to set replication lag if primary"
do
expect
(
Gitlab
::
Geo
::
HealthCheck
).
not_to
receive
(
:db_replication_lag
)
expect
(
Gitlab
::
Geo
).
to
receive
(
:secondary?
).
and_return
(
false
)
expect
(
subject
.
db_replication_lag
).
to
eq
(
nil
)
end
end
describe
'#lfs_objects_synced_in_percentage'
do
...
...
@@ -196,6 +203,14 @@ describe GeoNodeStatus do
expect
(
subject
.
cursor_last_event_id
).
to
eq
(
event
.
event_id
)
end
it
"doesn't attempt to retrieve cursor if primary"
do
event
=
create
(
:geo_event_log_state
)
expect
(
Gitlab
::
Geo
).
to
receive
(
:secondary?
).
exactly
(
2
).
times
.
and_return
(
false
)
expect
(
subject
.
cursor_last_event_date
).
to
eq
(
nil
)
expect
(
subject
.
cursor_last_event_id
).
to
eq
(
nil
)
end
end
context
'when no values are available'
do
...
...
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