Protected containers: Protected badge not visible in group level view
Summary
In the group container registry overview list, some protected container repositories do not contain the badge "protected", although the these container repositories are actually protected.
Note: This bug was mentioned by @rchanila in #480385 (comment 2229699064). The intention of this bug is to isolate the discussion.
Steps to reproduce
- Create a group with multiple projects.
- Publish container images to each project.
- Setup protection rule in one of the projects & confirm that
protectedbadge is visible for container images underProject > Deploy > Container registry - Visit
Group > Deploy > Container registry.
Example Project
Feature flag :container_registry_protected_containers is currently disabled on gitlab.com . Therefore, it is not possible to show case this bug on an example project.
What is the current bug behavior?
Usually, when a container repository is protected by a container protection rule, then this container repository should be marked with a badge "protected" in the container registry overview list. This also works fine for a single container overview list inside a project. The following three screenshots show that each project has protected one container repository.
However, for the container overview list inside the group shows the container repositories from all the sub projects. If a container repository of a sub project is protected then this container repository should also recieve a badge "protected" in the group's overview list. As the following screenshot shows, this is not the case with the current implementation because the container repositories project-1/protected, project-2/protected and project-3/protected should have the badge "protected".
What is the expected correct behavior?
As mentioned right above, the overview list of the container repositories inside the group should also show the badge "protected" for all the protected container repositories.
Relevant logs and/or screenshots
Output of checks
Results of GitLab environment info
Expand for output related to GitLab environment info
System information System: Proxy: no Current User: client-siemens Using RVM: no Ruby Version: 3.2.4 Gem Version: 3.5.23 Bundler Version:2.5.11 Rake Version: 13.0.6 Redis Version: 7.0.14 Sidekiq Version:7.2.4 Go Version: go1.23.2 darwin/arm64 GitLab information Version: 17.7.0-pre Revision: 9f1f1be6663 Directory: /Users/client-siemens/Development/gitlab-development-kit/gitlab DB Adapter: PostgreSQL DB Version: 14.9 URL: http://gdk.test:3000 HTTP Clone URL: http://gdk.test:3000/some-group/some-project.git SSH Clone URL: ssh://git@gdk.test:2222/some-group/some-project.git Elasticsearch: no Geo: no Using LDAP: no Using Omniauth: yes Omniauth Providers: GitLab Shell Version: 14.39.0 Repository storages: - default: unix:/Users/client-siemens/Development/gitlab-development-kit/praefect.socket GitLab Shell path: /Users/client-siemens/Development/gitlab-development-kit/gitlab-shell Gitaly - default Address: unix:/Users/client-siemens/Development/gitlab-development-kit/praefect.socket - default Version: 17.5.0-rc1-271-g9a94e7c7c - default Git Version: 2.47.0
Results of GitLab application Check
Expand for output related to the GitLab application check
Checking GitLab subtasks ...Checking GitLab Shell ...
GitLab Shell: ... GitLab Shell version >= 14.39.0 ? ... OK (14.39.0) Running /Users/client-siemens/Development/gitlab-development-kit/gitlab-shell/bin/gitlab-shell-check {"correlation_id":"01JDQ2S1GJRDZQ78MC2SM36KXE","duration_ms":216,"error":null,"level":"error","method":"GET","msg":"Internal API error","status":500,"time":"2024-11-27T15:10:32Z","url":"http://gdk.test:3000/api/v4/internal/check"} {"correlation_id":"01JDQ2S1GJRDZQ78MC2SM36KXE","duration_ms":50,"error":null,"level":"error","method":"GET","msg":"Internal API error","status":500,"time":"2024-11-27T15:10:33Z","url":"http://gdk.test:3000/api/v4/internal/check"} {"correlation_id":"01JDQ2S1GJRDZQ78MC2SM36KXE","duration_ms":35,"error":null,"level":"error","method":"GET","msg":"Internal API error","status":500,"time":"2024-11-27T15:10:35Z","url":"http://gdk.test:3000/api/v4/internal/check"} gitlab-shell self-check failed Try fixing it: Make sure GitLab is running; Check the gitlab-shell configuration file: sudo -u client-siemens -H editor /Users/client-siemens/Development/gitlab-development-kit/gitlab-shell/config.yml Please fix the error above and rerun the checks.
Checking GitLab Shell ... Finished
Checking Gitaly ...
Gitaly: ... default ... OK
Checking Gitaly ... Finished
Checking Sidekiq ...
Sidekiq: ... Running? ... yes Number of Sidekiq processes (cluster/worker) ... 1/1
Checking Sidekiq ... Finished
Checking Incoming Email ...
Incoming Email: ... Reply by email is disabled in config/gitlab.yml
Checking Incoming Email ... Finished
Checking LDAP ...
LDAP: ... LDAP is disabled in config/gitlab.yml
Checking LDAP ... Finished
Checking GitLab App ...
Database config exists? ... yes Tables are truncated? ... yes All migrations up? ... yes Database contains orphaned GroupMembers? ... no GitLab config exists? ... yes GitLab config up to date? ... yes Cable config exists? ... yes Resque config exists? ... yes Log directory writable? ... yes Tmp directory writable? ... yes Uploads directory exists? ... yes Uploads directory has correct permissions? ... no Try fixing it: sudo chmod 700 /Users/client-siemens/Development/gitlab-development-kit/gitlab/public/uploads For more information see: doc/install/installation.md in section "GitLab" Please fix the error above and rerun the checks. Uploads directory tmp has correct permissions? ... yes Systemd unit files or init script exist? ... no Try fixing it: Install the Service For more information see: doc/install/installation.md in section "Install the Service" Please fix the error above and rerun the checks. Systemd unit files or init script up-to-date? ... can't check because of previous errors Projects have namespace: ... 22/1 ... yes 24/2 ... yes 24/3 ... yes 27/4 ... yes 29/5 ... yes 31/6 ... yes 33/7 ... yes 35/8 ... yes 58/9 ... yes 10/10 ... yes 49/11 ... yes 12/12 ... yes 13/13 ... yes 43/14 ... yes 9/15 ... yes 56/16 ... yes 6/17 ... yes 17/18 ... yes 1/19 ... yes 1/20 ... yes 1/21 ... yes 1/22 ... yes 1/23 ... yes 1/24 ... yes 29/25 ... yes 104/26 ... yes 106/27 ... yes 109/28 ... yes 113/29 ... yes 115/30 ... yes 117/31 ... yes 119/32 ... yes 1/33 ... yes 125/34 ... yes 128/35 ... yes 127/36 ... yes 1/37 ... yes 132/38 ... yes 134/39 ... yes 140/40 ... yes 151/41 ... yes 153/42 ... yes 153/43 ... yes 158/44 ... yes 151/45 ... yes 151/46 ... yes 151/48 ... yes 151/49 ... yes 151/50 ... yes 151/51 ... yes 167/52 ... yes 170/53 ... yes 167/54 ... yes 173/55 ... yes 173/56 ... yes 173/57 ... yes Redis version >= 6.2.14? ... yes Ruby version >= 3.0.6 ? ... yes (3.2.4) Git user has default SSH configuration? ... no Try fixing it: mkdir ~/gitlab-check-backup-1732720254 sudo mv /Users/client-siemens/.ssh/config ~/gitlab-check-backup-1732720254 sudo mv /Users/client-siemens/.ssh/gdk.local_rsa ~/gitlab-check-backup-1732720254 sudo mv /Users/client-siemens/.ssh/gitpod ~/gitlab-check-backup-1732720254 sudo mv /Users/client-siemens/.ssh/id_ed25519 ~/gitlab-check-backup-1732720254 sudo mv /Users/client-siemens/.ssh/id_ed25519.pub ~/gitlab-check-backup-1732720254 sudo mv /Users/client-siemens/.ssh/known_hosts.old ~/gitlab-check-backup-1732720254 For more information see: doc/user/ssh.md#overriding-ssh-settings-on-the-gitlab-server Please fix the error above and rerun the checks. Active users: ... 75 Is authorized keys file accessible? ... yes GitLab configured to store new projects in hashed storage? ... yes All projects are in hashed storage? ... yes Elasticsearch version 7.x-8.x or OpenSearch version 1.x ... skipped (Advanced Search is disabled) All migrations must be finished before doing a major upgrade ... skipped (Advanced Search is disabled)
Checking GitLab App ... Finished
Checking GitLab subtasks ... Finished
Possible fixes
-
Add or extend the test case for graphql api group to cover this bug scenario, see https://gitlab.com/gitlab-community/gitlab/-/blob/master/spec/requests/api/graphql/group/container_repositories_spec.rb -
Adjust the method that checks several container protection rules at once container repositories in bulk https://gitlab.com/gitlab-community/gitlab/-/blob/master/app/models/container_registry/protection/rule.rb#L45 -
Adjust the field protectionRuleExists, seehttps://gitlab.com/gitlab-community/gitlab/-/blob/master/app/graphql/types/container_registry/container_repository_type.rb#L71



