Add Elasticsearch migration to backfill project permissions on MRs
What does this MR do?
As part of our efforts to avoid using joins in Elasticsearch queries &2054 we need to "denormalize" (copy them into child docs) the permission related fields needed for searching.
In order to allow us to search for merge requests without joining to the
project we need to store the merge_requests_access_level
as well as
the visibility_level
of the project on the merge request record. In
!59731 (merged) we started
storing these fields for any newly created or updated Merge Requests.
This MR is to backfill all the existing MRs in the index that don't have this value set. Technically we are backfilling 3 fields but, since all these fields were added in that MR, we can just check for the existence of any of those fields to be sure that a record has them all.
This MR does not yet use these fields as it's only the 2nd step of all the steps described in &5468 (closed)
Once these fields are backfilled we can start using them and get some performance gains. Technically we could add that code in this MR to use these new fields (conditioned upon the migration being finished) but in the past we've found that we often ran into issues that were only with one part of the code that led to us needing to revert and then do the whole process again and code review again and this is less efficient.
This MR is actually pretty much an identical copy of the same thing we
already did for issues a while back in
!47819 (merged) but all I
did was find and replace issues
with merge_requests
since that's the
only difference.
Screenshots (strongly suggested)
Does this MR meet the acceptance criteria?
Conformity
-
📋 Does this MR need a changelog?-
I have included a changelog entry. -
I have not included a changelog entry because _____.
-
- [-] Documentation (if required)
-
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team
Related to #322788 (closed)