Commit f90e7416 authored by Katrin Leinweber's avatar Katrin Leinweber Committed by Suzanne Selhorn

Surface container tag cleanup workaround

From https://gitlab.com/gitlab-org/gitlab/-/issues/220886#workaround
parent bbf984f0
......@@ -693,6 +693,35 @@ notifications:
backoff: 1000
```
## Run the Cleanup policy now
To reduce the amount of [Container Registry disk space used by a given project](../troubleshooting/gitlab_rails_cheat_sheet.md#registry-disk-space-usage-by-project),
administrators can clean up image tags
and [run garbage collection](#container-registry-garbage-collection).
To remove image tags by running the cleanup policy, run the following commands in the
[GitLab Rails console](../troubleshooting/navigating_gitlab_via_rails_console.md):
```ruby
# Numeric ID of the project whose container registry should be cleaned up
P = <project_id>
# Numeric ID of a developer, maintainer or owner in that project
U = <user_id>
# Get required details / objects
user = User.find_by_id(U)
project = Project.find_by_id(P)
repo = ContainerRepository.find_by(project_id: P)
policy = ContainerExpirationPolicy.find_by(project_id: P)
# Start the tag cleanup
Projects::ContainerRepository::CleanupTagsService.new(project, user, policy.attributes.except("created_at", "updated_at")).execute(repo)
```
NOTE: **Note:**
You can also [run cleanup on a schedule](../../user/packages/container_registry/index.md#cleanup-policy).
## Container Registry garbage collection
NOTE: **Note:**
......
......@@ -689,10 +689,10 @@ end
As a GitLab administrator, you may need to reduce disk space consumption.
A common culprit is Docker Registry images that are no longer in use. To find
the storage broken down by each project, run the following in the
GitLab Rails console:
[GitLab Rails console](../troubleshooting/navigating_gitlab_via_rails_console.md):
```ruby
projects_and_size = []
projects_and_size = [["project_id", "creator_id", "registry_size_bytes", "project path"]]
# You need to specify the projects that you want to look through. You can get these in any manner.
projects = Project.last(100)
......@@ -707,17 +707,21 @@ projects.each do |p|
end
if project_total_size > 0
projects_and_size << [p.full_path,project_total_size]
projects_and_size << [p.project_id, p.creator.id, project_total_size, p.full_path]
end
end
# projects_and_size is filled out now
# maybe print it as comma separated output?
projects_and_size.each do |ps|
puts "%s,%s" % ps
puts "%s,%s,%s,%s" % ps
end
```
### Run the Cleanup policy now
Find this content in the [Container Registry troubleshooting docs](../packages/container_registry.md#run-the-cleanup-policy-now).
## Sidekiq
This content has been moved to the [Troubleshooting Sidekiq docs](./sidekiq.md).
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment