Commit d93e84cf authored by Mike Kozono's avatar Mike Kozono

Fix incorrect Package File progress bar total count

...when registry count does not equal the total package file count on
the primary. For example, when selective sync is enabled.
parent b4edc9c0
...@@ -367,8 +367,9 @@ Example response: ...@@ -367,8 +367,9 @@ Example response:
"package_files_count": 10, "package_files_count": 10,
"package_files_checksummed_count": 10, "package_files_checksummed_count": 10,
"package_files_checksum_failed_count": 0, "package_files_checksum_failed_count": 0,
"package_files_synced_count": 10, "package_files_registry_count": 10,
"package_files_failed_count": 5 "package_files_synced_count": 6,
"package_files_failed_count": 3
}, },
{ {
"geo_node_id": 2, "geo_node_id": 2,
...@@ -440,8 +441,9 @@ Example response: ...@@ -440,8 +441,9 @@ Example response:
"package_files_count": 10, "package_files_count": 10,
"package_files_checksummed_count": 10, "package_files_checksummed_count": 10,
"package_files_checksum_failed_count": 0, "package_files_checksum_failed_count": 0,
"package_files_synced_count": 10, "package_files_registry_count": 10,
"package_files_failed_count": 5 "package_files_synced_count": 6,
"package_files_failed_count": 3
} }
] ]
``` ```
......
...@@ -138,7 +138,7 @@ export default class GeoNodesStore { ...@@ -138,7 +138,7 @@ export default class GeoNodesStore {
failureCount: rawNodeDetails.design_repositories_failed_count || 0, failureCount: rawNodeDetails.design_repositories_failed_count || 0,
}, },
packageFiles: { packageFiles: {
totalCount: rawNodeDetails.package_files_count || 0, totalCount: rawNodeDetails.package_files_registry_count || 0,
successCount: rawNodeDetails.package_files_synced_count || 0, successCount: rawNodeDetails.package_files_synced_count || 0,
failureCount: rawNodeDetails.package_files_failed_count || 0, failureCount: rawNodeDetails.package_files_failed_count || 0,
}, },
......
...@@ -80,6 +80,7 @@ class GeoNodeStatus < ApplicationRecord ...@@ -80,6 +80,7 @@ class GeoNodeStatus < ApplicationRecord
package_files_checksum_failed_count package_files_checksum_failed_count
package_files_synced_count package_files_synced_count
package_files_failed_count package_files_failed_count
package_files_registry_count
).freeze ).freeze
# Be sure to keep this consistent with Prometheus naming conventions # Be sure to keep this consistent with Prometheus naming conventions
...@@ -156,8 +157,9 @@ class GeoNodeStatus < ApplicationRecord ...@@ -156,8 +157,9 @@ class GeoNodeStatus < ApplicationRecord
package_files_count: 'Number of package files on primary', package_files_count: 'Number of package files on primary',
package_files_checksummed_count: 'Number of package files checksummed on primary', package_files_checksummed_count: 'Number of package files checksummed on primary',
package_files_checksum_failed_count: 'Number of package files failed to checksum on primary', package_files_checksum_failed_count: 'Number of package files failed to checksum on primary',
package_files_synced_count: 'Number of syncable package files synced on secondary', package_files_registry_count: 'Number of package files in the registry',
package_files_failed_count: 'Number of syncable package files failed to sync on secondary' package_files_synced_count: 'Number of package files synced on secondary',
package_files_failed_count: 'Number of package files failed to sync on secondary'
}.freeze }.freeze
EXPIRATION_IN_MINUTES = 10 EXPIRATION_IN_MINUTES = 10
...@@ -374,7 +376,7 @@ class GeoNodeStatus < ApplicationRecord ...@@ -374,7 +376,7 @@ class GeoNodeStatus < ApplicationRecord
attr_in_percentage :container_repositories_synced, :container_repositories_synced_count, :container_repositories_count attr_in_percentage :container_repositories_synced, :container_repositories_synced_count, :container_repositories_count
attr_in_percentage :design_repositories_synced, :design_repositories_synced_count, :design_repositories_count attr_in_percentage :design_repositories_synced, :design_repositories_synced_count, :design_repositories_count
attr_in_percentage :package_files_checksummed, :package_files_checksummed_count, :package_files_count attr_in_percentage :package_files_checksummed, :package_files_checksummed_count, :package_files_count
attr_in_percentage :package_files_synced, :package_files_synced_count, :package_files_count attr_in_percentage :package_files_synced, :package_files_synced_count, :package_files_registry_count
def storage_shards_match? def storage_shards_match?
return true if geo_node.primary? return true if geo_node.primary?
...@@ -439,6 +441,7 @@ class GeoNodeStatus < ApplicationRecord ...@@ -439,6 +441,7 @@ class GeoNodeStatus < ApplicationRecord
load_attachments_data load_attachments_data
load_container_registry_data load_container_registry_data
load_designs_data load_designs_data
load_package_files_data
end end
def load_lfs_objects_data def load_lfs_objects_data
...@@ -489,6 +492,14 @@ class GeoNodeStatus < ApplicationRecord ...@@ -489,6 +492,14 @@ class GeoNodeStatus < ApplicationRecord
self.design_repositories_registry_count = design_registry_finder.count_registry self.design_repositories_registry_count = design_registry_finder.count_registry
end end
def load_package_files_data
# return unless package_files_replication_enabled # TODO: https://gitlab.com/gitlab-org/gitlab/-/issues/221069
self.package_files_registry_count = Geo::PackageFileReplicator.registry_count
self.package_files_synced_count = Geo::PackageFileReplicator.synced_count
self.package_files_failed_count = Geo::PackageFileReplicator.failed_count
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
...@@ -518,8 +529,6 @@ class GeoNodeStatus < ApplicationRecord ...@@ -518,8 +529,6 @@ class GeoNodeStatus < ApplicationRecord
self.wikis_checksum_mismatch_count = registries_for_mismatch_projects(:wiki).count self.wikis_checksum_mismatch_count = registries_for_mismatch_projects(:wiki).count
self.repositories_retrying_verification_count = registries_retrying_verification(:repository).count self.repositories_retrying_verification_count = registries_retrying_verification(:repository).count
self.wikis_retrying_verification_count = registries_retrying_verification(:wiki).count self.wikis_retrying_verification_count = registries_retrying_verification(:wiki).count
self.package_files_synced_count = Geo::PackageFileReplicator.synced_count
self.package_files_failed_count = Geo::PackageFileReplicator.failed_count
end end
end end
......
---
title: 'Geo: Fix incorrect Package File progress bar total count'
merge_request: 35294
author:
type: fixed
...@@ -125,6 +125,10 @@ module Gitlab ...@@ -125,6 +125,10 @@ module Gitlab
model.count model.count
end end
def self.registry_count
registry_class.count
end
def self.synced_count def self.synced_count
registry_class.synced.count registry_class.synced.count
end end
......
...@@ -37,8 +37,9 @@ FactoryBot.define do ...@@ -37,8 +37,9 @@ FactoryBot.define do
wikis_checksum_failed_count { 55 } wikis_checksum_failed_count { 55 }
package_files_count { 585 } package_files_count { 585 }
package_files_checksummed_count { 585 } package_files_checksummed_count { 585 }
package_files_registry_count { 585 }
package_files_failed_count { 3 } package_files_failed_count { 3 }
package_files_synced_count { 585 } package_files_synced_count { 580 }
package_files_checksum_failed_count { 585 } package_files_checksum_failed_count { 585 }
repositories_verified_count { 501 } repositories_verified_count { 501 }
repositories_verification_failed_count { 100 } repositories_verification_failed_count { 100 }
......
...@@ -129,6 +129,7 @@ ...@@ -129,6 +129,7 @@
"package_files_count": { "type": ["integer", "null"] }, "package_files_count": { "type": ["integer", "null"] },
"package_files_checksummed_count": { "type": ["integer", "null"] }, "package_files_checksummed_count": { "type": ["integer", "null"] },
"package_files_checksum_failed_count": { "type": ["integer", "null"] }, "package_files_checksum_failed_count": { "type": ["integer", "null"] },
"package_files_registry_count": { "type": ["integer", "null"] },
"package_files_failed_count": { "type": ["integer", "null"] }, "package_files_failed_count": { "type": ["integer", "null"] },
"package_files_synced_count": { "type": ["integer", "null"] }, "package_files_synced_count": { "type": ["integer", "null"] },
"package_files_synced_in_percentage": { "type": "string" }, "package_files_synced_in_percentage": { "type": "string" },
......
...@@ -93,7 +93,7 @@ export const rawMockNodeDetails = { ...@@ -93,7 +93,7 @@ export const rawMockNodeDetails = {
design_repositories_synced_count: 0, design_repositories_synced_count: 0,
design_repositories_failed_count: 0, design_repositories_failed_count: 0,
design_repositories_synced_in_percentage: '0.00%', design_repositories_synced_in_percentage: '0.00%',
package_files_count: 25, package_files_registry_count: 25,
package_files_synced_count: 25, package_files_synced_count: 25,
package_files_failed_count: 0, package_files_failed_count: 0,
package_files_synced_in_percentage: '100.00%', package_files_synced_in_percentage: '100.00%',
......
...@@ -1234,6 +1234,10 @@ RSpec.describe GeoNodeStatus, :geo, :geo_fdw do ...@@ -1234,6 +1234,10 @@ RSpec.describe GeoNodeStatus, :geo, :geo_fdw do
create(:geo_package_file_registry, :synced) create(:geo_package_file_registry, :synced)
end end
it 'returns the right number of repos in registry' do
expect(subject.package_files_registry_count).to eq(3)
end
it 'returns the right number of failed and synced repos' do it 'returns the right number of failed and synced repos' do
expect(subject.package_files_failed_count).to eq(2) expect(subject.package_files_failed_count).to eq(2)
expect(subject.package_files_synced_count).to eq(1) expect(subject.package_files_synced_count).to eq(1)
...@@ -1246,6 +1250,7 @@ RSpec.describe GeoNodeStatus, :geo, :geo_fdw do ...@@ -1246,6 +1250,7 @@ RSpec.describe GeoNodeStatus, :geo, :geo_fdw do
context 'when no package registries available' do context 'when no package registries available' do
it 'returns 0' do it 'returns 0' do
expect(subject.package_files_registry_count).to eq(0)
expect(subject.package_files_failed_count).to eq(0) expect(subject.package_files_failed_count).to eq(0)
expect(subject.package_files_synced_count).to eq(0) expect(subject.package_files_synced_count).to eq(0)
end end
......
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