Commit bded707c authored by Valery Sizov's avatar Valery Sizov

Merge remote-tracking branch 'origin/master' into ce_upstream

parents fdf6aaa5 5926adac
......@@ -25,9 +25,31 @@ class IssuableFinder
NONE = '0'.freeze
SCALAR_PARAMS = %i(scope state group_id project_id milestone_title assignee_id search label_name sort assignee_username author_id author_username authorized_only due_date iids non_archived weight my_reaction_emoji).freeze
SCALAR_PARAMS = %i[
assignee_id
assignee_username
author_id
author_username
authorized_only
due_date
group_id
iids
label_name
milestone_title
non_archived
project_id
scope
search
sort
state
].freeze
ARRAY_PARAMS = { label_name: [], iids: [], assignee_username: [] }.freeze
VALID_PARAMS = (SCALAR_PARAMS + [ARRAY_PARAMS]).freeze
EE_SCALAR_PARAMS = %i[
weight
].freeze
VALID_PARAMS = (SCALAR_PARAMS + [ARRAY_PARAMS] + EE_SCALAR_PARAMS).freeze
attr_accessor :current_user, :params
......
......@@ -22,7 +22,7 @@ module Geo
end
def find_project_ids_not_synced
current_node.unsynced_projects
healthy_shards_restriction(current_node.unsynced_projects)
.reorder(last_repository_updated_at: :desc)
.limit(db_retrieve_batch_size)
.pluck(:id)
......@@ -35,5 +35,25 @@ module Geo
.limit(db_retrieve_batch_size)
.pluck(:project_id)
end
def healthy_shards_restriction(relation)
configured = Gitlab.config.repositories.storages.keys
referenced = Project.distinct(:repository_storage).pluck(:repository_storage)
healthy = healthy_shards
known = configured | referenced
return relation if (known - healthy).empty?
relation.where(repository_storage: healthy)
end
def healthy_shards
Gitlab::HealthChecks::FsShardsCheck
.readiness
.select(&:success)
.map { |check| check.labels[:shard] }
.compact
.uniq
end
end
end
......@@ -38,6 +38,8 @@ You will be asked to confirm the number of issues and email address for the expo
## Format
> **Time Estimate** and **Time Spent** columns were [introduced](https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/2627) in GitLab Enterprise Edition Starter 10.0.
Data will be encoded with a comma as the column delimiter, with `"` used to quote fields if needed, and newlines to separate rows. The first row will be the headers, which are listed in the following table along with a description of the values:
......
......@@ -116,5 +116,32 @@ describe Geo::RepositorySyncWorker, :postgresql do
end
end
end
context 'unhealthy shards' do
it 'skips backfill for repositories on unhealthy shards' do
unhealthy = create(:project, group: synced_group, repository_storage: 'broken')
# Make the shard unhealthy
FileUtils.rm_rf(unhealthy.repository_storage_path)
expect(Geo::ProjectSyncWorker).to receive(:perform_async).with(project_in_synced_group.id, anything)
expect(Geo::ProjectSyncWorker).not_to receive(:perform_async).with(unhealthy.id, anything)
Sidekiq::Testing.inline! { subject.perform }
end
it 'skips backfill for projects on missing shards' do
missing = create(:project, group: synced_group)
missing.update_column(:repository_storage, 'unknown')
# hide the 'broken' storage for this spec
stub_storage_settings({})
expect(Geo::ProjectSyncWorker).to receive(:perform_async).with(project_in_synced_group.id, anything)
expect(Geo::ProjectSyncWorker).not_to receive(:perform_async).with(missing.id, anything)
Sidekiq::Testing.inline! { subject.perform }
end
end
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