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
25964a33
Commit
25964a33
authored
Mar 08, 2021
by
Alex Ives
Committed by
Douglas Barbosa Alexandre
Mar 15, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Report data from secondary_usage_data in geo_node_status
Relates to
https://gitlab.com/gitlab-org/gitlab/issues/298781
parent
c152931c
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
2 deletions
+44
-2
ee/app/models/geo_node_status.rb
ee/app/models/geo_node_status.rb
+16
-2
ee/spec/factories/geo_node_statuses.rb
ee/spec/factories/geo_node_statuses.rb
+4
-0
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
ee/spec/models/geo_node_status_spec.rb
ee/spec/models/geo_node_status_spec.rb
+22
-0
No files found.
ee/app/models/geo_node_status.rb
View file @
25964a33
...
@@ -55,6 +55,10 @@ class GeoNodeStatus < ApplicationRecord
...
@@ -55,6 +55,10 @@ class GeoNodeStatus < ApplicationRecord
end
.
flatten
.
map
(
&
:to_s
)
end
.
flatten
.
map
(
&
:to_s
)
end
end
def
self
.
usage_data_fields
Geo
::
SecondaryUsageData
::
PAYLOAD_COUNT_FIELDS
end
RESOURCE_STATUS_FIELDS
=
(
%w(
RESOURCE_STATUS_FIELDS
=
(
%w(
repository_verification_enabled
repository_verification_enabled
repositories_replication_enabled
repositories_replication_enabled
...
@@ -103,7 +107,7 @@ class GeoNodeStatus < ApplicationRecord
...
@@ -103,7 +107,7 @@ class GeoNodeStatus < ApplicationRecord
design_repositories_count
design_repositories_count
design_repositories_synced_count
design_repositories_synced_count
design_repositories_failed_count
design_repositories_failed_count
)
+
replicator_class_status_fields
).
freeze
)
+
replicator_class_status_fields
+
usage_data_fields
).
freeze
# Why are disabled classes included? See https://gitlab.com/gitlab-org/gitlab/-/merge_requests/38959#note_402656534
# Why are disabled classes included? See https://gitlab.com/gitlab-org/gitlab/-/merge_requests/38959#note_402656534
def
self
.
replicator_class_prometheus_metrics
def
self
.
replicator_class_prometheus_metrics
...
@@ -276,7 +280,7 @@ class GeoNodeStatus < ApplicationRecord
...
@@ -276,7 +280,7 @@ class GeoNodeStatus < ApplicationRecord
return
if
val
.
nil?
return
if
val
.
nil?
case
attr_name
case
attr_name
when
/_count\z/
then
val
.
to_i
when
/_count
(?:_weekly)?
\z/
then
val
.
to_i
when
/_enabled\z/
then
val
.
to_s
==
'true'
when
/_enabled\z/
then
val
.
to_s
==
'true'
else
raise
"Unhandled status attribute name format
\"
#{
attr_name
}
\"
"
else
raise
"Unhandled status attribute name format
\"
#{
attr_name
}
\"
"
end
end
...
@@ -480,6 +484,7 @@ class GeoNodeStatus < ApplicationRecord
...
@@ -480,6 +484,7 @@ class GeoNodeStatus < ApplicationRecord
load_container_registry_data
load_container_registry_data
load_designs_data
load_designs_data
load_ssf_replicable_data
load_ssf_replicable_data
load_secondary_usage_data
end
end
def
load_repositories_data
def
load_repositories_data
...
@@ -547,6 +552,15 @@ class GeoNodeStatus < ApplicationRecord
...
@@ -547,6 +552,15 @@ class GeoNodeStatus < ApplicationRecord
end
end
end
end
def
load_secondary_usage_data
usage_data
=
Geo
::
SecondaryUsageData
.
last
return
unless
usage_data
self
.
class
.
usage_data_fields
.
each
do
|
field
|
status
[
field
]
=
usage_data
.
payload
[
field
]
end
end
def
load_repository_check_data
def
load_repository_check_data
if
Gitlab
::
Geo
.
primary?
if
Gitlab
::
Geo
.
primary?
self
.
repositories_checked_count
=
Project
.
where
.
not
(
last_repository_check_at:
nil
).
count
self
.
repositories_checked_count
=
Project
.
where
.
not
(
last_repository_check_at:
nil
).
count
...
...
ee/spec/factories/geo_node_statuses.rb
View file @
25964a33
...
@@ -68,6 +68,10 @@ FactoryBot.define do
...
@@ -68,6 +68,10 @@ FactoryBot.define do
GeoNodeStatus
.
replicator_class_status_fields
.
each
do
|
field
|
GeoNodeStatus
.
replicator_class_status_fields
.
each
do
|
field
|
send
(
field
)
{
rand
(
10000
)
}
send
(
field
)
{
rand
(
10000
)
}
end
end
Geo
::
SecondaryUsageData
::
PAYLOAD_COUNT_FIELDS
.
each
do
|
field
|
send
(
field
)
{
rand
(
10000
)
}
end
end
end
trait
:replicated_and_verified
do
trait
:replicated_and_verified
do
...
...
ee/spec/fixtures/api/schemas/public_api/v4/geo_node_status.json
View file @
25964a33
...
@@ -127,6 +127,7 @@
...
@@ -127,6 +127,7 @@
"replication_slots_used_count"
,
"replication_slots_used_count"
,
"replication_slots_used_in_percentage"
,
"replication_slots_used_in_percentage"
,
"replication_slots_max_retained_wal_bytes"
,
"replication_slots_max_retained_wal_bytes"
,
"git_fetch_event_count_weekly"
,
"last_event_id"
,
"last_event_id"
,
"last_event_timestamp"
,
"last_event_timestamp"
,
"cursor_last_event_id"
,
"cursor_last_event_id"
,
...
@@ -272,6 +273,7 @@
...
@@ -272,6 +273,7 @@
"replication_slots_used_count"
:
{
"type"
:
[
"integer"
,
"null"
]
},
"replication_slots_used_count"
:
{
"type"
:
[
"integer"
,
"null"
]
},
"replication_slots_used_in_percentage"
:
{
"type"
:
"string"
},
"replication_slots_used_in_percentage"
:
{
"type"
:
"string"
},
"replication_slots_max_retained_wal_bytes"
:
{
"type"
:
[
"integer"
,
"null"
]
},
"replication_slots_max_retained_wal_bytes"
:
{
"type"
:
[
"integer"
,
"null"
]
},
"git_fetch_event_count_weekly"
:
{
"type"
:
[
"integer"
,
"null"
]
},
"last_event_id"
:
{
"type"
:
[
"integer"
,
"null"
]
},
"last_event_id"
:
{
"type"
:
[
"integer"
,
"null"
]
},
"last_event_timestamp"
:
{
"type"
:
[
"integer"
,
"null"
]
},
"last_event_timestamp"
:
{
"type"
:
[
"integer"
,
"null"
]
},
"cursor_last_event_id"
:
{
"type"
:
[
"integer"
,
"null"
]
},
"cursor_last_event_id"
:
{
"type"
:
[
"integer"
,
"null"
]
},
...
...
ee/spec/models/geo_node_status_spec.rb
View file @
25964a33
...
@@ -1156,6 +1156,28 @@ RSpec.describe GeoNodeStatus, :geo do
...
@@ -1156,6 +1156,28 @@ RSpec.describe GeoNodeStatus, :geo do
end
end
end
end
context
'secondary usage data'
do
shared_examples_for
'a field from secondary_usage_data'
do
|
field
|
describe
'#load_secondary_usage_data'
do
it
'loads the latest data from Geo::SecondaryUsageData'
do
data
=
create
(
:geo_secondary_usage_data
)
expect
(
described_class
.
current_node_status
.
status
[
field
]).
to
eq
(
data
.
payload
[
field
])
end
it
'reports nil if there is no collected data in Geo::SecondaryUsageData'
do
expect
(
status
.
status
[
field
]).
to
be_nil
end
end
end
described_class
.
usage_data_fields
.
each
do
|
field
|
context
"#
#{
field
}
"
do
it_behaves_like
'a field from secondary_usage_data'
,
field
end
end
end
context
'Replicator stats'
do
context
'Replicator stats'
do
where
(
:replicator
,
:model_factory
,
:registry_factory
)
do
where
(
:replicator
,
:model_factory
,
:registry_factory
)
do
Geo
::
MergeRequestDiffReplicator
|
:external_merge_request_diff
|
:geo_merge_request_diff_registry
Geo
::
MergeRequestDiffReplicator
|
:external_merge_request_diff
|
:geo_merge_request_diff_registry
...
...
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