Skip to content

Commit cf90bb4

Browse files
stevsmitSteven Smith
andauthored
Adds multiple auto-pruning policies info (quay#1119)
Co-authored-by: Steven Smith <[email protected]>
1 parent 02c5f1f commit cf90bb4

10 files changed

+195
-22
lines changed
-8.1 KB
Loading

modules/api-policy-createOrganizationAutoPrunePolicy.adoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ The policy configuration that is to be applied to the user namespace
3333
_required_|The method to use for pruning tags (number_of_tags, creation_date)|string
3434
|**value** +
3535
_required_|The value to use for the pruning method (number of tags e.g. 10, time delta e.g. 7d (7 days))|
36+
|**tagPattern** +
37+
_optional_|Tags only matching this pattern will be pruned|string
38+
|**tagPatternMatches** +
39+
_optional_|Determine whether pruned tags should or should not match the tagPattern|boolean
3640
|===
3741

3842

modules/api-policy-createRepositoryAutoPrunePolicy.adoc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,13 @@ The policy configuration that is to be applied to the user namespace
3030
|===
3131
|Name|Description|Schema
3232
|**method** +
33-
_optional_|The method to use for pruning tags (number_of_tags, creation_date)|string
33+
_required_|The method to use for pruning tags (number_of_tags, creation_date)|string
3434
|**value** +
35-
_optional_|The value to use for the pruning method (number of tags e.g. 10, time delta e.g. 7d (7 days))|
35+
_required_|The value to use for the pruning method (number of tags e.g. 10, time delta e.g. 7d (7 days))|
36+
|**tagPattern** +
37+
_optional_|Tags only matching this pattern will be pruned|string
38+
|**tagPatternMatches** +
39+
_optional_|Determine whether pruned tags should or should not match the tagPattern|boolean
3640
|===
3741

3842

modules/api-policy-createUserAutoPrunePolicy.adoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ The policy configuration that is to be applied to the user namespace
2323
_required_|The method to use for pruning tags (number_of_tags, creation_date)|string
2424
|**value** +
2525
_required_|The value to use for the pruning method (number of tags e.g. 10, time delta e.g. 7d (7 days))|
26+
|**tagPattern** +
27+
_optional_|Tags only matching this pattern will be pruned|string
28+
|**tagPatternMatches** +
29+
_optional_|Determine whether pruned tags should or should not match the tagPattern|boolean
2630
|===
2731

2832

modules/api-policy-updateOrganizationAutoPrunePolicy.adoc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ Updates the auto-prune policy for the organization
1616
[options="header", width=100%, cols=".^2a,.^3a,.^9a,.^4a"]
1717
|===
1818
|Type|Name|Description|Schema
19-
|path|**orgname** +
20-
_required_|The name of the organization|string
2119
|path|**policy_uuid** +
2220
_required_|The unique ID of the policy|string
21+
|path|**orgname** +
22+
_required_|The name of the organization|string
2323
|===
2424

2525

@@ -35,6 +35,10 @@ The policy configuration that is to be applied to the user namespace
3535
_required_|The method to use for pruning tags (number_of_tags, creation_date)|string
3636
|**value** +
3737
_required_|The value to use for the pruning method (number of tags e.g. 10, time delta e.g. 7d (7 days))|
38+
|**tagPattern** +
39+
_optional_|Tags only matching this pattern will be pruned|string
40+
|**tagPatternMatches** +
41+
_optional_|Determine whether pruned tags should or should not match the tagPattern|boolean
3842
|===
3943

4044

modules/api-policy-updateRepositoryAutoPrunePolicy.adoc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,13 @@ The policy configuration that is to be applied to the user namespace
3232
|===
3333
|Name|Description|Schema
3434
|**method** +
35-
_optional_|The method to use for pruning tags (number_of_tags, creation_date)|string
35+
_required_|The method to use for pruning tags (number_of_tags, creation_date)|string
3636
|**value** +
37-
_optional_|The value to use for the pruning method (number of tags e.g. 10, time delta e.g. 7d (7 days))|
37+
_required_|The value to use for the pruning method (number of tags e.g. 10, time delta e.g. 7d (7 days))|
38+
|**tagPattern** +
39+
_optional_|Tags only matching this pattern will be pruned|string
40+
|**tagPatternMatches** +
41+
_optional_|Determine whether pruned tags should or should not match the tagPattern|boolean
3842
|===
3943

4044

modules/api-policy-updateUserAutoPrunePolicy.adoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ The policy configuration that is to be applied to the user namespace
3333
_required_|The method to use for pruning tags (number_of_tags, creation_date)|string
3434
|**value** +
3535
_required_|The value to use for the pruning method (number of tags e.g. 10, time delta e.g. 7d (7 days))|
36+
|**tagPattern** +
37+
_optional_|Tags only matching this pattern will be pruned|string
38+
|**tagPatternMatches** +
39+
_optional_|Determine whether pruned tags should or should not match the tagPattern|boolean
3640
|===
3741

3842

modules/managing-namespace-auto-pruning-policies.adoc

Lines changed: 118 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
[id="managing-namespace-auto-pruning-policies"]
33
= Managing auto-pruning policies using the {productname} UI
44

5-
All auto-pruning policies, with the exception of a registry-wide auto pruning policy, are created using the {productname} v2 UI. This can be done after you have configured your {productname} `config.yaml` file to enable the auto-pruning feature and the v2 UI.
5+
All auto-pruning policies, with the exception of a registry-wide auto pruning policy, are created using the {productname} v2 UI or by using the API. This can be done after you have configured your {productname} `config.yaml` file to enable the auto-pruning feature and the v2 UI.
66

77
[NOTE]
88
====
@@ -191,6 +191,10 @@ image:auto-prune-policies-page.png[Auto-Prune Policies page]
191191

192192
. Select the desired number of tags to keep. By default, this is set at *20* tags. For this example, the number of tags to keep is set at *3*.
193193

194+
. Optional. To prune only tags that match the given regex pattern, click the *Tag pattern* box and select *match*. In the regex box, enter a pattern to match tags against. For example, to automatically prune all `test` tags, enter `^test.*`. To prune a specific image, you can enter `^test1$`.
195+
196+
. Optional. You can create a second auto-prune policy by clicking *Add Policy* and entering the required information.
197+
194198
. Click *Save*. A notification that your auto-prune policy has been updated appears.
195199

196200
.Verification
@@ -212,7 +216,7 @@ You can use {productname} API endpoints to manage auto-pruning policies for an n
212216

213217
.Procedure
214218

215-
. Enter the following `POST` command create a new policy that limits the number of tags allowed in an organization:
219+
. Enter the following link:https://docs.redhat.com/en/documentation/red_hat_quay/{producty}/html-single/red_hat_quay_api_guide/index#createorganizationautoprunepolicy[`POST /api/v1/organization/{orgname}/autoprunepolicy/`] command create a new policy that limits the number of tags allowed in an organization:
216220
+
217221
[source,terminal]
218222
----
@@ -232,13 +236,43 @@ $ curl -X POST -H "Authorization: Bearer <access_token>" -H "Content-Type: appli
232236
----
233237
{"uuid": "73d64f05-d587-42d9-af6d-e726a4a80d6e"}
234238
----
239+
240+
. Optional. You can add an additional policy to an organization and pass in the `tagPattern` and `tagPatternMatches` fields to prune only tags that match the given regex pattern. For example:
241+
+
242+
[source,terminal]
243+
----
244+
$ curl -X POST \
245+
-H "Authorization: Bearer <bearer_token>" \
246+
-H "Content-Type: application/json" \
247+
-d '{
248+
"method": "creation_date",
249+
"value": "7d",
250+
"tagPattern": "^v*",
251+
"tagPatternMatches": true
252+
}' \
253+
"https://<quay-server.example.com>/api/v1/organization/<organization_name>/autoprunepolicy/"
254+
----
255+
+
256+
.Example output
235257
+
236-
Attempting to create multiple policies returns the following error:
258+
[source,terminal]
259+
----
260+
{"uuid": "ebf7448b-93c3-4f14-bf2f-25aa6857c7b0"}
261+
----
262+
263+
. You can update your organization's auto-prune policy by using the link:https://docs.redhat.com/en/documentation/red_hat_quay/{producty}/html-single/red_hat_quay_api_guide/index#updateorganizationautoprunepolicy[`PUT /api/v1/organization/{orgname}/autoprunepolicy/{policy_uuid}`] command. For example:
237264
+
238265
[source,terminal]
239266
----
240-
{"detail": "Policy for this namespace already exists, delete existing to create new policy", "error_message": "Policy for this namespace already exists, delete existing to create new policy", "error_type": "invalid_request", "title": "invalid_request", "type": "http://<quay-server.example.com>/api/v1/error/invalid_request", "status": 400}
267+
$ curl -X PUT -H "Authorization: Bearer <bearer_token>" -H "Content-Type: application/json" -d '{
268+
"method": "creation_date",
269+
"value": "4d",
270+
"tagPattern": "^v*",
271+
"tagPatternMatches": true
272+
}' "<quay-server.example.com>/api/v1/organization/<organization_name>/autoprunepolicy/<uuid>"
241273
----
274+
+
275+
This command does not return output. Continue to the next step.
242276

243277
. Check your auto-prune policy by entering the following command:
244278
+
@@ -254,7 +288,7 @@ $ curl -X GET -H "Authorization: Bearer <access_token>" http://<quay-server.exam
254288
{"policies": [{"uuid": "73d64f05-d587-42d9-af6d-e726a4a80d6e", "method": "creation_date", "value": "7d"}]}
255289
----
256290

257-
. You can delete the auto-prune policy by entering the following command. Note that deleting the policy requires the UUID.
291+
. You can delete the auto-prune policy for your organization by entering the following command. Note that deleting the policy requires the UUID.
258292
+
259293
[source,terminal]
260294
----
@@ -397,6 +431,10 @@ $ podman push <quay-server.example.com>/<organization_name>/<repository_name>:te
397431

398432
. Select the desired number of tags to keep. By default, this is set at *20* tags. For this example, the number of tags to keep is set at *3*.
399433

434+
. Optional. To prune only tags that match the given regex pattern, click the *Tag pattern* box and select *match*. In the regex box, enter a pattern to match tags against. For example, to automatically prune all `test` tags, enter `^test.*`. To prune a specific image, you can enter `^test1$`.
435+
436+
. Optional. You can create a second auto-prune policy by clicking *Add Policy* and entering the required information.
437+
400438
. Click *Save*. A notification that your auto-prune policy has been updated appears.
401439

402440
.Verification
@@ -418,7 +456,7 @@ You can use {productname} API endpoints to manage auto-pruning policies for an r
418456

419457
.Procedure
420458

421-
. Enter the following `POST` command create a new policy that limits the number of tags allowed in an organization:
459+
. Enter the following link:https://docs.redhat.com/en/documentation/red_hat_quay/{producty}/html-single/red_hat_quay_api_guide/index#updateorganizationautoprunepolicy[`POST /api/v1/repository/{repository}/autoprunepolicy/`] command create a new policy that limits the number of tags allowed in an organization:
422460
+
423461
[source,terminal]
424462
----
@@ -438,14 +476,48 @@ $ curl -X POST -H "Authorization: Bearer <access_token>" -H "Content-Type: appli
438476
----
439477
{"uuid": "ce2bdcc0-ced2-4a1a-ac36-78a9c1bed8c7"}
440478
----
479+
480+
. Optional. You can add an additional policy and pass in the `tagPattern` and `tagPatternMatches` fields to prune only tags that match the given regex pattern. For example:
481+
+
482+
[source,terminal]
483+
----
484+
$ curl -X POST \
485+
-H "Authorization: Bearer <access_token>" \
486+
-H "Content-Type: application/json" \
487+
-d '{
488+
"method": "<creation_date>",
489+
"value": "<7d>",
490+
"tagPattern": "<^test.>*",
491+
"tagPatternMatches": <true>
492+
}' \
493+
"https://<quay-server.example.com>/api/v1/repository/<organization_name>/<repository_name>/<tag_name>/autoprunepolicy/"
494+
----
441495
+
442-
Attempting to create multiple policies returns the following error:
496+
.Example output
443497
+
444498
[source,terminal]
445499
----
446-
{"detail": "Policy for this namespace already exists, delete existing to create new policy", "error_message": "Policy for this namespace already exists, delete existing to create new policy", "error_type": "invalid_request", "title": "invalid_request", "type": "http://quay-server.example.com/api/v1/error/invalid_request", "status": 400}
500+
{"uuid": "b53d8d3f-2e73-40e7-96ff-736d372cd5ef"}
447501
----
448502

503+
. You can update your policy for the repository by using the link:https://docs.redhat.com/en/documentation/red_hat_quay/{producty}/html-single/red_hat_quay_api_guide/index#updaterepositoryautoprunepolicy[`PUT /api/v1/repository/{repository}/autoprunepolicy/{policy_uuid}`] command and passing in the UUID. For example:
504+
+
505+
[source,terminal]
506+
----
507+
$ curl -X PUT \
508+
-H "Authorization: Bearer <bearer_token>" \
509+
-H "Content-Type: application/json" \
510+
-d '{
511+
"method": "number_of_tags",
512+
"value": "5",
513+
"tagPattern": "^test.*",
514+
"tagPatternMatches": true
515+
}' \
516+
"https://quay-server.example.com/api/v1/repository/<namespace>/<repo_name>/autoprunepolicy/<uuid>"
517+
----
518+
+
519+
This command does not return output. Continue to the next step to check your auto-prune policy.
520+
449521
. Check your auto-prune policy by entering the following command:
450522
+
451523
[source,terminal]
@@ -495,7 +567,7 @@ You can use {productname} API endpoints to manage auto-pruning policies on a rep
495567

496568
.Procedure
497569

498-
. Enter the following `POST` command create a new policy that limits the number of tags for the current user:
570+
. Enter the following link:https://docs.redhat.com/en/documentation/red_hat_quay/{producty}/html-single/red_hat_quay_api_guide/index#createuserautoprunepolicy[`POST /api/v1/user/autoprunepolicy/`] command create a new policy that limits the number of tags for the current user:
499571
+
500572
[source,terminal]
501573
----
@@ -509,6 +581,43 @@ $ curl -X POST -H "Authorization: Bearer <access_token>" -H "Content-Type: appli
509581
{"uuid": "7726f79c-cbc7-490e-98dd-becdc6fefce7"}
510582
----
511583

584+
. Optional. You can add an additional policy for the current user and pass in the `tagPattern` and `tagPatternMatches` fields to prune only tags that match the given regex pattern. For example:
585+
+
586+
[source,terminal]
587+
----
588+
$ curl -X POST \
589+
-H "Authorization: Bearer <bearer_token>" \
590+
-H "Content-Type: application/json" \
591+
-d '{
592+
"method": "creation_date",
593+
"value": "7d",
594+
"tagPattern": "^v*",
595+
"tagPatternMatches": true
596+
}' \
597+
"https://<quay-server.example.com>/api/v1/user/autoprunepolicy/"
598+
----
599+
+
600+
.Example output
601+
+
602+
[source,terminal]
603+
----
604+
{"uuid": "b3797bcd-de72-4b71-9b1e-726dabc971be"}
605+
----
606+
607+
. You can update your policy for the current user by using the link:https://docs.redhat.com/en/documentation/red_hat_quay/{producty}/html-single/red_hat_quay_api_guide/index#updateuserautoprunepolicy[`PUT /api/v1/user/autoprunepolicy/{policy_uuid}`] command. For example:
608+
+
609+
[source,terminal]
610+
----
611+
$ curl -X PUT -H "Authorization: Bearer <bearer_token>" -H "Content-Type: application/json" -d '{
612+
"method": "creation_date",
613+
"value": "4d",
614+
"tagPattern": "^test.",
615+
"tagPatternMatches": true
616+
}' "https://<quay-server.example.com>/api/v1/user/autoprunepolicy/<uuid>"
617+
----
618+
+
619+
Updating a policy does not return output in the CLI.
620+
512621
. Check your auto-prune policy by entering the following command:
513622
+
514623
[source,terminal]

modules/red-hat-quay-namespace-auto-pruning-overview.adoc

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,30 @@
22
[id="red-hat-quay-namespace-auto-pruning-overview"]
33
= {productname} auto-pruning overview
44

5-
{productname} administrators can set up auto-pruning policies on organizations and repositories; administrators can also set up auto-pruning policies at the registry level so that they apply to all organizations, including all newly created organizations. This feature allows for image tags to be automatically deleted within an organization or a repository based on specified criteria, which allows {productname} organization owners to stay below the storage quota by automatically pruning content.
5+
{productname} administrators can set up multiple auto-pruning policies on organizations and repositories; administrators can also set up auto-pruning policies at the registry level so that they apply to all organizations, including all newly created organizations. This feature allows for image tags to be automatically deleted within an organization or a repository based on specified criteria, which allows {productname} organization owners to stay below the storage quota by automatically pruning content.
66

77
Currently, two policies have been added:
88

99
* **Prune images by the number of tags**. For this policy, when the actual number of tags exceeds the desired number of tags, the oldest tags are deleted by their creation date until the desired number of tags is achieved.
1010
1111
* **Prune image tags by creation date**. For this policy, any tags with a creation date older than the given time span, for example, 10 days, are deleted.
1212
13-
After tags are automatically pruned, they go into the {productname} time machine, or the amount of time, after a tag is deleted, that the tag is accessible before being garbage collected. The expiration time of an image tag is dependent on your organization's settings. For more information, see link:https://access.redhat.com/documentation/en-us/red_hat_quay/3/html-single/manage_red_hat_quay/index#garbage-collection[{productname} garbage collection].
13+
After tags are automatically pruned, they go into the {productname} time machine, or the amount of time, after a tag is deleted, that the tag is accessible before being garbage collected. The expiration time of an image tag is dependent on your organization's settings. For more information, see link:https://access.redhat.com/documentation/en-us/red_hat_quay/{producty}/html-single/manage_red_hat_quay/index#garbage-collection[{productname} garbage collection].
1414

15-
Users can only configure one policy per namespace or repository; this can be done through the {productname} v2 UI. Policies can also be set by using the API endpoints through the command-line interface (CLI).
15+
Users can configure multiple policies per namespace or repository; this can be done through the {productname} v2 UI. Policies can also be set by using the API endpoints through the command-line interface (CLI).
1616

1717
[id="prerequisites-limitations-namespace-autopruning"]
18-
== Prerequisites and limitations for auto-pruning
18+
== Prerequisites and limitations for auto-pruning and multiple policies
1919

2020
The following prerequisites and limitations apply to the auto-pruning feature:
2121

2222
* Auto-pruning is not available when using the {productname} legacy UI. You must use the v2 UI to create, view, or modify auto-pruning policies.
2323

2424
* Auto-pruning is only supported in databases that support the `FOR UPDATE SKIP LOCKED` SQL command.
2525

26-
* Auto-pruning is unavailable on mirrored repositories and read-only repositories.
26+
* Auto-pruning is unavailable on mirrored repositories and read-only repositories.
27+
28+
* If you are configuring multiple auto-prune policies, rules are processed without particular order, and individual result sets are processed immediately before moving on to the next rule.
29+
** For example, if an image is already subject for garbage collection by one rule, it cannot be excluded from pruning by another rule.
30+
31+
* If you have both an auto-pruning policy for an organization and a repository, the auto-pruning policies set at the organization level are executed first.

0 commit comments

Comments
 (0)