Skip to content

Move repository storage to BasicProjectDetails

Steve Xuereb requested to merge feat/repository-storage-base into master

What does this MR do and why?

What

Move the repository_storage_detail from the project entities to the basic project details.

Why

forked_from_project returns BasicPrjectDetails which doesn't include the repository storage. Having the repository storage available will allow to easily know if the project and the forked_from_project are in the same storage or not so that we can move them to the same storage.

We can still get this information if we send a GET /project/:id request but this will be en extra API call for the user every time they want to see if a project and it's root project (where its forked from) are in the same gitaly shard.

Reference: https://gitlab.com/gitlab-com/gl-infra/reliability/-/issues/24322

How to set up and validate locally

  1. Start a fresh GDK: gdk reset-data.

  2. Create a new PAT with api scope for the root user.

  3. Send requests to a project that is a fork: Before:

    $ curl -s --request GET --header "PRIVATE-TOKEN: $ADMIN_PAT" "http://gdk.test:3000/api/v4/projects/bethanie%2FFlight" | jq -r '.forked_from_project.repository_storage'
    null

    After:

    $ curl -s --request GET --header "PRIVATE-TOKEN: $ADMIN_PAT" "http://gdk.test:3000/api/v4/projects/bethanie%2FFlight" | jq -r '.forked_from_project.repository_storage'
    default
  4. Impersonate a normal user from http://gdk.test:3000/admin/users/

  5. Create a new PAT with api scope.

  6. Send a request to a project that is a fork:

    # Check that repository_storage is not returned
    $ curl -s --request GET --header "PRIVATE-TOKEN: $USER_PAT" "http://gdk.test:3000/api/v4/projects/bethanie%2FFlight" | jq -r '.forked_from_project.repository_storage'
    null
    # Validate that `forked_from_project` is still returned.
    $ curl -s --request GET --header "PRIVATE-TOKEN: $USER_PAT" "http://gdk.test:3000/api/v4/projects/bethanie%2FFlight" | jq -r '.forked_from_project.id'
    17

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Steve Xuereb

Merge request reports

Loading