Lazy load container registry tags

Weights:
frontend: 2
backend: 2

Rationale

Currently, the container registry tag list works as follow:

  1. Frontend hits app/controllers/projects/registry/tags_controller.rb
  2. Rails fetch all the tags from the container registry
  3. Rails paginate the tags
  4. For each tag inside the paginated subset 1 request for each field is issued ( 5 requests in average per tag )
  5. When all the requests are done the list with the details is returned to the frontend

We could change this approach and leverage the UI to make this more smooth:

  1. Fetch the full list of tags, the list should only contain the tag name ( this should be a fast request )
  2. Paginate it on the frontend
  3. When a tag is displayed in the UI, show the tag name and lazy load the rest of the tag details
  4. Cache in-memory the tag details so there is no need to fetch the value two times

This new approach would allow us to:

  • Enable the search ( only on the tag name )
  • Enable sorting ( only on the tag name )
  • Defer the perception of loading time for the user, since the data will appear when is ready but the UI will still be functional

Implementation

This is a video that demonstrates the second approach in action:

https://youtu.be/scHApK4Ygc8

This is the MR of the proof of concept that I created (that powers the video), as usual, the proof of concept is created in a way that we can 'reuse' 60/70% of the code, but the tests are all missing

!26503 (closed)

What is missing

  • tests
  • API endpoint for the group level
  • a non-hacky way to find have the path to the tag bulk_delete in the Get repository details call

Backend what is needed

I added this code:

     desc 'Get repository details' do
        detail 'This feature was introduced in GitLab 12.9.'
        success Entities::ContainerRegistry::Repository
      end
      params do
        requires :repository_id, type: Integer, desc: 'The ID of the repository'
      end
      get ':id/registry/repositories/:repository_id' do
        present repository, with: Entities::ContainerRegistry::Repository, tags: true
      end

to lib/api/project_container_repositories.rb, the very same needs to be added to lib/api/group_container_repositories.rb

Add to Entities::ContainerRegistry::Repository the bulk_delete path (https://gitlab.com/gitlab-org/gitlab/blob/22c19861a6b2137e5b57ab04798b81c721349cf0/app/controllers/projects/registry/repositories_controller.rb#L34-35)

Unit tests for all of the above

Edited by Tim Rizzi