Skip to content

Commit 6f61038

Browse files
stevsmitSteven Smith
andauthored
Adds multiple auto-pruning policies info (quay#1119) (quay#1121)
* Adds multiple auto-pruning policies info (quay#1119) Co-authored-by: Steven Smith <[email protected]> * Updates a few API commands --------- Co-authored-by: Steven Smith <[email protected]>
1 parent cf86978 commit 6f61038

File tree

3 files changed

+74
-119
lines changed

3 files changed

+74
-119
lines changed

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

Lines changed: 41 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ $ podman push <quay-server.example.com>/<quayadmin>/busybox:test4
119119

120120
. By default, the auto-pruner worker at the registry level runs every 24 hours. After 24 hours, the two oldest image tags are removed, leaving the `test3` and `test4` tags if you followed these instructions. Check your {productname} organization to ensure that the two oldest tags were removed.
121121

122-
123122
[id="creating-policy-v2-ui"]
124123
== Creating an auto-prune policy for an organization by using the {productname} v2 UI
125124

@@ -128,55 +127,10 @@ Use the following procedure to create an auto-prune policy for an organization u
128127
.Prerequisites
129128

130129
* You have enabled the `FEATURE_AUTO_PRUNE` feature.
130+
* Your organization has image tags that have been pushed to it.
131131

132132
.Procedure
133133

134-
. Tag four sample images, for example, `busybox`, that will be pushed to the repository with auto-pruning enabled. For example:
135-
+
136-
[source,terminal]
137-
----
138-
$ podman tag docker.io/library/busybox <quay-server.example.com>/<quayadmin>/busybox:test
139-
----
140-
+
141-
[source,terminal]
142-
----
143-
$ podman tag docker.io/library/busybox <quay-server.example.com>/<quayadmin>/busybox:test2
144-
----
145-
+
146-
[source,terminal]
147-
----
148-
$ podman tag docker.io/library/busybox <quay-server.example.com>/<quayadmin>/busybox:test3
149-
----
150-
+
151-
[source,terminal]
152-
----
153-
$ podman tag docker.io/library/busybox <quay-server.example.com>/<quayadmin>/busybox:test4
154-
----
155-
156-
. Push the four sample images, for example, `busybox`, to the repository with auto-pruning enabled by entering the following commands:
157-
+
158-
[source,terminal]
159-
----
160-
$ podman push <quay-server.example.com>/quayadmin/busybox:test
161-
----
162-
+
163-
[source,terminal]
164-
----
165-
$ podman push <quay-server.example.com>/<quayadmin>/busybox:test2
166-
----
167-
+
168-
[source,terminal]
169-
----
170-
$ podman push <quay-server.example.com>/<quayadmin>/busybox:test3
171-
----
172-
+
173-
[source,terminal]
174-
----
175-
$ podman push <quay-server.example.com>/<quayadmin>/busybox:test4
176-
----
177-
178-
. Check that there are four tags in your repository.
179-
180134
. On the {productname} v2 UI, click *Organizations* in the navigation pane.
181135

182136
. Select the name of an organization that you will apply the auto-pruning feature to, for example, `test_organization`.
@@ -191,15 +145,24 @@ image:auto-prune-policies-page.png[Auto-Prune Policies page]
191145

192146
. 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*.
193147

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$`.
148+
. Optional. With the introduction of _regular expressions_, you are provided the following options to fine-grain your auto-pruning policy:
149+
+
150+
* *Match*: When selecting this option, the auto-pruner prunes all tags that match the given _regex_ pattern.
151+
* *Does not match*: When selecting this option, the auto-pruner prunes all tags that _do not_ match the _regex_ pattern.
152+
+
153+
If you do not select an option, the auto-pruner defaults to pruning all image tags.
154+
+
155+
For this example, 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.*`.
195156

196157
. Optional. You can create a second auto-prune policy by clicking *Add Policy* and entering the required information.
197158

198-
. Click *Save*. A notification that your auto-prune policy has been updated appears.
159+
. Click *Save*. A notification that your auto-prune policy has been updated appears.
160+
+
161+
With this example, the organization is configured to keep the three latest tags that are named `^test.*`.
199162

200163
.Verification
201164

202-
* Navigate to the *Tags* page of your Organization's repository. With this example, tags are marked for deletion starting from the tag's oldest creation date. After a few minutes, the auto-pruner worker removes tags that no longer fit within the established criteria. In this example, it removes the `busybox:test` tag, and keeps the `busybox:test2`, `busybox:test3`, and `busybox:test4` tag.
165+
* Navigate to the *Tags* page of your Organization's repository. After a few minutes, the auto-pruner worker removes tags that no longer fit within the established criteria. In this example, it removes the `busybox:test` tag, and keeps the `busybox:test2`, `busybox:test3`, and `busybox:test4` tag.
203166
+
204167
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].
205168

@@ -248,10 +211,11 @@ $ curl -X POST \
248211
"method": "creation_date",
249212
"value": "7d",
250213
"tagPattern": "^v*",
251-
"tagPatternMatches": true
214+
"tagPatternMatches": <true> <1>
252215
}' \
253216
"https://<quay-server.example.com>/api/v1/organization/<organization_name>/autoprunepolicy/"
254217
----
218+
<1> Setting `tagPatternMatches` to `true` makes it so that tags that match the given regex pattern will be pruned. In this example, tags that match `^v*` are pruned.
255219
+
256220
.Example output
257221
+
@@ -317,7 +281,7 @@ The use of `/user/` in the following commands represents the user that is curren
317281
+
318282
[source,terminal]
319283
----
320-
$ curl -X POST -H "Authorization: Bearer <access_token>" -H "Content-Type: application/json" -d '{"method": "number_of_tags", "value": 10}' http://<quay-server.example.com>/api/v1/<user>/autoprunepolicy/
284+
$ curl -X POST -H "Authorization: Bearer <access_token>" -H "Content-Type: application/json" -d '{"method": "number_of_tags", "value": 10}' http://<quay-server.example.com>/api/v1/user/autoprunepolicy/
321285
----
322286
+
323287
.Example output
@@ -331,14 +295,14 @@ $ curl -X POST -H "Authorization: Bearer <access_token>" -H "Content-Type: appli
331295
+
332296
[source,terminal]
333297
----
334-
$ curl -X GET -H "Authorization: Bearer <access_token>" http://<quay-server.example.com>/api/v1/<user>/autoprunepolicy/8c03f995-ca6f-4928-b98d-d75ed8c14859
298+
$ curl -X GET -H "Authorization: Bearer <access_token>" http://<quay-server.example.com>/api/v1/user/autoprunepolicy/
335299
----
336300
+
337301
Alternatively, you can include the UUID:
338302
+
339303
[source,terminal]
340304
----
341-
$ curl -X GET -H "Authorization: Bearer <access_token>" http://<quay-server.example.com>/api/v1/<user>/autoprunepolicy/
305+
$ curl -X GET -H "Authorization: Bearer <access_token>" http://<quay-server.example.com>/api/v1/user/autoprunepolicy/8c03f995-ca6f-4928-b98d-d75ed8c14859
342306
----
343307
+
344308
.Example output
@@ -352,7 +316,7 @@ $ curl -X GET -H "Authorization: Bearer <access_token>" http://<quay-server.exam
352316
+
353317
[source,terminal]
354318
----
355-
$ curl -X DELETE -H "Authorization: Bearer <access_token>" http://<quay-server.example.com>/api/v1/<user>/autoprunepolicy/8c03f995-ca6f-4928-b98d-d75ed8c14859
319+
$ curl -X DELETE -H "Authorization: Bearer <access_token>" http://<quay-server.example.com>/api/v1/user/autoprunepolicy/8c03f995-ca6f-4928-b98d-d75ed8c14859
356320
----
357321
+
358322
.Example output
@@ -370,55 +334,10 @@ Use the following procedure to create an auto-prune policy for a repository usin
370334
.Prerequisites
371335

372336
* You have enabled the `FEATURE_AUTO_PRUNE` feature.
337+
* You have pushed image tags to your repository.
373338

374339
.Procedure
375340

376-
. Tag four sample images, for example, `busybox`, that will be pushed to the repository with auto-pruning enabled. For example:
377-
+
378-
[source,terminal]
379-
----
380-
$ podman tag docker.io/library/busybox <quay-server.example.com>/<organization_name>/<repository_name>:test
381-
----
382-
+
383-
[source,terminal]
384-
----
385-
$ podman tag docker.io/library/busybox <quay-server.example.com>/<organization_name>/<repository_name>:test2
386-
----
387-
+
388-
[source,terminal]
389-
----
390-
$ podman tag docker.io/library/busybox <quay-server.example.com>/<organization_name>/<repository_name>:test3
391-
----
392-
+
393-
[source,terminal]
394-
----
395-
$ podman tag docker.io/library/busybox <quay-server.example.com>/<organization_name>/<repository_name>:test4
396-
----
397-
398-
. Push the four sample images, for example, `busybox`, to the repository with auto-pruning enabled by entering the following commands:
399-
+
400-
[source,terminal]
401-
----
402-
$ podman push <quay-server.example.com>/<organization_name>/<repository_name>:test
403-
----
404-
+
405-
[source,terminal]
406-
----
407-
$ podman push <quay-server.example.com>/<organization_name>/<repository_name>:test2
408-
----
409-
+
410-
[source,terminal]
411-
----
412-
$ podman push <quay-server.example.com>/<organization_name>/<repository_name>:test3
413-
----
414-
+
415-
[source,terminal]
416-
----
417-
$ podman push <quay-server.example.com>/<organization_name>/<repository_name>:test4
418-
----
419-
420-
. Check that there are four tags in your repository.
421-
422341
. On the {productname} v2 UI, click *Repository* in the navigation pane.
423342

424343
. Select the name of an organization that you will apply the auto-pruning feature to, for example, `<organization_name>/<repository_name>`.
@@ -427,19 +346,26 @@ $ podman push <quay-server.example.com>/<organization_name>/<repository_name>:te
427346

428347
. Click *Repository Auto-Prune Policies*.
429348

430-
. Click the drop down menu and select the desired policy, for example, *By number of tags*.
349+
. Click the drop down menu and select the desired policy, for example, *By age of tags*.
431350

432-
. 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*.
351+
. Set a time, for example, `5` and an interval, for example `minutes` to delete tags older than the specified time frame. For this example, tags older than 5 minutes are marked for deletion.
433352

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$`.
353+
. Optional. With the introduction of _regular expressions_, you are provided the following options to fine-grain your auto-pruning policy:
354+
+
355+
* *Match*: When selecting this option, the auto-pruner prunes all tags that match the given _regex_ pattern.
356+
* *Does not match*: When selecting this option, the auto-pruner prunes all tags that _do not_ match the _regex_ pattern.
357+
+
358+
If you do not select an option, the auto-pruner defaults to pruning all image tags.
359+
+
360+
For this example, click the *Tag pattern* box and select *Does not match*. In the _regex_ box, enter a pattern to match tags against. For example, to automatically prune all tags that _do not_ match the `test` tag, enter `^test.*`.
435361

436362
. Optional. You can create a second auto-prune policy by clicking *Add Policy* and entering the required information.
437363

438364
. Click *Save*. A notification that your auto-prune policy has been updated appears.
439365

440366
.Verification
441367

442-
* Navigate to the *Tags* page of your Organization's repository. With this example, tags are marked for deletion starting from the tag's oldest creation date. After a few minutes, the auto-pruner worker removes tags that no longer fit within the established criteria. In this example, it removes the `busybox:test` tag, and keeps the `busybox:test2`, `busybox:test3`, and `busybox:test4` tag.
368+
* Navigate to the *Tags* page of your Organization's repository. With this example, Tags that are older than 5 minutes that _do not_ match the `^test.*` _regex_ tag are automatically pruned when the pruner runs.
443369
+
444370
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].
445371

@@ -488,10 +414,11 @@ $ curl -X POST \
488414
"method": "<creation_date>",
489415
"value": "<7d>",
490416
"tagPattern": "<^test.>*",
491-
"tagPatternMatches": <true>
417+
"tagPatternMatches": <false> <1>
492418
}' \
493-
"https://<quay-server.example.com>/api/v1/repository/<organization_name>/<repository_name>/<tag_name>/autoprunepolicy/"
419+
"https://<quay-server.example.com>/api/v1/repository/<organization_name>/<repository_name>/autoprunepolicy/"
494420
----
421+
<1> Setting `tagPatternMatches` to `false` makes it so that tags that all tags that _do not_ match the given regex pattern are pruned. In this example, all tags _but_ `^test.` are pruned.
495422
+
496423
.Example output
497424
+
@@ -567,11 +494,11 @@ You can use {productname} API endpoints to manage auto-pruning policies on a rep
567494

568495
.Procedure
569496

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:
497+
. 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/repository/<user_account>/<user_repository>/autoprunepolicy/`] command create a new policy that limits the number of tags for the user:
571498
+
572499
[source,terminal]
573500
----
574-
$ curl -X POST -H "Authorization: Bearer <access_token>" -H "Content-Type: application/json" -d '{"method": "number_of_tags","value": 2}' http://<quay-server.example.com>/api/v1/repository/<user_account>/<user_repository>/autoprunepolicy/
501+
$ curl -X POST -H "Authorization: Bearer <access_token>" -H "Content-Type: application/json" -d '{"method": "number_of_tags","value": 2}' https://<quay-server.example.com>/api/v1/repository/<user_account>/<user_repository>/autoprunepolicy/
575502
----
576503
+
577504
.Example output
@@ -594,7 +521,7 @@ $ curl -X POST \
594521
"tagPattern": "^v*",
595522
"tagPatternMatches": true
596523
}' \
597-
"https://<quay-server.example.com>/api/v1/user/autoprunepolicy/"
524+
"http://<quay-server.example.com>/api/v1/repository/<user_account>/<user_repository>/autoprunepolicy/"
598525
----
599526
+
600527
.Example output
@@ -604,7 +531,7 @@ $ curl -X POST \
604531
{"uuid": "b3797bcd-de72-4b71-9b1e-726dabc971be"}
605532
----
606533

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:
534+
. 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/repository/<user_account>/<user_repository>/autoprunepolicy/<policy_uuid>`] command. For example:
608535
+
609536
[source,terminal]
610537
----
@@ -613,7 +540,7 @@ $ curl -X PUT -H "Authorization: Bearer <bearer_token>" -H "Content-Type: ap
613540
"value": "4d",
614541
"tagPattern": "^test.",
615542
"tagPatternMatches": true
616-
}' "https://<quay-server.example.com>/api/v1/user/autoprunepolicy/<uuid>"
543+
}' "https://<quay-server.example.com>/api/v1/repository/<user_account>/<user_repository>/autoprunepolicy/<policy_uuid>"
617544
----
618545
+
619546
Updating a policy does not return output in the CLI.
@@ -643,12 +570,12 @@ $ curl -X GET -H "Authorization: Bearer <access_token>" http://<quay-server.exam
643570
+
644571
[source,terminal]
645572
----
646-
$ curl -X DELETE -H "Authorization: Bearer <access_token>" http://<quay-server.example.com>/api/v1/user/autoprunepolicy/7726f79c-cbc7-490e-98dd-becdc6fefce7
573+
$ curl -X DELETE -H "Authorization: Bearer <access_token>" http://<quay-server.example.com>/api/v1/repository/<user_account>/<user_repository>/autoprunepolicy/<policy_uuid>
647574
----
648575
+
649576
.Example output
650577
+
651578
[source,terminal]
652579
----
653580
{"uuid": "7726f79c-cbc7-490e-98dd-becdc6fefce7"}
654-
----
581+
----

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Currently, two policies have been added:
1212
1313
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 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).
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"]
1818
== Prerequisites and limitations for auto-pruning and multiple policies
@@ -28,4 +28,16 @@ The following prerequisites and limitations apply to the auto-pruning feature:
2828
* 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.
2929
** For example, if an image is already subject for garbage collection by one rule, it cannot be excluded from pruning by another rule.
3030

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.
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.
32+
33+
[id="autopruning-regular-expressions"]
34+
== Regular expressions with auto-pruning
35+
36+
{productname} administrators can leverage _regular expressions_, or _regex_, to match a subset of tags for both organization- and repository-level auto-pruning policies. This provides more granular auto-pruning policies to target only certain image tags for removal. Consider the following when using _regular expressions_ with the auto-pruning feature:
37+
38+
* _Regular expressions_ are optional.
39+
* If a _regular expression_ is not provided, the auto-pruner defaults to pruning all image tags in the organization or the repository. These are user-supplied and must be protected against ReDOS attacks.
40+
* Registry-wide policies do not currently support _regular expressions_. Only organization- and repository-level auto-pruning policies support _regular expressions_.
41+
* _Regular expressions_ can be configured to prune images that either do, or _do not_, match the provided _regex_ pattern.
42+
43+
Some of the following procedures provide example auto-pruning policies using _regular expressions_ that you can use as a reference when creating an auto-prune policy.

0 commit comments

Comments
 (0)