You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/artifact-management/retention-rules.mdx
+21-21Lines changed: 21 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ Cloudsmith Retention Rules automate artifact data management for a repository by
9
9
- The number of days (time).
10
10
- A [search query](/artifact-management/search-filter-sort-packages) to filter packages.
11
11
12
-
Each repository has one configurable Retention Rule. This rule runs automatically when a new package is uploaded and synchronized; subsequently, it deletes any packages that do not meet the configured parameters.
12
+
Each repository has one configurable Retention Rule. This rule runs automatically when a new package is uploaded and synchronized, subsequently deleting any packages that meet the configured parameters.
13
13
14
14
Retention Rules can be configured for a repository either via the Cloudsmith Web App, the Cloudsmith API, or the Cloudsmith Terraform Provider.
15
15
@@ -41,12 +41,12 @@ From the Cloudsmith Web App UI, use the sliders to configure rule values, and th
41
41
| Name | API | Description |
42
42
|----------|----------|----------|
43
43
| Enabled |`retention_enabled`| Enables/Disables a Retention Rule for a repository. A value of `true` enables the rule, and `false` disables it. |
44
-
| Limit by Days |`retention_days_limit`| The number of days to retain packages. A cutoff date is calculated and packages with an upload date before this cutoff date are selected for deletion; packages uploaded on or after the cutoff are retained. Set to zero to remove this criteria from the rule. |
45
-
| Limit by Count |`retention_count_limit`| The maximum number of packages to retain. Set to zero to remove this criteria from the rule. |
46
-
| Limit by Size |`retention_size_limit`| The maximum total size (in bytes) of packages to retain. Set to zero to remove this criteria from the rule. |
47
-
| Group Packages by Name |`retention_group_by_name`| If enabled, retention will apply to groups of packages by name rather than all packages. For example, when `retention_count_limit` is defined as "1" and packages `PkgA 1.0`, `PkgB 1.0` and `PkgB 1.1` are identified as eligible for deletion; only `PkgB 1.0` is deleted because there are two (2) `PkgBs` and one (1) `PkgA`; this parameter is applied to each grouped package name. |
44
+
| Limit by Days |`retention_days_limit`| The number of days to retain packages. A cutoff date is calculated, and packages with an upload date before this cutoff date are selected for deletion; packages uploaded on or after the cutoff date are retained. Set to zero to remove this criterion from the rule. |
45
+
| Limit by Count |`retention_count_limit`| The maximum number of packages to retain. Set to zero to remove this criterion from the rule. |
46
+
| Limit by Size |`retention_size_limit`| The maximum total size (in bytes) of packages to retain. Set to zero to remove this criterion from the rule. |
47
+
| Group Packages by Name |`retention_group_by_name`| If enabled, retention will apply to groups of packages by name rather than all packages. For example, when `retention_count_limit` is defined as "1" and packages `PkgA 1.0`, `PkgB 1.0`, and `PkgB 1.1` are identified as eligible for deletion; only `PkgB 1.0` is deleted because there are (2) `PkgBs` and (1) `PkgA`; this parameter is applied to each grouped package name. |
48
48
| Group Packages by Format |`retention_group_by_format`| If enabled, retention will apply to packages by package formats rather than across all package formats. For example, when `retention_count_limit` is defined as "1" and packages `PkgA 1.0`(Python) and `PkgA 1.0`(Ruby) are identified as eligible for deletion; nothing is deleted because these packages are different formats and the rule must retain 1 for each grouped package format. |
49
-
| Group Packages by Type |`retention_group_by_package_type`| If enabled, retention will apply to packages by package type (e.g. by binary, by source, etc.), rather than across all package types for one or more formats. For example, when retaining by a limit of 1 and packages `DebPackage 1.0` and `DebSourcePackage 1.0` are uploaded, no packages are deleted because they are different package types, binary and source respectively. |
49
+
| Group Packages by Type |`retention_group_by_package_type`| If enabled, retention will apply to packages by package type (e.g. by binary, by source, etc.), rather than across all package types for one or more formats. For example, when retaining by a limit of 1 and packages `DebPackage 1.0` and `DebSourcePackage 1.0` are uploaded, no packages are deleted because they are of different types: binary and source, respectively. |
50
50
| Query String |`retention_package_query_string`| A package search expression. If provided, this expression further filters the packages to be deleted. For example, a search expression of `name:foo` will result in only packages called `foo` being eligible for deletion, or a search expression of `tag:~latest` will prevent any packages with the `latest` tag from being deleted. Refer to the Cloudsmith documentation for package query syntax. |
51
51
52
52
### Configuration Parameters via the Cloudsmith API
@@ -55,19 +55,19 @@ Visit [API reference](https://api.cloudsmith.io/swagger/) and search by `/repos/
55
55
As a reference, use the `GET` method to retrieve an existing retention rule or the `PATCH` method to update it.
56
56
57
57
## When Do Retention Rules Get Evaluated?
58
-
1.**Upload Trigger:** A Retention Rule is evaluated automatically whenever a new package is uploaded and completes synchronization. This is the ideal method for triggering a retention rule to ensure packages are evaluated and actioned as expected.
59
-
2.**Resync Trigger:** A Retention Rule can also be triggered by resyncing the most recently uploaded package. When using this mechanism, review this documentation to understand how the cutoff date is calculated and how it affects package deletion.
58
+
1.**Upload Trigger:** A Retention Rule is evaluated automatically whenever a new package is uploaded and completes synchronization. This is the ideal method for triggering a retention rule to ensure that packages are evaluated and acted upon as expected.
59
+
2.**Resync Trigger:** A Retention Rule can also be triggered by resyncing the most recently uploaded package. When using this mechanism, review this documentation to understand how the cutoff date is calculated and its impact on package deletion.
60
60
61
61
<Notevariant="note"headline="Limit by Days: Cutoff Date Calculation">
62
62
The cutoff date is calculated by subtracting the Limit by Days parameter value from the upload date of the newest package.
63
63
64
-
Example: If today is June 10 and you upload a new package and the Limit by Days parameter is 4, the cutoff date would be June 6. Packages uploaded before June 6 would be deleted.
64
+
Example: If today is June 10 and you upload a new package with the Limit by Days parameter set to 4, the cutoff date would be June 6. Packages uploaded before June 6 would be deleted.
65
65
</Note>
66
66
67
67
<Notevariant="note"headline="Invoking an Evaluation Using the Resync Trigger">
68
-
The Cloudsmith Package Resync feature does not alter the upload date of a package. The cutoff date is a relative calculation based on the upload date of the most recently uploaded package used to trigger the evaluation. If the most recently uploaded package is 1,000 days old, and the ***Limit by Days*** parameter is 90 (days), the cutoff date calculation will be based on the upload date of that 1,000-day-old package.
68
+
The Cloudsmith Package Resync feature does not alter the upload date of a package. The cutoff date is calculated based on the upload date of the most recently uploaded package that triggered the evaluation. If the most recently uploaded package is 1,000 days old, and the **Limit by Days** parameter is 90 (days), the cutoff date calculation will be based on the upload date of this 1,000-day-old package.
69
69
70
-
Example: 1,000 (uploaded date) subtracted by 90 (Limit by Days parameter) = 910 (cutoff date). Packages 911 days old and older would be deleted. Additionally, the 1,000dayold package used to trigger the evaluation would not be deleted, as it is not eligible for deletion. To effectively delete this 1,000-day-old package, upload a new package to trigger a new evaluation based on the new package's upload date.
70
+
Example: 1,000 (uploaded date) subtracted by 90 (Limit by Days parameter) = 910 (cutoff date). Packages 911 days old and older would be deleted. Additionally, the 1,000-day-old package used to trigger the evaluation would not be deleted, as it is not eligible for deletion. To effectively delete this 1,000-day-old package, upload a new package to trigger a new evaluation based on the new package's upload date.
71
71
</Note>
72
72
73
73
## Other Considerations
@@ -76,23 +76,23 @@ When multiple parameters of a retention rule are enabled, a package that meets a
76
76
### Understanding Groupings
77
77
Enable grouping(s) to filter packages into groups based on specified criteria before applying retention rules.
78
78
79
-
For example, if “Group Packages by Name” is selected, retention will apply to groups of packages by name rather than all packages. For example, when retaining by a count limit of 1 and packages `PkgA 1.0`, `PkgB 1.0` and `PkgB 1.1` are uploaded; only `PkgB 1.0` is deleted because there are two (2) `PkgBs` and one (1) `PkgA`. Or, If “Group Packages by Format” is selected, retention will apply to packages within package types rather than across all package formats. For example, when retaining by a limit of 1 and packages `PythonPkg 1.0` and `RubyPkg 1.0` are uploaded, no packages are deleted because they are different formats.
79
+
For example, if “Group Packages by Name” is selected, retention will apply to groups of packages by name rather than all packages. For example, when retaining by a count limit of 1 and packages `PkgA 1.0`, `PkgB 1.0`, and `PkgB 1.1` are uploaded; only `PkgB 1.0` is deleted because there are two (2) `PkgBs` and one (1) `PkgA`. Or, if “Group Packages by Format” is selected, retention will apply to packages within package types rather than across all package formats. For example, when retaining by a limit of 1 and packages `PythonPkg 1.0` and `RubyPkg 1.0` are uploaded, no packages are deleted because they are different formats.
80
80
81
81
### Understanding the Sequence of an Evaluation
82
82
1.**Initial Query Set is Created** - All successfully synced packages within the repository are identified.
83
-
2.**Grouping is Applied to the Initial Query Set** - The initial query set of all packages is grouped by format, grouped by name, grouped by type based on the enabled parameters specified in the retention rule. To be clear, if all (3) grouping parameters are enabled, this will result in (3) separate query sets.
83
+
2.**Grouping is Applied to the Initial Query Set** - The initial query set of all packages is grouped by format, grouped by name, and grouped by type based on the enabled parameters specified in the retention rule. To be clear, if all 3 grouping parameters are enabled, this will result in 3 separate query sets.
84
84
3.**Package Query String is Applied to Query Set** - The query string filters the packages of each existing query set. Again, if multiple grouping parameters are enabled, the query string is applied to each query set separately.
85
-
4.**Query Set is Ordered by Package Upload Date** - Any query set(s) gets sorted based on the upload date of the packages, newest to oldest and excluding the newest package used to trigger the evaluation.
85
+
4.**Query Set is Ordered by Package Upload Date** - Any query set(s) gets sorted based on the upload date of the packages, newest to oldest, and excluding the newest package used to trigger the evaluation.
86
86
5.**Limit by Count is Applied** - The number of packages to keep is determined according to the Limit by Count parameter. Packages exceeding this limit are deleted from the query set.
87
87
6.**Limit by Days is Applied** - The number of days to keep packages is determined according to the Limit by Days parameter. Packages older than the calculated cutoff date are deleted from the query set.
88
-
7.**Limit by Size is Applied** - The total size of packages to keep is determined according to the Limit by Size parameter. The latest query set is reordered by semantic version value and packages are deleted from the oldest semantic version to newest until the total size of remaining packages is under the defined parameter.
88
+
7.**Limit by Size is Applied** - The total size of packages to keep is determined according to the Limit by Size parameter. The latest query set is reordered by semantic version value, and packages are deleted from the oldest semantic version to the newest until the total size of remaining packages is under the defined parameter.
89
89
90
90
<Notevariant="note">
91
91
The Package Query String Parameter is an excellent way to further filter packages before applying retention rules. The Cloudsmith Web App UI repository Filter function can be used to refine a query string to a desired set of packages and visualize the results.
92
92
</Note>
93
93
94
94
### Limiting the Number of Packages to Delete
95
-
The **Limit by count** option defines the number of packages to keep. For example, if we set its value to `4` and only a total of `3` packages meet the criteria, then `0` packages will be deleted. But if `5` packages meet the criteria, then `1` will be deleted and `4` will be keep in the repository.
95
+
The **Limit by count** option defines the number of packages to keep. For example, if we set its value to `4` and only a total of `3` packages meet the criteria, then `0` packages will be deleted. But if `5` packages meet the criteria, then `1` will be deleted and `4` will be kept in the repository.
96
96
97
97
This value applies per group. So, the maximum total number of packages to keep will always be the result of `retention_count_limit` multiplied by the number of groups.
98
98
@@ -106,16 +106,16 @@ The **Limit by Size** option defines the total size of packages to keep. For exa
106
106
### Example 1
107
107
Delete packages older than 100 days.
108
108
109
-
To configure a retention rule in the UI that removes all packages older than 100 days, configure the next values:
109
+
To configure a retention rule in the UI that removes all packages older than 100 days, configure the following values:
110
110
111
111
- "Limit By Days" = 100
112
112
- "Limit By Count" = 0
113
113
- "Limit By Size" = 0.0B (disabled)
114
114
115
-
By disabling count and size, it means it only uses the package age to delete.
115
+
Disabling count and size means it only uses the package age to delete.
116
116
117
117
### Example 2
118
-
Delete all packages that are more than 30 days old and do not have any tag.
118
+
Delete all packages that are more than 30 days old and do not have any tags.
119
119
120
120
```shell
121
121
curl --request PATCH \
@@ -131,7 +131,7 @@ curl --request PATCH \
131
131
```
132
132
133
133
### Example 3
134
-
Delete all packages that are more than 60 days old and have less than 10 downloads.
134
+
Delete all packages that are more than 60 days old and have fewer than 10 downloads.
135
135
136
136
```shell
137
137
curl --request PATCH \
@@ -147,7 +147,7 @@ curl --request PATCH \
147
147
```
148
148
149
149
### Example 4
150
-
Keep only 5 packages per format (python, docker, helm, etc.), that are not older than 100 days, are not tagged with `production`, have been downloaded less than 10 times and are violating some policies.
150
+
Keep only 5 packages per format (Python, Docker, Helm, etc.) that are not older than 100 days, are not tagged with `production`, have been downloaded fewer than 10 times, and are violating some policies.
0 commit comments