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
16f107cb
Commit
16f107cb
authored
May 27, 2019
by
Toon Claes
Committed by
Douglas Barbosa Alexandre
Jul 18, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Split out load_ methods and simplify condition
Don't put code in large if blocks, but do an early return instead.
parent
8ba8815c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
65 additions
and
63 deletions
+65
-63
ee/app/models/geo_node_status.rb
ee/app/models/geo_node_status.rb
+65
-63
No files found.
ee/app/models/geo_node_status.rb
View file @
16f107cb
...
@@ -145,13 +145,6 @@ class GeoNodeStatus < ApplicationRecord
...
@@ -145,13 +145,6 @@ class GeoNodeStatus < ApplicationRecord
end
end
def
load_data_from_current_node
def
load_data_from_current_node
self
.
status_message
=
begin
HealthCheck
::
Utils
.
process_checks
([
'geo'
])
rescue
NotImplementedError
=>
e
e
.
to_s
end
latest_event
=
Geo
::
EventLog
.
latest_event
latest_event
=
Geo
::
EventLog
.
latest_event
self
.
last_event_id
=
latest_event
&
.
id
self
.
last_event_id
=
latest_event
&
.
id
self
.
last_event_date
=
latest_event
&
.
created_at
self
.
last_event_date
=
latest_event
&
.
created_at
...
@@ -175,77 +168,86 @@ class GeoNodeStatus < ApplicationRecord
...
@@ -175,77 +168,86 @@ class GeoNodeStatus < ApplicationRecord
self
.
hashed_storage_attachments_max_id
=
Geo
::
HashedStorageAttachmentsEvent
.
maximum
(
:id
)
self
.
hashed_storage_attachments_max_id
=
Geo
::
HashedStorageAttachmentsEvent
.
maximum
(
:id
)
self
.
projects_count
=
geo_node
.
projects
.
count
self
.
projects_count
=
geo_node
.
projects
.
count
load_status_message
load_primary_data
load_primary_data
load_secondary_data
load_secondary_data
self
self
end
end
def
load_primary_data
def
load_status_message
if
Gitlab
::
Geo
.
primary?
self
.
status_message
=
self
.
lfs_objects_count
=
LfsObject
.
syncable
.
count
begin
self
.
job_artifacts_count
=
Ci
::
JobArtifact
.
syncable
.
count
HealthCheck
::
Utils
.
process_checks
([
'geo'
])
self
.
attachments_count
=
Upload
.
syncable
.
count
rescue
NotImplementedError
=>
e
e
.
to_s
self
.
replication_slots_count
=
geo_node
.
replication_slots_count
self
.
replication_slots_used_count
=
geo_node
.
replication_slots_used_count
self
.
replication_slots_max_retained_wal_bytes
=
geo_node
.
replication_slots_max_retained_wal_bytes
if
repository_verification_enabled
self
.
repositories_checksummed_count
=
repository_verification_finder
.
count_verified_repositories
self
.
repositories_checksum_failed_count
=
repository_verification_finder
.
count_verification_failed_repositories
self
.
wikis_checksummed_count
=
repository_verification_finder
.
count_verified_wikis
self
.
wikis_checksum_failed_count
=
repository_verification_finder
.
count_verification_failed_wikis
end
end
end
def
load_primary_data
return
unless
Gitlab
::
Geo
.
primary?
self
.
lfs_objects_count
=
LfsObject
.
syncable
.
count
self
.
job_artifacts_count
=
Ci
::
JobArtifact
.
syncable
.
count
self
.
attachments_count
=
Upload
.
syncable
.
count
self
.
repositories_checked_count
=
Project
.
where
.
not
(
last_repository_check_at:
nil
).
count
self
.
replication_slots_count
=
geo_node
.
replication_slots_count
self
.
repositories_checked_failed_count
=
Project
.
where
(
last_repository_check_failed:
true
).
count
self
.
replication_slots_used_count
=
geo_node
.
replication_slots_used_count
self
.
replication_slots_max_retained_wal_bytes
=
geo_node
.
replication_slots_max_retained_wal_bytes
if
repository_verification_enabled
self
.
repositories_checksummed_count
=
repository_verification_finder
.
count_verified_repositories
self
.
repositories_checksum_failed_count
=
repository_verification_finder
.
count_verification_failed_repositories
self
.
wikis_checksummed_count
=
repository_verification_finder
.
count_verified_wikis
self
.
wikis_checksum_failed_count
=
repository_verification_finder
.
count_verification_failed_wikis
end
end
end
end
def
load_secondary_data
# rubocop:disable Metrics/AbcSize
def
load_secondary_data
# rubocop:disable Metrics/AbcSize
if
Gitlab
::
Geo
.
secondary?
return
unless
Gitlab
::
Geo
.
secondary?
self
.
db_replication_lag_seconds
=
Gitlab
::
Geo
::
HealthCheck
.
new
.
db_replication_lag_seconds
self
.
cursor_last_event_id
=
current_cursor_last_event_id
self
.
db_replication_lag_seconds
=
Gitlab
::
Geo
::
HealthCheck
.
new
.
db_replication_lag_seconds
self
.
cursor_last_event_date
=
Geo
::
EventLog
.
find_by
(
id:
self
.
cursor_last_event_id
)
&
.
created_at
self
.
cursor_last_event_id
=
current_cursor_last_event_id
self
.
repositories_synced_count
=
registries_for_synced_projects
(
:repository
).
coun
t
self
.
cursor_last_event_date
=
Geo
::
EventLog
.
find_by
(
id:
self
.
cursor_last_event_id
)
&
.
created_a
t
self
.
repositories_failed_count
=
registries_for_fail
ed_projects
(
:repository
).
count
self
.
repositories_synced_count
=
registries_for_sync
ed_projects
(
:repository
).
count
self
.
wikis_synced_count
=
registries_for_synced_projects
(
:wiki
).
count
self
.
repositories_failed_count
=
registries_for_failed_projects
(
:repository
).
count
self
.
wikis_failed_count
=
registries_for_fail
ed_projects
(
:wiki
).
count
self
.
wikis_synced_count
=
registries_for_sync
ed_projects
(
:wiki
).
count
self
.
lfs_objects_count
=
lfs_objects_finder
.
count_syncable
self
.
wikis_failed_count
=
registries_for_failed_projects
(
:wiki
).
count
self
.
lfs_objects_synced_count
=
lfs_objects_finder
.
count_synced
self
.
lfs_objects_count
=
lfs_objects_finder
.
count_syncable
self
.
lfs_objects_failed_count
=
lfs_objects_finder
.
count_fail
ed
self
.
lfs_objects_synced_count
=
lfs_objects_finder
.
count_sync
ed
self
.
lfs_objects_registry_count
=
lfs_objects_finder
.
count_registry
self
.
lfs_objects_failed_count
=
lfs_objects_finder
.
count_failed
self
.
lfs_objects_synced_missing_on_primary_count
=
lfs_objects_finder
.
count_synced_missing_on_prima
ry
self
.
lfs_objects_registry_count
=
lfs_objects_finder
.
count_regist
ry
self
.
job_artifacts_count
=
job_artifacts_finder
.
count_syncable
self
.
lfs_objects_synced_missing_on_primary_count
=
lfs_objects_finder
.
count_synced_missing_on_primary
self
.
job_artifacts_synced_count
=
job_artifacts_finder
.
count_synced
self
.
job_artifacts_count
=
job_artifacts_finder
.
count_syncable
self
.
job_artifacts_failed_count
=
job_artifacts_finder
.
count_fail
ed
self
.
job_artifacts_synced_count
=
job_artifacts_finder
.
count_sync
ed
self
.
job_artifacts_registry_count
=
job_artifacts_finder
.
count_registry
self
.
job_artifacts_failed_count
=
job_artifacts_finder
.
count_failed
self
.
job_artifacts_synced_missing_on_primary_count
=
job_artifacts_finder
.
count_synced_missing_on_prima
ry
self
.
job_artifacts_registry_count
=
job_artifacts_finder
.
count_regist
ry
self
.
attachments_count
=
attachments_finder
.
count_syncable
self
.
job_artifacts_synced_missing_on_primary_count
=
job_artifacts_finder
.
count_synced_missing_on_primary
self
.
attachments_synced_count
=
attachments_finder
.
count_synced
self
.
attachments_count
=
attachments_finder
.
count_syncable
self
.
attachments_failed_count
=
attachments_finder
.
count_fail
ed
self
.
attachments_synced_count
=
attachments_finder
.
count_sync
ed
self
.
attachments_registry_count
=
attachments_finder
.
count_registry
self
.
attachments_failed_count
=
attachments_finder
.
count_failed
self
.
attachments_synced_missing_on_primary_count
=
attachments_finder
.
count_synced_missing_on_prima
ry
self
.
attachments_registry_count
=
attachments_finder
.
count_regist
ry
self
.
attachments_synced_missing_on_primary_count
=
attachments_finder
.
count_synced_missing_on_primary
load_verification_data
load_verification_data
self
.
repositories_checked_count
=
Geo
::
ProjectRegistry
.
where
.
not
(
last_repository_check_at:
nil
).
count
self
.
repositories_checked_failed_count
=
Geo
::
ProjectRegistry
.
where
(
last_repository_check_failed:
true
).
count
self
.
repositories_checked_count
=
Geo
::
ProjectRegistry
.
where
.
not
(
last_repository_check_at:
nil
).
count
end
self
.
repositories_checked_failed_count
=
Geo
::
ProjectRegistry
.
where
(
last_repository_check_failed:
true
).
count
end
end
def
load_verification_data
def
load_verification_data
if
repository_verification_enabled
return
unless
repository_verification_enabled
self
.
repositories_verified_count
=
registries_for_verified_projects
(
:repository
).
count
self
.
repositories_verification_failed_count
=
registries_for_verification_fail
ed_projects
(
:repository
).
count
self
.
repositories_verified_count
=
registries_for_verifi
ed_projects
(
:repository
).
count
self
.
repositories_checksum_mismatch_count
=
registries_for_mismatch
_projects
(
:repository
).
count
self
.
repositories_verification_failed_count
=
registries_for_verification_failed
_projects
(
:repository
).
count
self
.
wikis_verified_count
=
registries_for_verified_projects
(
:wiki
).
count
self
.
repositories_checksum_mismatch_count
=
registries_for_mismatch_projects
(
:repository
).
count
self
.
wikis_verification_failed_count
=
registries_for_verification_fail
ed_projects
(
:wiki
).
count
self
.
wikis_verified_count
=
registries_for_verifi
ed_projects
(
:wiki
).
count
self
.
wikis_checksum_mismatch_count
=
registries_for_mismatch
_projects
(
:wiki
).
count
self
.
wikis_verification_failed_count
=
registries_for_verification_failed
_projects
(
:wiki
).
count
self
.
repositories_retrying_verification_count
=
registries_retrying_verification
(
:repository
).
count
self
.
wikis_checksum_mismatch_count
=
registries_for_mismatch_projects
(
:wiki
).
count
self
.
wikis_retrying_verification_count
=
registries_retrying_verification
(
:wiki
).
count
self
.
repositories_retrying_verification_count
=
registries_retrying_verification
(
:repository
).
count
end
self
.
wikis_retrying_verification_count
=
registries_retrying_verification
(
:wiki
).
count
end
end
def
current_cursor_last_event_id
def
current_cursor_last_event_id
...
...
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