Cannot index or search group milestones with elasticsearch enabled

Raised in sentry for GitLab.com: https://sentry.gitlap.com/gitlab/gitlabcom/issues/37072/

Backtrace:

Elasticsearch::Transport::Transport::Errors::BadRequest: [400] {"error":{"root_cause":[{"type":"routing_missing_exception","reason":"routing is required for [gitlab-production]/[milestone]/[X]","index_uuid":"_na_","index":"gitlab-production"}],"type":"routing_missing_exception","reason":"routing is required for [gitlab-production]/[milestone]/[357565]","index_uuid":"_na_","index":"gitlab-production"},"status":400}
  from elasticsearch/transport/transport/base.rb:201:in `__raise_transport_error'
  from elasticsearch/transport/transport/base.rb:318:in `perform_request'
  from elasticsearch/transport/transport/http/faraday.rb:20:in `perform_request'
  from elasticsearch/transport/client.rb:131:in `perform_request'
  from elasticsearch/api/actions/index.rb:100:in `index'
  from elasticsearch/model/indexing.rb:336:in `index_document'
  from app/workers/elastic_indexer_worker.rb:22:in `perform'
  from sidekiq/processor.rb:204:in `execute_job'
...

Line of code: app/workers/elastic_indexer_worker.rb in perform at line 22

          record.__elasticsearch__.client = client

          if klass.nested?
            record.__elasticsearch__.__send__ "#{operation}_document", parent: record.es_parent # here
          else
            record.__elasticsearch__.__send__ "#{operation}_document"
          end

es_parent is defined as project_id... so perhaps we had a milestone where that was nil? Could this be related to group milestones? Does milestones.project_id ever get nullified?

The affected milestone ID is in the sentry issue so this should be easy for someone with production access to check the group milestone case.

/cc @vsizov

Edited May 15, 2019 by Nick Thomas
Assignee Loading
Time tracking Loading