feat: add namespace with tags endpoint
Context
It is a well known problem that renaming/moving groups with container repositories is not possible Allow renaming/moving groups and projects with ... (&9459).
This was recently brought to our attention in this issue (internal) that attempting to rename a namespace that removed all container repositories is failing.
Problem
One of the problems identified in the customer support issue is that GitLab Rails will query the container registry /tags/list
endpoint for each project in a given namespace, which results in a high number of API requests for namespaces with many many projects.
Solution
Add a new endpoint to the the container registryAPI-GitLab-V1 that will quickly return if a namespace contains any container repositories with tags in it. To accomplish this, we can do the following:
- Add the new endpoint specification to the
/gitlab/v1
API docs. For example:-
GET /gitlab/v1/repositories/<namespace>
or perhaps adding a new routeGET /gitlab/v1/namespace/<name>
(TBD) - Specify supported query strings, for example whether the response will include a small number of repository paths that contain tags e.g.
?include_paths=true
-
- Once documented, we should go ahead and do the implementation of the new endpoint.
-
Add a new method to the
NamespaceStore
inregistry/datastore/namespace.go
that can query thetop_level_namespace
table joined with the tags and repositories table. Sample query used before:select * from (select r.path as repo, count(*) as tag_count from tags as t join repositories as r on r.id = t.repository_id where t.top_level_namespace_id = 1234 group by r.path) q order by tag_count desc;
-
Add new endpoint to the
repositoryHandler
handler. If going with the/namespace/
route, we would require a newnamespaceHandler
.
-
Once this is done, we will need to update the method used by Rails to query if there are any tags for a given namespace, see Renaming a namespace with large number of proje... (gitlab#385679 - closed).