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
A dry run supports a maximum of 50,000 Docker images per repository. In this case, an active policy with the same rules will delete all Docker images eligible for deletion.
- In the management console
, select the folder with the registry. - Navigate
to 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 lifecycle policy name.
- In the top-right corner, click
Dry run. Once the test is complete, the Lifecycle dru runs section will contain a line with the policy dry run results. - To get a list of Docker images to delete according to the policy rules, click the line with the policy dry run results.
If you do not have the Yandex Cloud CLI 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: crpn27glo1k8******** lifecycle_policy_id: crp6lg1868p3******** 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 the repository or registry.
-
Get the list of policy dry runs:
yc container repository lifecycle-policy list-dry-run-results crp6lg1868p3********Result:
+----------------------+----------------------+-----------------------+---------------------+ | RESULT ID | LIFECYCLE POLICY ID | AFFECTED IMAGES COUNT | RUN AT | +----------------------+----------------------+-----------------------+---------------------+ | crpn27glo1k8******** | crp6lg1868p3******** | 1 | 2020-05-29 07:30:02 | +----------------------+----------------------+-----------------------+---------------------+ -
Get information about the policy dry run results. Use
RESULT IDfrom the previous step:yc container repository lifecycle-policy get-dry-run-result crpn27glo1k8********Result:
dry_run_lifecycle_policy_result_id: crpn27glo1k8******** lifecycle_policy_id: crp6lg1868p3******** run_at: "2020-05-29T07:30:02.704Z" affected_images_count: "1" -
Get a list of Docker images to delete according to the policy rules. Use
dry_run_lifecycle_policy_result_idfrom the previous step:yc container repository lifecycle-policy list-dry-run-affected-images crpn27glo1k8********Result:
+----------------------+---------------------+-----------------------------+------+-----------------+ | ID | CREATED | NAME | TAGS | COMPRESSED SIZE | +----------------------+---------------------+-----------------------------+------+-----------------+ | crphc7nnrvhl******** | 2019-01-17 17:00:48 | crp2hlbs67tj********/ubuntu | 111 | 64.1 MB | +----------------------+---------------------+-----------------------------+------+-----------------+
To test a lifecycle policy:
- Perform a policy dry run using the DryRun method for the LifecyclePolicyService resource. Specify the policy ID in the
lifecycle_policy_idparameter. You can get the list of policies using the List method for the LifecyclePolicyService resource. - Get a list of policy dry runs using the ListDryRunResults method for the LifecyclePolicyService resource. Specify the policy ID in the
lifecycle_policy_idparameter. - Get information regarding a policy dry run using the GetDryRunResult method for the LifecyclePolicyService resource. In the
dry_run_lifecycle_policy_result_idparameter, specify the ID of the policy dry run results from the previous step. - Get a list of Docker images to delete according to the policy rules. Use the ListDryRunResultAffectedImages method for the LifecyclePolicyService resource. In the
dry_run_lifecycle_policy_result_idparameter, specify the ID of the policy dry run result.