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
642fc9cb
Commit
642fc9cb
authored
Aug 14, 2017
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show Geo event log and cursor data in node status page
parent
f0deea60
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
136 additions
and
4 deletions
+136
-4
app/assets/javascripts/geo_nodes.js
app/assets/javascripts/geo_nodes.js
+7
-0
app/models/geo/event_log.rb
app/models/geo/event_log.rb
+4
-0
app/models/geo_node_status.rb
app/models/geo_node_status.rb
+44
-0
app/serializers/geo_node_status_entity.rb
app/serializers/geo_node_status_entity.rb
+5
-0
app/services/geo/node_status_service.rb
app/services/geo/node_status_service.rb
+4
-0
app/views/admin/geo_nodes/index.html.haml
app/views/admin/geo_nodes/index.html.haml
+7
-0
changelogs/unreleased-ee/sh-geo-show-event-log-data.yml
changelogs/unreleased-ee/sh-geo-show-event-log-data.yml
+5
-0
lib/api/entities.rb
lib/api/entities.rb
+4
-0
spec/controllers/admin/geo_nodes_controller_spec.rb
spec/controllers/admin/geo_nodes_controller_spec.rb
+5
-1
spec/fixtures/api/schemas/geo_node_status.json
spec/fixtures/api/schemas/geo_node_status.json
+10
-2
spec/models/geo_node_status_spec.rb
spec/models/geo_node_status_spec.rb
+36
-0
spec/services/geo/node_status_service_spec.rb
spec/services/geo/node_status_service_spec.rb
+5
-1
No files found.
app/assets/javascripts/geo_nodes.js
View file @
642fc9cb
/* eslint-disable no-new*/
import
'
./smart_interval
'
;
import
'
./lib/utils/datetime_utility
'
;
const
healthyClass
=
'
geo-node-healthy
'
;
const
unhealthyClass
=
'
geo-node-unhealthy
'
;
...
...
@@ -20,6 +21,8 @@ class GeoNodeStatus {
this
.
$repositoriesFailed
=
$
(
'
.js-repositories-failed
'
,
this
.
$status
);
this
.
$lfsObjectsSynced
=
$
(
'
.js-lfs-objects-synced
'
,
this
.
$status
);
this
.
$attachmentsSynced
=
$
(
'
.js-attachments-synced
'
,
this
.
$status
);
this
.
$lastEventSeen
=
$
(
'
.js-last-event-seen
'
,
this
.
$status
);
this
.
$lastCursorEvent
=
$
(
'
.js-last-cursor-event
'
,
this
.
$status
);
this
.
$health
=
$
(
'
.js-health
'
,
this
.
$status
);
this
.
endpoint
=
this
.
$el
.
data
(
'
status-url
'
);
...
...
@@ -50,6 +53,10 @@ class GeoNodeStatus {
this
.
$repositoriesFailed
.
html
(
status
.
repositories_failed_count
);
this
.
$lfsObjectsSynced
.
html
(
`
${
status
.
lfs_objects_synced_count
}
/
${
status
.
lfs_objects_count
}
(
${
status
.
lfs_objects_synced_in_percentage
}
)`
);
this
.
$attachmentsSynced
.
html
(
`
${
status
.
attachments_synced_count
}
/
${
status
.
attachments_count
}
(
${
status
.
attachments_synced_in_percentage
}
)`
);
const
eventDate
=
gl
.
utils
.
formatDate
(
new
Date
(
status
.
last_event_date
));
const
cursorDate
=
gl
.
utils
.
formatDate
(
new
Date
(
status
.
cursor_last_event_date
));
this
.
$lastEventSeen
.
html
(
`
${
status
.
last_event_id
}
(
${
eventDate
}
)`
);
this
.
$lastCursorEvent
.
html
(
`
${
status
.
cursor_last_event_id
}
(
${
cursorDate
}
)`
);
if
(
status
.
health
===
'
Healthy
'
)
{
this
.
$health
.
html
(
''
);
}
else
{
...
...
app/models/geo/event_log.rb
View file @
642fc9cb
...
...
@@ -18,6 +18,10 @@ module Geo
class_name:
'Geo::RepositoriesChangedEvent'
,
foreign_key: :repositories_changed_event_id
def
self
.
latest_event
order
(
id: :desc
).
first
end
def
event
repository_updated_event
||
repository_deleted_event
||
...
...
app/models/geo_node_status.rb
View file @
642fc9cb
...
...
@@ -21,6 +21,42 @@ class GeoNodeStatus
def
db_replication_lag
=
(
value
)
@db_replication_lag
=
value
end
def
last_event_id
@last_event_id
||=
latest_event
&
.
id
end
def
last_event_id
=
(
value
)
@last_event_id
=
value
end
def
last_event_date
@last_event_date
||=
Geo
::
EventLog
.
latest_event
&
.
created_at
end
def
last_event_date
=
(
value
)
@last_event_date
=
value
end
def
cursor_last_event_id
@cursor_last_event_id
||=
cursor_last_processed
&
.
event_id
end
def
cursor_last_event_id
=
(
value
)
@cursor_last_event_id
=
value
end
def
cursor_last_event_date
event_id
=
cursor_last_event_id
return
unless
event_id
@cursor_last_event_date
||=
Geo
::
EventLog
.
find_by
(
id:
event_id
)
&
.
created_at
end
def
cursor_last_event_date
=
(
value
)
@cursor_last_event_date
=
value
end
def
repositories_count
@repositories_count
||=
repositories
.
count
...
...
@@ -126,4 +162,12 @@ class GeoNodeStatus
def
repositories
@repositories
||=
Gitlab
::
Geo
.
current_node
.
projects
end
def
latest_event
Geo
::
EventLog
.
latest_event
end
def
cursor_last_processed
Geo
::
EventLogState
.
last_processed
end
end
app/serializers/geo_node_status_entity.rb
View file @
642fc9cb
...
...
@@ -28,4 +28,9 @@ class GeoNodeStatusEntity < Grape::Entity
expose
:repositories_synced_in_percentage
do
|
node
|
number_to_percentage
(
node
.
repositories_synced_in_percentage
,
precision:
2
)
end
expose
:last_event_id
expose
:last_event_date
expose
:cursor_last_event_id
expose
:cursor_last_event_date
end
app/services/geo/node_status_service.rb
View file @
642fc9cb
...
...
@@ -13,6 +13,10 @@ module Geo
lfs_objects_synced_count
attachments_count
attachments_synced_count
last_event_id
last_event_date
cursor_last_event_id
cursor_last_event_date
)
.
freeze
def
call
(
geo_node
)
...
...
app/views/admin/geo_nodes/index.html.haml
View file @
642fc9cb
...
...
@@ -65,6 +65,13 @@
%span
.help-block
Attachments synced:
%strong
.node-info.js-attachments-synced
%p
%span
.help-block
Last event ID seen from primary:
%strong
.node-info.js-last-event-seen
%span
.help-block
Last event ID processed by cursor:
%strong
.node-info.js-last-cursor-event
%p
.js-health
...
...
changelogs/unreleased-ee/sh-geo-show-event-log-data.yml
0 → 100644
View file @
642fc9cb
---
title
:
Show Geo event log and cursor data in node status page
merge_request
:
author
:
type
:
changed
lib/api/entities.rb
View file @
642fc9cb
...
...
@@ -957,6 +957,10 @@ module API
expose
:lfs_objects_synced_count
expose
:attachments_count
expose
:attachments_synced_count
expose
:last_event_id
expose
:last_event_date
expose
:cursor_last_event_id
expose
:cursor_last_event_date
end
class
PersonalAccessToken
<
Grape
::
Entity
...
...
spec/controllers/admin/geo_nodes_controller_spec.rb
View file @
642fc9cb
...
...
@@ -267,7 +267,11 @@ describe Admin::GeoNodesController, :postgresql do
lfs_objects_synced_count:
123
,
repositories_count:
10
,
repositories_synced_count:
5
,
repositories_failed_count:
0
repositories_failed_count:
0
,
last_event_id:
2
,
last_event_date:
Time
.
now
.
iso8601
,
cursor_last_event_id:
1
,
cursor_last_event_date:
Time
.
now
.
iso8601
)
end
...
...
spec/fixtures/api/schemas/geo_node_status.json
View file @
642fc9cb
...
...
@@ -11,7 +11,11 @@
"db_replication_lag"
,
"repositories_count"
,
"repositories_failed_count"
,
"repositories_synced_count"
"repositories_synced_count"
,
"last_event_id"
,
"last_event_date"
,
"cursor_last_event_id"
,
"cursor_last_event_date"
],
"properties"
:
{
"id"
:
{
"type"
:
"integer"
},
...
...
@@ -27,7 +31,11 @@
"repositories_count"
:
{
"type"
:
"integer"
},
"repositories_failed_count"
:
{
"type"
:
"integer"
},
"repositories_synced_count"
:
{
"type"
:
"integer"
},
"repositories_synced_in_percentage"
:
{
"type"
:
"string"
}
"repositories_synced_in_percentage"
:
{
"type"
:
"string"
},
"last_event_id"
:
{
"type"
:
[
"integer"
,
"null"
]
},
"last_event_date"
:
{
"type"
:
[
"string"
,
"null"
]
},
"cursor_last_event_id"
:
{
"type"
:
[
"integer"
,
"null"
]
},
"cursor_last_event_date"
:
{
"type"
:
[
"string"
,
"null"
]
}
},
"additionalProperties"
:
false
}
spec/models/geo_node_status_spec.rb
View file @
642fc9cb
...
...
@@ -170,6 +170,34 @@ describe GeoNodeStatus do
end
end
describe
'#last_event_id and #last_event_date'
do
it
'returns nil when no events are available'
do
expect
(
subject
.
last_event_id
).
to
be_nil
expect
(
subject
.
last_event_date
).
to
be_nil
end
it
'returns the latest event'
do
created_at
=
Date
.
new
(
2017
,
10
,
22
)
event
=
create
(
:geo_event_log
,
created_at:
created_at
)
expect
(
subject
.
last_event_id
).
to
eq
(
event
.
id
)
expect
(
subject
.
last_event_date
).
to
eq
(
created_at
)
end
end
describe
'#cursor_last_event_id and #cursor_last_event_date'
do
it
'returns nil when no events are available'
do
expect
(
subject
.
cursor_last_event_id
).
to
be_nil
expect
(
subject
.
cursor_last_event_date
).
to
be_nil
end
it
'returns the latest event ID'
do
event
=
create
(
:geo_event_log_state
)
expect
(
subject
.
cursor_last_event_id
).
to
eq
(
event
.
event_id
)
end
end
context
'when no values are available'
do
it
'returns 0 for each attribute'
do
allow
(
Gitlab
::
Geo
::
HealthCheck
).
to
receive
(
:db_replication_lag
).
and_return
(
nil
)
...
...
@@ -180,6 +208,10 @@ describe GeoNodeStatus do
subject
.
repositories_count
=
nil
subject
.
repositories_synced_count
=
nil
subject
.
repositories_failed_count
=
nil
subject
.
last_event_id
=
nil
subject
.
last_event_date
=
nil
subject
.
cursor_last_event_id
=
nil
subject
.
cursor_last_event_date
=
nil
expect
(
subject
.
db_replication_lag
).
to
be_nil
expect
(
subject
.
repositories_count
).
to
be_zero
...
...
@@ -192,6 +224,10 @@ describe GeoNodeStatus do
expect
(
subject
.
attachments_count
).
to
be_zero
expect
(
subject
.
attachments_synced_count
).
to
be_zero
expect
(
subject
.
attachments_synced_in_percentage
).
to
be_zero
expect
(
subject
.
last_event_id
).
to
be_nil
expect
(
subject
.
last_event_date
).
to
be_nil
expect
(
subject
.
cursor_last_event_id
).
to
be_nil
expect
(
subject
.
cursor_last_event_date
).
to
be_nil
end
end
end
spec/services/geo/node_status_service_spec.rb
View file @
642fc9cb
...
...
@@ -32,7 +32,11 @@ describe Geo::NodeStatusService do
lfs_objects_count:
100
,
lfs_objects_synced_count:
50
,
attachments_count:
30
,
attachments_synced_count:
30
}
attachments_synced_count:
30
,
last_event_id:
2
,
last_event_date:
Time
.
now
,
cursor_last_event_id:
1
,
cursor_last_event_date:
Time
.
now
}
request
=
double
(
success?:
true
,
parsed_response:
data
.
stringify_keys
,
code:
200
)
allow
(
described_class
).
to
receive
(
:get
).
and_return
(
request
)
...
...
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