Commit c0af6dce authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch '5341-geo-hide-checksum-ui-elements-unless-feature-is-enabled' into 'master'

Geo: Hide checksum UI elements unless feature is enabled

Closes #5341

See merge request gitlab-org/gitlab-ee!5035
parents bbede12a 73976d26
......@@ -204,6 +204,7 @@
<template v-if="showAdvanceItems">
<template v-if="node.primary">
<geo-node-detail-item
v-if="nodeDetails.repositoryVerificationEnabled"
:item-title="s__('GeoNodes|Repositories checksummed:')"
:success-label="s__('GeoNodes|Checksummed')"
:neutral-label="s__('GeoNodes|Not checksummed')"
......@@ -212,6 +213,7 @@
:item-value-type="valueType.GRAPH"
/>
<geo-node-detail-item
v-if="nodeDetails.repositoryVerificationEnabled"
:item-title="s__('GeoNodes|Wikis checksummed:')"
:success-label="s__('GeoNodes|Checksummed')"
:neutral-label="s__('GeoNodes|Not checksummed')"
......@@ -236,6 +238,7 @@
</template>
<template v-else>
<geo-node-detail-item
v-if="nodeDetails.repositoryVerificationEnabled"
:item-title="s__('GeoNodes|Repository checksums verified:')"
:success-label="s__('GeoNodes|Verified')"
:neutral-label="s__('GeoNodes|Unverified')"
......@@ -244,6 +247,7 @@
:item-value-type="valueType.GRAPH"
/>
<geo-node-detail-item
v-if="nodeDetails.repositoryVerificationEnabled"
:item-title="s__('GeoNodes|Wiki checksums verified:')"
:success-label="s__('GeoNodes|Verified')"
:neutral-label="s__('GeoNodes|Unverified')"
......
......@@ -87,6 +87,7 @@ export default class GeoNodesStore {
successCount: rawNodeDetails.wikis_synced_count || 0,
failureCount: rawNodeDetails.wikis_failed_count || 0,
},
repositoryVerificationEnabled: rawNodeDetails.repository_verification_enabled,
verifiedRepositories: {
totalCount: rawNodeDetails.repositories_count || 0,
successCount: rawNodeDetails.repositories_verified_count || 0,
......
......@@ -3,11 +3,15 @@ class GeoNodeStatus < ActiveRecord::Base
delegate :selective_sync_type, to: :geo_node
after_initialize :initialize_feature_flags
# Whether we were successful in reaching this node
attr_accessor :success
attr_writer :health_status
attr_writer :health_status
attr_accessor :storage_shards
attr_accessor :repository_verification_enabled
# Prometheus metrics, no need to store them in the database
attr_accessor :event_log_count, :event_log_max_id,
:repository_created_max_id, :repository_updated_max_id,
......@@ -98,6 +102,10 @@ class GeoNodeStatus < ActiveRecord::Base
self.column_names - EXCLUDED_PARAMS + EXTRA_PARAMS
end
def initialize_feature_flags
self.repository_verification_enabled = Feature.enabled?('geo_repository_verification')
end
def load_data_from_current_node
self.status_message =
begin
......@@ -135,6 +143,7 @@ class GeoNodeStatus < ActiveRecord::Base
load_primary_data
load_secondary_data
load_verification_data
self
end
......@@ -144,10 +153,6 @@ class GeoNodeStatus < ActiveRecord::Base
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
self.repositories_verified_count = repository_verification_finder.count_verified_repositories
self.repositories_verification_failed_count = repository_verification_finder.count_verification_failed_repositories
self.wikis_verified_count = repository_verification_finder.count_verified_wikis
self.wikis_verification_failed_count = repository_verification_finder.count_verification_failed_wikis
end
end
......@@ -160,10 +165,6 @@ class GeoNodeStatus < ActiveRecord::Base
self.repositories_failed_count = projects_finder.count_failed_repositories
self.wikis_synced_count = projects_finder.count_synced_wikis
self.wikis_failed_count = projects_finder.count_failed_wikis
self.repositories_verified_count = projects_finder.count_verified_repositories
self.repositories_verification_failed_count = projects_finder.count_verification_failed_repositories
self.wikis_verified_count = projects_finder.count_verified_wikis
self.wikis_verification_failed_count = projects_finder.count_verification_failed_wikis
self.lfs_objects_synced_count = lfs_objects_finder.count_synced_lfs_objects
self.lfs_objects_failed_count = lfs_objects_finder.count_failed_lfs_objects
self.lfs_objects_registry_count = lfs_objects_finder.count_registry_lfs_objects
......@@ -176,6 +177,16 @@ class GeoNodeStatus < ActiveRecord::Base
end
end
def load_verification_data
return unless repository_verification_enabled
finder = Gitlab::Geo.primary? ? repository_verification_finder : projects_finder
self.repositories_verified_count = finder.count_verified_repositories
self.repositories_verification_failed_count = finder.count_verification_failed_repositories
self.wikis_verified_count = finder.count_verified_wikis
self.wikis_verification_failed_count = finder.count_verification_failed_wikis
end
alias_attribute :health, :status_message
def healthy?
......
---
title: Show repository checksum UI elements only when feature is enabled
merge_request: 5341
author:
type: fixed
......@@ -293,6 +293,8 @@ module EE
number_to_percentage(node.wikis_synced_in_percentage, precision: 2)
end
expose :repository_verification_enabled
expose :repositories_verification_failed_count
expose :repositories_verified_count
expose :repositories_verified_in_percentage do |node|
......
......@@ -20,6 +20,10 @@ FactoryBot.define do
wikis_count 9
wikis_synced_count 4
wikis_failed_count 1
repositories_verified_count 501
repositories_verification_failed_count 100
wikis_verified_count 499
wikis_verification_failed_count 99
last_event_id 2
last_event_timestamp { Time.now.to_i }
cursor_last_event_id 1
......
......@@ -9,12 +9,12 @@ FactoryBot.define do
trait :repository_outdated do
repository_verification_checksum nil
last_repository_verification_failure false
last_repository_verification_failure nil
end
trait :repository_verified do
repository_verification_checksum 'f079a831cab27bcda7d81cd9b48296d0c3dd92ee'
last_repository_verification_failure false
last_repository_verification_failure nil
end
trait :wiki_failed do
......
......@@ -22,6 +22,7 @@
"wikis_count",
"wikis_failed_count",
"wikis_synced_count",
"repository_verification_enabled",
"repositories_verified_count",
"repositories_verification_failed_count",
"repositories_verified_in_percentage",
......@@ -70,6 +71,7 @@
"wikis_failed_count": { "type": ["integer", "null"] },
"wikis_synced_count": { "type": ["integer", "null"] },
"wikis_synced_in_percentage": { "type": "string" },
"repository_verification_enabled": { "type": "boolean" },
"repositories_verified_count": { "type": ["integer", "null"] },
"repositories_verification_failed_count": { "type": ["integer", "null"] },
"repositories_verified_in_percentage": { "type": "string" },
......
......@@ -388,6 +388,182 @@ describe GeoNodeStatus, :geo do
end
end
describe '#repositories_verified_count' do
context 'on the primary' do
before do
stub_current_geo_node(primary)
end
it 'returns the right number of verified repositories' do
stub_feature_flags(geo_repository_verification: true)
create(:repository_state, :repository_verified)
create(:repository_state, :repository_verified)
expect(subject.repositories_verified_count).to eq(2)
end
it 'returns existing value when feature flag if off' do
stub_feature_flags(geo_repository_verification: false)
create(:geo_node_status, :healthy, geo_node: primary)
expect(subject.repositories_verified_count).to eq(501)
end
end
context 'on the secondary' do
before do
stub_current_geo_node(secondary)
end
it 'returns the right number of verified repositories' do
stub_feature_flags(geo_repository_verification: true)
create(:geo_project_registry, :repository_verified)
create(:geo_project_registry, :repository_verified)
expect(subject.repositories_verified_count).to eq(2)
end
it 'returns existing value when feature flag if off' do
stub_feature_flags(geo_repository_verification: false)
create(:geo_node_status, :healthy, geo_node: secondary)
expect(subject.repositories_verified_count).to eq(501)
end
end
end
describe '#repositories_verification_failed_count' do
context 'on the primary' do
before do
stub_current_geo_node(primary)
end
it 'returns the right number of failed repositories' do
stub_feature_flags(geo_repository_verification: true)
create(:repository_state, :repository_failed)
create(:repository_state, :repository_failed)
expect(subject.repositories_verification_failed_count).to eq(2)
end
it 'returns existing value when feature flag if off' do
stub_feature_flags(geo_repository_verification: false)
create(:geo_node_status, :healthy, geo_node: primary)
expect(subject.repositories_verification_failed_count).to eq(100)
end
end
context 'on the secondary' do
before do
stub_current_geo_node(secondary)
end
it 'returns the right number of failed repositories' do
stub_feature_flags(geo_repository_verification: true)
create(:geo_project_registry, :repository_verification_failed)
create(:geo_project_registry, :repository_verification_failed)
expect(subject.repositories_verification_failed_count).to eq(2)
end
it 'returns existing value when feature flag if off' do
stub_feature_flags(geo_repository_verification: false)
create(:geo_node_status, :healthy, geo_node: secondary)
expect(subject.repositories_verification_failed_count).to eq(100)
end
end
end
describe '#wikis_verified_count' do
context 'on the primary' do
before do
stub_current_geo_node(primary)
end
it 'returns the right number of verified wikis' do
stub_feature_flags(geo_repository_verification: true)
create(:repository_state, :wiki_verified)
create(:repository_state, :wiki_verified)
expect(subject.wikis_verified_count).to eq(2)
end
it 'returns existing value when feature flag if off' do
stub_feature_flags(geo_repository_verification: false)
create(:geo_node_status, :healthy, geo_node: primary)
expect(subject.wikis_verified_count).to eq(499)
end
end
context 'on the secondary' do
before do
stub_current_geo_node(secondary)
end
it 'returns the right number of verified wikis' do
stub_feature_flags(geo_repository_verification: true)
create(:geo_project_registry, :wiki_verified)
create(:geo_project_registry, :wiki_verified)
expect(subject.wikis_verified_count).to eq(2)
end
it 'returns existing value when feature flag if off' do
stub_feature_flags(geo_repository_verification: false)
create(:geo_node_status, :healthy, geo_node: secondary)
expect(subject.wikis_verified_count).to eq(499)
end
end
end
describe '#wikis_verification_failed_count' do
context 'on the primary' do
before do
stub_current_geo_node(primary)
end
it 'returns the right number of failed wikis' do
stub_feature_flags(geo_repository_verification: true)
create(:repository_state, :wiki_failed)
create(:repository_state, :wiki_failed)
expect(subject.wikis_verification_failed_count).to eq(2)
end
it 'returns existing value when feature flag if off' do
stub_feature_flags(geo_repository_verification: false)
create(:geo_node_status, :healthy, geo_node: primary)
expect(subject.wikis_verification_failed_count).to eq(99)
end
end
context 'on the secondary' do
before do
stub_current_geo_node(secondary)
end
it 'returns the right number of failed wikis' do
stub_feature_flags(geo_repository_verification: true)
create(:geo_project_registry, :wiki_verification_failed)
create(:geo_project_registry, :wiki_verification_failed)
expect(subject.wikis_verification_failed_count).to eq(2)
end
it 'returns existing value when feature flag if off' do
stub_feature_flags(geo_repository_verification: false)
create(:geo_node_status, :healthy, geo_node: secondary)
expect(subject.wikis_verification_failed_count).to eq(99)
end
end
end
describe '#last_event_id and #last_event_date' do
it 'returns nil when no events are available' do
expect(subject.last_event_id).to be_nil
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment