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
b3a4fa88
Commit
b3a4fa88
authored
Feb 22, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add API endpoint to get Geo node information
parent
1d35406d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
0 deletions
+34
-0
app/models/geo/project_registry.rb
app/models/geo/project_registry.rb
+3
-0
app/models/geo_node.rb
app/models/geo_node.rb
+2
-0
lib/api/entities.rb
lib/api/entities.rb
+7
-0
lib/api/geo.rb
lib/api/geo.rb
+22
-0
No files found.
app/models/geo/project_registry.rb
View file @
b3a4fa88
class
Geo::ProjectRegistry
<
Geo
::
BaseRegistry
validates
:project_id
,
presence:
true
scope
:failed
,
->
{
where
.
not
(
last_repository_synced_at:
nil
).
where
(
last_repository_successful_sync_at:
nil
)
}
scope
:synced
,
->
{
where
.
not
(
last_repository_synced_at:
nil
,
last_repository_successful_sync_at:
nil
)
}
end
app/models/geo_node.rb
View file @
b3a4fa88
class
GeoNode
<
ActiveRecord
::
Base
Status
=
Struct
.
new
(
:health
,
:repositories
,
:repositories_synced
,
:repositories_failed
)
belongs_to
:geo_node_key
,
dependent: :destroy
belongs_to
:oauth_application
,
class_name:
'Doorkeeper::Application'
,
dependent: :destroy
belongs_to
:system_hook
,
dependent: :destroy
...
...
lib/api/entities.rb
View file @
b3a4fa88
...
...
@@ -768,5 +768,12 @@ module API
expose
:id
,
:message
,
:starts_at
,
:ends_at
,
:color
,
:font
expose
:active?
,
as: :active
end
class
GeoNodeStatus
<
Grape
::
Entity
expose
:health
expose
:repositories
expose
:repositories_synced
expose
:repositories_failed
end
end
end
lib/api/geo.rb
View file @
b3a4fa88
...
...
@@ -28,6 +28,24 @@ module API
end
end
# Get node information (e.g. health, repos synced, repos failed, etc.)
#
# Example request:
# GET /geo/status
get
'status'
do
authenticated_as_admin!
require_node_to_be_secondary!
status
=
GeoNode
::
Status
.
new
(
HealthCheck
::
Utils
.
process_checks
([
'geo'
]),
Project
.
count
,
::
Geo
::
ProjectRegistry
.
synced
.
count
,
::
Geo
::
ProjectRegistry
.
failed
.
count
)
present
status
,
with:
Entities
::
GeoNodeStatus
end
# Enqueue a batch of IDs of wiki's projects to have their
# wiki repositories updated
#
...
...
@@ -82,6 +100,10 @@ module API
def
require_node_to_be_enabled!
forbidden!
'Geo node is disabled.'
unless
Gitlab
::
Geo
.
current_node
.
enabled?
end
def
require_node_to_be_secondary!
forbidden!
'Geo node is disabled.'
unless
Gitlab
::
Geo
.
current_node
.
secondary?
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