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
f56731fc
Commit
f56731fc
authored
Nov 02, 2017
by
Toon Claes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make Geo::PruneEventLogWorker generate some logging
parent
7d125f1a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
2 deletions
+10
-2
app/workers/geo/prune_event_log_worker.rb
app/workers/geo/prune_event_log_worker.rb
+6
-2
spec/workers/geo/prune_event_log_worker_spec.rb
spec/workers/geo/prune_event_log_worker_spec.rb
+4
-0
No files found.
app/workers/geo/prune_event_log_worker.rb
View file @
f56731fc
...
@@ -16,6 +16,7 @@ module Geo
...
@@ -16,6 +16,7 @@ module Geo
try_obtain_lease
do
try_obtain_lease
do
if
Gitlab
::
Geo
.
secondary_nodes
.
empty?
if
Gitlab
::
Geo
.
secondary_nodes
.
empty?
log_info
(
'No secondary nodes, delete all Geo Event Log entries'
)
Geo
::
EventLog
.
delete_all
Geo
::
EventLog
.
delete_all
return
return
end
end
...
@@ -24,9 +25,12 @@ module Geo
...
@@ -24,9 +25,12 @@ module Geo
Geo
::
NodeStatusService
.
new
.
call
(
node
).
cursor_last_event_id
Geo
::
NodeStatusService
.
new
.
call
(
node
).
cursor_last_event_id
end
end
# Abort when any of the nodes could not be contacted
if
cursor_last_event_ids
.
include?
(
nil
)
return
if
cursor_last_event_ids
.
include?
(
nil
)
log_info
(
'Could not get status of all nodes, not deleting any entries from Geo Event Log'
,
unhealthy_node_count:
cursor_last_event_ids
.
count
(
nil
))
return
end
log_info
(
'Delete Geo Event Log entries up to id'
,
geo_event_log_id:
cursor_last_event_ids
.
min
)
Geo
::
EventLog
.
delete_all
([
'id < ?'
,
cursor_last_event_ids
.
min
])
Geo
::
EventLog
.
delete_all
([
'id < ?'
,
cursor_last_event_ids
.
min
])
end
end
end
end
...
...
spec/workers/geo/prune_event_log_worker_spec.rb
View file @
f56731fc
...
@@ -43,6 +43,7 @@ describe Geo::PruneEventLogWorker, :geo do
...
@@ -43,6 +43,7 @@ describe Geo::PruneEventLogWorker, :geo do
end
end
it
'deletes everything from the Geo event log'
do
it
'deletes everything from the Geo event log'
do
expect
(
worker
).
to
receive
(
:log_info
).
with
(
'No secondary nodes, delete all Geo Event Log entries'
)
expect
(
Geo
::
EventLog
).
to
receive
(
:delete_all
)
expect
(
Geo
::
EventLog
).
to
receive
(
:delete_all
)
worker
.
perform
worker
.
perform
...
@@ -62,6 +63,7 @@ describe Geo::PruneEventLogWorker, :geo do
...
@@ -62,6 +63,7 @@ describe Geo::PruneEventLogWorker, :geo do
it
'contacts all secondary nodes for their status'
do
it
'contacts all secondary nodes for their status'
do
expect
(
node_status_service
).
to
receive
(
:call
).
twice
{
healthy_status
}
expect
(
node_status_service
).
to
receive
(
:call
).
twice
{
healthy_status
}
expect
(
worker
).
to
receive
(
:log_info
).
with
(
'Delete Geo Event Log entries up to id'
,
anything
)
expect
(
Geo
::
EventLog
).
to
receive
(
:delete_all
)
expect
(
Geo
::
EventLog
).
to
receive
(
:delete_all
)
worker
.
perform
worker
.
perform
...
@@ -69,6 +71,7 @@ describe Geo::PruneEventLogWorker, :geo do
...
@@ -69,6 +71,7 @@ describe Geo::PruneEventLogWorker, :geo do
it
'aborts when there are unhealthy nodes'
do
it
'aborts when there are unhealthy nodes'
do
expect
(
node_status_service
).
to
receive
(
:call
).
twice
.
and_return
(
healthy_status
,
unhealthy_status
)
expect
(
node_status_service
).
to
receive
(
:call
).
twice
.
and_return
(
healthy_status
,
unhealthy_status
)
expect
(
worker
).
to
receive
(
:log_info
).
with
(
'Could not get status of all nodes, not deleting any entries from Geo Event Log'
,
unhealthy_node_count:
1
)
expect
(
Geo
::
EventLog
).
not_to
receive
(
:delete_all
)
expect
(
Geo
::
EventLog
).
not_to
receive
(
:delete_all
)
worker
.
perform
worker
.
perform
...
@@ -79,6 +82,7 @@ describe Geo::PruneEventLogWorker, :geo do
...
@@ -79,6 +82,7 @@ describe Geo::PruneEventLogWorker, :geo do
build
(
:geo_node_status
,
:healthy
,
cursor_last_event_id:
3
),
build
(
:geo_node_status
,
:healthy
,
cursor_last_event_id:
3
),
build
(
:geo_node_status
,
:healthy
,
cursor_last_event_id:
10
)
build
(
:geo_node_status
,
:healthy
,
cursor_last_event_id:
10
)
)
)
expect
(
worker
).
to
receive
(
:log_info
).
with
(
'Delete Geo Event Log entries up to id'
,
geo_event_log_id:
3
)
expect
(
Geo
::
EventLog
).
to
receive
(
:delete_all
).
with
([
'id < ?'
,
3
])
expect
(
Geo
::
EventLog
).
to
receive
(
:delete_all
).
with
([
'id < ?'
,
3
])
worker
.
perform
worker
.
perform
...
...
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