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
619e2984
Commit
619e2984
authored
Apr 03, 2020
by
Valery Sizov
Committed by
Mike Kozono
Apr 14, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expose GeoNodeStatus entities based on the decrared list
of fields
parent
9e2133e2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
90 deletions
+25
-90
ee/app/models/geo_node_status.rb
ee/app/models/geo_node_status.rb
+9
-1
ee/lib/ee/api/entities/geo_node_status.rb
ee/lib/ee/api/entities/geo_node_status.rb
+14
-89
ee/spec/fixtures/api/schemas/public_api/v4/geo_node_status.json
...c/fixtures/api/schemas/public_api/v4/geo_node_status.json
+2
-0
No files found.
ee/app/models/geo_node_status.rb
View file @
619e2984
...
...
@@ -298,8 +298,16 @@ class GeoNodeStatus < ApplicationRecord
self
[
attr
]
=
Time
.
at
(
value
)
end
def
self
.
percentage_methods
@percentage_methods
||
[]
end
def
self
.
attr_in_percentage
(
attr_name
,
count
,
total
)
define_method
(
"
#{
attr_name
}
_in_percentage"
)
do
method_name
=
"
#{
attr_name
}
_in_percentage"
@percentage_methods
||=
[]
@percentage_methods
<<
method_name
define_method
(
method_name
)
do
return
0
if
self
[
total
].
to_i
.
zero?
(
self
[
count
].
to_f
/
self
[
total
].
to_f
)
*
100.0
...
...
ee/lib/ee/api/entities/geo_node_status.rb
View file @
619e2984
...
...
@@ -9,6 +9,19 @@ module EE
expose
:geo_node_id
::
GeoNodeStatus
::
RESOURCE_STATUS_FIELDS
.
each
do
|
field
|
expose
field
end
::
GeoNodeStatus
.
percentage_methods
.
each
do
|
method_name
|
expose
method_name
do
|
node
|
number_to_percentage
(
node
[
method_name
],
precision:
2
)
end
end
expose
:replication_slots_count
expose
:replication_slots_used_count
expose
:healthy?
,
as: :healthy
expose
:health
do
|
node
|
node
.
healthy?
?
'Healthy'
:
node
.
health
...
...
@@ -16,109 +29,21 @@ module EE
expose
:health_status
expose
:missing_oauth_application
expose
:attachments_replication_enabled
expose
:attachments_count
expose
:attachments_synced_count
expose
:attachments_failed_count
expose
:attachments_synced_missing_on_primary_count
expose
:attachments_synced_in_percentage
do
|
node
|
number_to_percentage
(
node
.
attachments_synced_in_percentage
,
precision:
2
)
end
expose
:db_replication_lag_seconds
expose
:attachments_replication_enabled
expose
:lfs_objects_replication_enabled
expose
:lfs_objects_count
expose
:lfs_objects_synced_count
expose
:lfs_objects_failed_count
expose
:lfs_objects_synced_missing_on_primary_count
expose
:lfs_objects_synced_in_percentage
do
|
node
|
number_to_percentage
(
node
.
lfs_objects_synced_in_percentage
,
precision:
2
)
end
expose
:job_artifacts_replication_enabled
expose
:job_artifacts_count
expose
:job_artifacts_synced_count
expose
:job_artifacts_failed_count
expose
:job_artifacts_synced_missing_on_primary_count
expose
:job_artifacts_synced_in_percentage
do
|
node
|
number_to_percentage
(
node
.
job_artifacts_synced_in_percentage
,
precision:
2
)
end
expose
:container_repositories_replication_enabled
expose
:container_repositories_count
expose
:container_repositories_synced_count
expose
:container_repositories_failed_count
expose
:container_repositories_synced_in_percentage
do
|
node
|
number_to_percentage
(
node
.
container_repositories_synced_in_percentage
,
precision:
2
)
end
expose
:design_repositories_replication_enabled
expose
:design_repositories_count
expose
:design_repositories_synced_count
expose
:design_repositories_failed_count
expose
:design_repositories_synced_in_percentage
do
|
node
|
number_to_percentage
(
node
.
design_repositories_synced_in_percentage
,
precision:
2
)
end
expose
:repositories_replication_enabled
expose
:projects_count
expose
:repositories_failed_count
expose
:repositories_synced_count
expose
:repositories_synced_in_percentage
do
|
node
|
number_to_percentage
(
node
.
repositories_synced_in_percentage
,
precision:
2
)
end
expose
:wikis_failed_count
expose
:wikis_synced_count
expose
:wikis_synced_in_percentage
do
|
node
|
number_to_percentage
(
node
.
wikis_synced_in_percentage
,
precision:
2
)
end
expose
:repository_verification_enabled
expose
:repositories_checksummed_count
expose
:repositories_checksum_failed_count
expose
:repositories_checksummed_in_percentage
do
|
node
|
number_to_percentage
(
node
.
repositories_checksummed_in_percentage
,
precision:
2
)
end
expose
:wikis_checksummed_count
expose
:wikis_checksum_failed_count
expose
:wikis_checksummed_in_percentage
do
|
node
|
number_to_percentage
(
node
.
wikis_checksummed_in_percentage
,
precision:
2
)
end
expose
:repositories_verification_failed_count
expose
:repositories_verified_count
expose
:repositories_verified_in_percentage
do
|
node
|
number_to_percentage
(
node
.
repositories_verified_in_percentage
,
precision:
2
)
end
expose
:repositories_checksum_mismatch_count
expose
:wikis_verification_failed_count
expose
:wikis_verified_count
expose
:wikis_verified_in_percentage
do
|
node
|
number_to_percentage
(
node
.
wikis_verified_in_percentage
,
precision:
2
)
end
expose
:wikis_checksum_mismatch_count
expose
:repositories_retrying_verification_count
expose
:wikis_retrying_verification_count
expose
:replication_slots_count
expose
:replication_slots_used_count
expose
:replication_slots_used_in_percentage
do
|
node
|
number_to_percentage
(
node
.
replication_slots_used_in_percentage
,
precision:
2
)
end
expose
:replication_slots_max_retained_wal_bytes
expose
:repositories_checked_count
expose
:repositories_checked_failed_count
expose
:repositories_checked_in_percentage
do
|
node
|
number_to_percentage
(
node
.
repositories_checked_in_percentage
,
precision:
2
)
end
expose
:last_event_id
expose
:last_event_timestamp
...
...
ee/spec/fixtures/api/schemas/public_api/v4/geo_node_status.json
View file @
619e2984
...
...
@@ -26,6 +26,7 @@
"container_repositories_count"
,
"container_repositories_failed_count"
,
"container_repositories_synced_count"
,
"container_repositories_registry_count"
,
"design_repositories_replication_enabled"
,
"design_repositories_count"
,
"design_repositories_failed_count"
,
...
...
@@ -101,6 +102,7 @@
"container_repositories_failed_count"
:
{
"type"
:
[
"integer"
,
"null"
]
},
"container_repositories_synced_count"
:
{
"type"
:
[
"integer"
,
"null"
]
},
"container_repositories_synced_in_percentage"
:
{
"type"
:
"string"
},
"container_repositories_registry_count"
:
{
"type"
:
[
"integer"
,
"null"
]
},
"design_repositories_replication_enabled"
:
{
"type"
:
"boolean"
},
"design_repositories_count"
:
{
"type"
:
"integer"
},
"design_repositories_failed_count"
:
{
"type"
:
[
"integer"
,
"null"
]
},
...
...
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