Testing a lifecycle policy
A dry run helps verify which Docker images meet lifecycle policy rules. Docker images are not actually deleted during dry runs.
Warning
The maximum number of Docker images in a single repository that a single dry run can verify is 50,000. In this case, an active policy with the same rules deletes all Docker images that are suitable for deletion.
- In the management console
, select the folder where the registry was created. - In the list of services, select Container Registry.
- Select the registry and click the row with its name.
- Select the repository and click the row with its name.
- In the left-hand panel, click Lifecycle.
- Click the name of the lifecycle policy you need.
- In the top-right corner, click Test. Once the test is completed, the Lifecycle dry runs section will contain a line with the policy dry run results.
- To get a list of Docker images to be deleted according to the policy rules, click the line with the policy dry run results.
If you don't have the Nebius Israel command line interface yet, install and initialize it.
To test a lifecycle policy:
-
Perform a dry run of the policy:
yc container repository lifecycle-policy dry-run <policy ID>
Result:
dry_run_lifecycle_policy_result_id: crpn27glo1k8r81dveq2 lifecycle_policy_id: crp6lg1868p3i0emkv1b run_at: "2020-05-29T07:30:02.704Z" affected_images_count: "1"
To find out the policy ID, get a list of lifecycle policies in a repository or registry.
-
Get a list of policy dry runs:
yc container repository lifecycle-policy list-dry-run-results crp6lg1868p3i0emkv1b
Result:
+----------------------+----------------------+-----------------------+---------------------+ | RESULT ID | LIFECYCLE POLICY ID | AFFECTED IMAGES COUNT | RUN AT | +----------------------+----------------------+-----------------------+---------------------+ | crpn27glo1k8r81dveq2 | crp6lg1868p3i0emkv1b | 1 | 2020-05-29 07:30:02 | +----------------------+----------------------+-----------------------+---------------------+
-
Get information about the results of the policy dry run. Use the
RESULT ID
parameter from the previous item:yc container repository lifecycle-policy get-dry-run-result crpn27glo1k8r81dveq2
Result:
dry_run_lifecycle_policy_result_id: crpn27glo1k8r81dveq2 lifecycle_policy_id: crp6lg1868p3i0emkv1b run_at: "2020-05-29T07:30:02.704Z" affected_images_count: "1"
-
Get a list of Docker images to be deleted according to the policy rules. Use the
dry_run_lifecycle_policy_result_id
parameter from the previous item:yc container repository lifecycle-policy list-dry-run-affected-images crpn27glo1k8r81dveq2
Result:
+----------------------+---------------------+-----------------------------+------+-----------------+ | ID | CREATED | NAME | TAGS | COMPRESSED SIZE | +----------------------+---------------------+-----------------------------+------+-----------------+ | crphc7nnrvhlg73oeiv5 | 2019-01-17 17:00:48 | crp2hlbs67tj4ggrfodb/ubuntu | 111 | 64.1 MB | +----------------------+---------------------+-----------------------------+------+-----------------+
To test a lifecycle policy:
- Perform a policy dry run using the DryRun method of the LifecyclePolicyService resource. In the
lifecycle_policy_id
parameter, specify a policy ID. You can retrieve a list of policies using the List method for the LifecyclePolicyService resource. - Retrieve a list of policy dry runs using the ListDryRunResults method for the LifecyclePolicyService resource. In the
lifecycle_policy_id
parameter, specify a policy ID. - Retrieve information regarding a policy dry run using the GetDryRunResult method for the LifecyclePolicyService resource. In the
dry_run_lifecycle_policy_result_id
parameter, specify the ID of the policy dry run results from the previous item. - Get a list of Docker images to be deleted according to the policy rules. Use the ListDryRunResultAffectedImages method for the LifecyclePolicyService resource. In the
dry_run_lifecycle_policy_result_id
parameter, specify the ID of the policy dry run results.