Project imports unconditionally enqueue an `ElasticCommitIndexerWorker`
Summary
Spotted while working on gitlab-com/gl-infra/production#800 (closed)
Steps to reproduce
Set up an elasticsearch-enabled GitLab instance with the following settings:
elasticsearch_indexing: true
elasticsearch_limit_indexing: true
ElasticsearchIndexed{Namespace,{Project}.count => 0
What is the current bug behavior?
Every time a project is imported, an ElasticCommitIndexerWorker
is unconditionally enqueued
What is the expected correct behavior?
Since we should be indexing zero projects with this setup, zero ElasticCommitIndexerWorker
jobs should be enqueued.
Output of checks
This bug happens on GitLab.com
Possible fixes
The issue is here: https://gitlab.com/gitlab-org/gitlab-ee/blob/master/ee/app/models/ee/project_import_state.rb#L68
We need to check project.use_elasticsearch?
before enqueuing the job.
Since we check it inside ElasticCommitIndexerWorker#perform
, this bug is almost free - it just creates a constant level of no-op sidekiq jobs that must be discarded. We're not blocked on it for GitLab.com, but we'll benefit, resource and clarity-wise, from fixing this quickly. cc @phikai