|
| 1 | +--- |
| 2 | +date: "2022-11-01T00:00:00+00:00" |
| 3 | +title: "Storage" |
| 4 | +slug: "packages/storage" |
| 5 | +draft: false |
| 6 | +toc: false |
| 7 | +menu: |
| 8 | + sidebar: |
| 9 | + parent: "packages" |
| 10 | + name: "storage" |
| 11 | + weight: 5 |
| 12 | + identifier: "storage" |
| 13 | +--- |
| 14 | + |
| 15 | +# Storage |
| 16 | + |
| 17 | +This document describes the storage of the package registry and how it can be managed. |
| 18 | + |
| 19 | +**Table of Contents** |
| 20 | + |
| 21 | +{{< toc >}} |
| 22 | + |
| 23 | +## Deduplication |
| 24 | + |
| 25 | +The package registry has a build-in deduplication of uploaded blobs. |
| 26 | +If two identical files are uploaded only one blob is saved on the filesystem. |
| 27 | +This ensures no space is wasted for duplicated files. |
| 28 | + |
| 29 | +If two packages are uploaded with identical files, both packages will display the same size but on the filesystem they require only half of the size. |
| 30 | +Whenever a package gets deleted only the references to the underlaying blobs are removed. |
| 31 | +The blobs get not removed at this moment, so they still require space on the filesystem. |
| 32 | +When a new package gets uploaded the existing blobs may get referenced again. |
| 33 | + |
| 34 | +These unreferenced blobs get deleted by a [clean up job]({{< relref "doc/advanced/config-cheat-sheet.en-us.md#cron---cleanup-expired-packages-croncleanup_packages" >}}). |
| 35 | +The config setting `OLDER_THAN` configures how long unreferenced blobs are kept before they get deleted. |
| 36 | + |
| 37 | +## Cleanup Rules |
| 38 | + |
| 39 | +Package registries can become large over time without cleanup. |
| 40 | +It's recommended to delete unnecessary packages and set up cleanup rules to automatically manage the package registry usage. |
| 41 | +Every package owner (user or organization) manages the cleanup rules which are applied to their packages. |
| 42 | + |
| 43 | +|Setting|Description| |
| 44 | +|-|-| |
| 45 | +|Enabled|Turn the cleanup rule on or off.| |
| 46 | +|Type|Every rule manages a specific package type.| |
| 47 | +|Apply pattern to full package name|If enabled, the patterns below are applied to the full package name (`package/version`). Otherwise only the version (`version`) is used.| |
| 48 | +|Keep the most recent|How many versions to *always* keep for each package.| |
| 49 | +|Keep versions matching|The regex pattern that determines which versions to keep. An empty pattern keeps no version while `.+` keeps all versions. The container registry will always keep the `latest` version even if not configured.| |
| 50 | +|Remove versions older than|Remove only versions older than the selected days.| |
| 51 | +|Remove versions matching|The regex pattern that determines which versions to remove. An empty pattern or `.+` leads to the removal of every package if no other setting tells otherwise.| |
| 52 | + |
| 53 | +Every cleanup rule can show a preview of the affected packages. |
| 54 | +This can be used to check if the cleanup rules is proper configured. |
| 55 | + |
| 56 | +### Regex examples |
| 57 | + |
| 58 | +Regex patterns are automatically surrounded with `\A` and `\z` anchors. |
| 59 | +Do not include any `\A`, `\z`, `^` or `$` token in the regex patterns as they are not necessary. |
| 60 | +The patterns are case-insensitive which matches the behaviour of the package registry in Gitea. |
| 61 | + |
| 62 | +|Pattern|Description| |
| 63 | +|-|-| |
| 64 | +|`.*`|Match every possible version.| |
| 65 | +|`v.+`|Match versions that start with `v`.| |
| 66 | +|`release`|Match only the version `release`.| |
| 67 | +|`release.*`|Match versions that are either named or start with `release`.| |
| 68 | +|`.+-temp-.+`|Match versions that contain `-temp-`.| |
| 69 | +|`v.+\|release`|Match versions that either start with `v` or are named `release`.| |
| 70 | +|`package/v.+\|other/release`|Match versions of the package `package` that start with `v` or the version `release` of the package `other`. This needs the setting *Apply pattern to full package name* enabled.| |
| 71 | + |
| 72 | +### How the cleanup rules work |
| 73 | + |
| 74 | +The cleanup rules are part of the [clean up job]({{< relref "doc/advanced/config-cheat-sheet.en-us.md#cron---cleanup-expired-packages-croncleanup_packages" >}}) and run periodicly. |
| 75 | + |
| 76 | +The cleanup rule: |
| 77 | + |
| 78 | +1. Collects all packages of the package type for the owners registry. |
| 79 | +1. For every package it collects all versions. |
| 80 | +1. Excludes from the list the # versions based on the *Keep the most recent* value. |
| 81 | +1. Excludes from the list any versions matching the *Keep versions matching* value. |
| 82 | +1. Excludes from the list the versions more recent than the *Remove versions older than* value. |
| 83 | +1. Excludes from the list any versions not matching the *Remove versions matching* value. |
| 84 | +1. Deletes the remaining versions. |
0 commit comments