Skip to content

Backfill missing routes for Bot Users

Manoj M J requested to merge backfill-routes-for-users-migration into master

What does this MR do?

This migration generates routes that are missing for bot users, based on the finding from !35711 (merged)

Query

The generated query to find bot users without routes is:

SELECT namespaces.*
FROM namespaces
INNER JOIN users ON users.id = namespaces.owner_id
WHERE (type IS NULL)
  AND users.user_type IN (2, 6, 1, 3, 7)
  AND (NOT EXISTS
         (SELECT 1
          FROM routes
          WHERE source_type = 'Namespace'
          AND source_id = namespaces.id))

Explain

This takes ~100 ms to run according to database-lab.

We have 3 bot users without routes in .com database.

The whole migration could take ~200 ms for completion on production database.

Logging

Logging has been added for both successful and failing records, it will be recorded like this in log/migrations.log

{"severity":"INFO","time":"2020-07-07T07:56:21.363Z","correlation_id":"2262e69ebffb6917a5d1c728d3f7a3ac","id":6,"path":"migration-bot","name":"GitLab Migration Bot","message":"a new route was created for the namespace"}
{"severity":"INFO","time":"2020-07-07T07:56:23.018Z","correlation_id":"c6d00663d7b62657969d22314d986101","id":8,"path":"visual-review-bot","name":"GitLab Visual Review Bot","message":"route creation failed for the namespace","errors":"Path has already been taken"}

Screenshots

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

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
Edited by Toon Claes

Merge request reports

Loading