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
5632f414
Commit
5632f414
authored
Jan 26, 2021
by
Douglas Barbosa Alexandre
Committed by
Michael Kozono
Jan 26, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Geo replication status for replicables with no data to sync
parent
c2222dd5
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
71 additions
and
25 deletions
+71
-25
ee/app/models/geo_node_status.rb
ee/app/models/geo_node_status.rb
+4
-0
ee/changelogs/unreleased/298725-gitlab-ctl-promotion-preflight-checks-incorrectly-fails-with-0.yml
...l-promotion-preflight-checks-incorrectly-fails-with-0.yml
+6
-0
ee/lib/gitlab/geo/geo_node_status_check.rb
ee/lib/gitlab/geo/geo_node_status_check.rb
+41
-22
ee/spec/lib/gitlab/geo/geo_node_status_check_spec.rb
ee/spec/lib/gitlab/geo/geo_node_status_check_spec.rb
+20
-3
No files found.
ee/app/models/geo_node_status.rb
View file @
5632f414
...
...
@@ -404,6 +404,10 @@ class GeoNodeStatus < ApplicationRecord
public_send
(
"
#{
replicator_class
.
replicable_name_plural
}
_checksummed_in_percentage"
)
# rubocop:disable GitlabSecurity/PublicSend
end
def
count_for
(
replicator_class
)
public_send
(
"
#{
replicator_class
.
replicable_name_plural
}
_count"
)
# rubocop:disable GitlabSecurity/PublicSend
end
def
storage_shards_match?
return
true
if
geo_node
.
primary?
return
false
unless
storage_configuration_digest
&&
primary_storage_digest
...
...
ee/changelogs/unreleased/298725-gitlab-ctl-promotion-preflight-checks-incorrectly-fails-with-0.yml
0 → 100644
View file @
5632f414
---
title
:
Fix Geo replication and verification status for replicables with no data to
sync
merge_request
:
52253
author
:
type
:
fixed
ee/lib/gitlab/geo/geo_node_status_check.rb
View file @
5632f414
...
...
@@ -61,45 +61,64 @@ module Gitlab
end
def
replication_verification_complete?
success_status
=
[
current_node_status
.
repositories_synced_in_percentage
,
current_node_status
.
repositories_checksummed_in_percentage
,
current_node_status
.
wikis_synced_in_percentage
,
current_node_status
.
wikis_checksummed_in_percentage
,
current_node_status
.
lfs_objects_synced_in_percentage
,
current_node_status
.
job_artifacts_synced_in_percentage
,
current_node_status
.
attachments_synced_in_percentage
,
current_node_status
.
replication_slots_used_in_percentage
,
current_node_status
.
design_repositories_synced_in_percentage
]
+
conditional_checks_status
checks_status
=
legacy_replication_and_verification_checks_status
+
replication_and_verification_checks_status
+
conditional_replication_and_verification_checks_status
success_status
.
all?
{
|
percentage
|
percentage
==
100
}
checks_status
.
compact
.
all?
{
|
percentage
|
percentage
==
100
}
end
private
def
conditional_checks_status
# rubocop:disable GitlabSecurity/PublicSend
def
legacy_replication_and_verification_checks_status
replicables
=
[
[
"repositories"
,
Gitlab
::
Geo
.
repository_verification_enabled?
],
[
"wikis"
,
Gitlab
::
Geo
.
repository_verification_enabled?
],
[
"lfs_objects"
,
false
],
[
"job_artifacts"
,
false
],
[
"attachments"
,
false
],
[
"design_repositories"
,
false
]
]
[].
tap
do
|
status
|
replicables
.
each
do
|
replicable_name
,
verification_enabled
|
next
unless
current_node_status
.
public_send
(
"
#{
replicable_name
}
_count"
).
to_i
>
0
status
.
push
current_node_status
.
public_send
(
"
#{
replicable_name
}
_synced_in_percentage"
)
if
verification_enabled
status
.
push
current_node_status
.
public_send
(
"
#{
replicable_name
}
_verified_in_percentage"
)
end
end
end
end
# rubocop:enable GitlabSecurity/PublicSend
def
replication_and_verification_checks_status
[].
tap
do
|
status
|
Gitlab
::
Geo
.
enabled_replicator_classes
.
each
do
|
replicator_class
|
next
unless
current_node_status
.
count_for
(
replicator_class
).
to_i
>
0
status
.
push
current_node_status
.
synced_in_percentage_for
(
replicator_class
)
if
replicator_class
.
verification_enabled?
status
.
push
current_node_status
.
checksummed_in_percentage_for
(
replicator_class
)
end
end
if
Gitlab
::
Geo
.
repository_verification_enabled?
status
.
push
current_node_status
.
repositories_verified_in_percentage
status
.
push
current_node_status
.
wikis_verified_in_percentage
end
if
::
Geo
::
ContainerRepositoryRegistry
.
replication_enabled?
status
.
push
current_node_status
.
container_repositories_synced_in_percentage
end
if
Gitlab
::
CurrentSettings
.
repository_checks_enabled
def
conditional_replication_and_verification_checks_status
[].
tap
do
|
status
|
if
Gitlab
::
CurrentSettings
.
repository_checks_enabled
&&
current_node_status
.
repositories_count
.
to_i
>
0
status
.
push
current_node_status
.
repositories_checked_in_percentage
end
if
::
Geo
::
ContainerRepositoryRegistry
.
replication_enabled?
&&
current_node_status
.
container_repositories_count
.
to_i
>
0
status
.
push
current_node_status
.
container_repositories_synced_in_percentage
end
end
end
...
...
ee/spec/lib/gitlab/geo/geo_node_status_check_spec.rb
View file @
5632f414
...
...
@@ -3,7 +3,8 @@
require
'spec_helper'
RSpec
.
describe
Gitlab
::
Geo
::
GeoNodeStatusCheck
do
let
(
:current_node
)
{
create
(
:geo_node
)
}
let_it_be
(
:current_node
)
{
create
(
:geo_node
)
}
let
(
:geo_node_status
)
do
build
(
:geo_node_status
,
:replicated_and_verified
,
geo_node:
current_node
)
end
...
...
@@ -34,7 +35,7 @@ RSpec.describe Gitlab::Geo::GeoNodeStatusCheck do
end
end
context
'
R
eplicators'
do
context
'
r
eplicators'
do
let
(
:replicators
)
{
Gitlab
::
Geo
.
enabled_replicator_classes
}
context
'replication'
do
...
...
@@ -77,7 +78,23 @@ RSpec.describe Gitlab::Geo::GeoNodeStatusCheck do
end
context
'when replication is up-to-date'
do
it
'returns true'
do
before
do
allow
(
Gitlab
::
CurrentSettings
).
to
receive
(
:repository_checks_enabled
).
and_return
(
true
)
end
it
'returns true when all replicables have data to sync'
do
expect
(
subject
.
replication_verification_complete?
).
to
be_truthy
end
it
'returns true when some replicables does not have data to sync'
do
geo_node_status
.
update!
(
container_repositories_count:
0
,
lfs_objects_count:
0
,
package_files_count:
0
,
repositories_count:
0
,
wikis_count:
0
)
expect
(
subject
.
replication_verification_complete?
).
to
be_truthy
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