Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(aws-cdk/lib/api/garbage-collection): (Garbage collection for ECR prints incorrect number of assets/images deleted and runs indefinitely) #32498

Open
1 task
tainsworth102 opened this issue Dec 12, 2024 · 1 comment
Assignees
Labels
@aws-cdk/aws-ecr Related to Amazon Elastic Container Registry @aws-cdk/core Related to core CDK functionality bug This issue is a bug. investigating This issue is being investigated and/or work is in progress to resolve the issue. p2

Comments

@tainsworth102
Copy link

tainsworth102 commented Dec 12, 2024

Describe the bug

When running cdk gc for ECR, the number of assets is misprinted and the files scanned exceeds the number in the bootstrap repository. This results in the percentage of files scanned exceeding 100.00% and therefore command runs indefinitely. Additionally, images are not being tagged in any attempted run, it is jumping straight to deleting the a random number of unused images which is not reflected in the print statement.

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Version

No response

Expected Behavior

The printed output should have stated:
[100.00%] 136 files scanned: 3 assets (0.56 GiB) tagged, 0 assets (0.00 GiB) deleted.

Current Behavior

[735.29%] 1000 files scanned: 0 assets (0.00 GiB) tagged, 30 assets (5.63 GiB) deleted.
image

The printed output was incorrect and rather than tagging it began deleting straight away.

Reproduction Steps

cdk gc aws://<my-account-id>/<my-only-used-region> --type ecr --unstable=gc --created-buffer-days 0 --action full --confirm=true

Possible Solution

No response

Additional Information/Context

When running this for an account which has an ECR repo with ~8000 images the progression printing is again displayed incorrectly. As the progression cycled and increased with the loop, the number progression progression prints for each progression iteration double and the number of images deleted cumulatively decreases until it deletes no images for each iteration.

CDK CLI Version

2.172.0

Framework Version

No response

Node.js Version

v20.11.1

OS

Ubuntu 22.04.4 LTS

Language

Python

Language Version

No response

Other information

No response

@tainsworth102 tainsworth102 added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Dec 12, 2024
@github-actions github-actions bot added the @aws-cdk/aws-ecr Related to Amazon Elastic Container Registry label Dec 12, 2024
@khushail khushail added investigating This issue is being investigated and/or work is in progress to resolve the issue. p2 @aws-cdk/core Related to core CDK functionality and removed needs-triage This issue or PR still needs to be triaged. labels Dec 13, 2024
@khushail khushail self-assigned this Dec 13, 2024
@khushail
Copy link
Contributor

khushail commented Dec 13, 2024

Hi @tainsworth102 , thanks for reaching out.

Although I did not have those many images, i tried with a small set.Here is a snippet (since I had only 2 images, it asked for deletion and then deleted)-

Screenshot 2024-12-13 at 2 37 49 PM

I assume it should have tagged the image as well as it was not used since long but the Asking part as well as the precentage looks good to me

After going through the CDK Doc for garbage collection, it seems that -

  • create-buffer-days as 0 which means 0 number of days an asset must exist before it is eligible for garbage collection actions.
  • tag – Tags any newly identified unused assets, but doesn’t delete any assets within the range of buffer days that you provide.

So considering these , AFAIU, in your command -
cdk gc aws://<my-account-id>/<my-only-used-region> --type ecr --unstable=gc --created-buffer-days 0 --action full --confirm=true

CDK GC should tag the image which does not seem to be the case.

Will try to repro this scenario with more images and share my findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-ecr Related to Amazon Elastic Container Registry @aws-cdk/core Related to core CDK functionality bug This issue is a bug. investigating This issue is being investigated and/or work is in progress to resolve the issue. p2
Projects
None yet
Development

No branches or pull requests

2 participants