diff --git a/GITLAB_ELASTICSEARCH_INDEXER_VERSION b/GITLAB_ELASTICSEARCH_INDEXER_VERSION index 7e7f33c2e387472f8ead1e579e675455d6b52b6d..3bcca128b9841ef162b16afff27d6d5327eaa5c5 100644 --- a/GITLAB_ELASTICSEARCH_INDEXER_VERSION +++ b/GITLAB_ELASTICSEARCH_INDEXER_VERSION @@ -1 +1 @@ -4.3.7 +4.3.8 diff --git a/ee/app/models/concerns/elastic/projects_search.rb b/ee/app/models/concerns/elastic/projects_search.rb index fb0dd0763fb7bdccfff1c76d2b3d31cc467d7dc1..2c238c0bd69a3b30ec627b19b72cabf012ce6e8a 100644 --- a/ee/app/models/concerns/elastic/projects_search.rb +++ b/ee/app/models/concerns/elastic/projects_search.rb @@ -28,8 +28,8 @@ def maintain_elasticsearch_update(updated_attributes: previous_changes.keys) # So we have to check the previous_changes on project_feature updated_attributes.concat(project_feature.previous_changes.keys.map(&:to_sym)) - if (updated_attributes & %i[visibility_level repository_access_level wiki_access_level]).any? - maintain_elasticsearch_permissions + if (updated_attributes & %i[visibility_level repository_access_level wiki_access_level archived]).any? + maintain_elasticsearch_values end super @@ -46,7 +46,7 @@ def invalidate_elasticsearch_indexes_cache! private - def maintain_elasticsearch_permissions + def maintain_elasticsearch_values ::Elastic::ProcessInitialBookkeepingService.backfill_projects!(self) end end diff --git a/ee/lib/gitlab/elastic/indexer.rb b/ee/lib/gitlab/elastic/indexer.rb index de502c827ae9477a32a033092c80cc66027326b9..b55d688fb69af78d6f628a04c9921e904dca10dd 100644 --- a/ee/lib/gitlab/elastic/indexer.rb +++ b/ee/lib/gitlab/elastic/indexer.rb @@ -189,6 +189,11 @@ def build_command(base_sha, to_sha) "--traversal-ids=#{group.elastic_namespace_ancestry}" end + if ::Elastic::DataMigrationService.migration_has_finished?(:add_archived_to_commits) && + ::Elastic::DataMigrationService.migration_has_finished?(:add_archived_to_main_index) && !index_wiki? + command << "--archived=#{project.archived}" + end + command << repository_path end diff --git a/ee/spec/lib/gitlab/elastic/indexer_spec.rb b/ee/spec/lib/gitlab/elastic/indexer_spec.rb index 0c3e3090ee7e1fb703727a58b0674ba42c8ca646..5992fd4aa30efb9bd930bf520779f253c1751bfe 100644 --- a/ee/spec/lib/gitlab/elastic/indexer_spec.rb +++ b/ee/spec/lib/gitlab/elastic/indexer_spec.rb @@ -182,6 +182,47 @@ "--hashed-root-namespace-id=#{project.namespace.hashed_root_namespace_id}", "--schema-version-commits=true", "--traversal-ids=#{project.namespace_ancestry}", + "--archived=#{project.archived}", + "#{project.repository.disk_path}.git" + ], + nil, + hash_including( + 'GITALY_CONNECTION_INFO' => gitaly_connection_data.to_json, + 'ELASTIC_CONNECTION_INFO' => elasticsearch_config.to_json, + 'RAILS_ENV' => Rails.env, + 'CORRELATION_ID' => Labkit::Correlation::CorrelationId.current_id + ) + ).and_return(popen_success) + + indexer.run + end + end + + context 'when add_archived_to_commits migration is not complete' do + before do + set_elasticsearch_migration_to(:add_archived_to_commits, including: false) + end + + it 'runs the indexer without --archived flag' do + gitaly_connection_data = { + storage: project.repository_storage, + limit_file_size: Gitlab::CurrentSettings.elasticsearch_indexed_file_size_limit_kb.kilobytes + }.merge(Gitlab::GitalyClient.connection_data(project.repository_storage)) + + expect_popen.with( + [ + TestEnv.indexer_bin_path, + "--timeout=#{described_class.timeout}s", + "--visibility-level=#{project.visibility_level}", + "--project-id=#{project.id}", + '--search-curation', + "--from-sha=#{expected_from_sha}", + "--to-sha=#{to_sha}", + "--full-path=#{project.full_path}", + "--repository-access-level=#{project.repository_access_level}", + "--hashed-root-namespace-id=#{project.namespace.hashed_root_namespace_id}", + "--schema-version-commits=true", + "--traversal-ids=#{project.namespace_ancestry}", "#{project.repository.disk_path}.git" ], nil, @@ -294,6 +335,7 @@ "--hashed-root-namespace-id=#{project.namespace.hashed_root_namespace_id}", "--schema-version-commits=true", "--traversal-ids=#{project.namespace_ancestry}", + "--archived=#{project.archived}", "#{project.repository.disk_path}.git" ], nil,