GoogleCloudPlatform / gcr-cleaner

Delete untagged image refs in Google Container Registry or Artifact Registry
Apache License 2.0
805 stars 112 forks source link

Too many images deleted from registry #79

Closed xpicio closed 2 years ago

xpicio commented 2 years ago

Hello, is not the first time that happens, but to be honest i'm not able to reproduce the issue. I tried many times with --dry-run option and the keep and grace parameters are always respected. On the same registry i'm using three different kind of tag version-alpha, version-rc, version-feature-name and for production images just version.

Every day i'm running gcr-cleaner as kubernets's CronJob with the following parameters:

-repo europe-west1-docker.pkg.dev/project-id/container-registry -recursive -tag-filter-all .*-alpha\..* -keep 3 -grace 24h

On the machine-events-srv folder yesterday there were 3 images:

1.4.0-alpha.1-212 built N/A 1.4.0-alpha.2-2 built at 03/03/22 16:33 with kaniko (cache enabled) 1.4.0-alpha.3-3 built at 03/21/22 14:30 with kaniko (cache enabled)

and with the last run of gcr-cleaner alla images has been removed:

2022-04-06 18:18:06.707 CEST Deleting refs since 2022-04-05T16:18:06Z on 60 repo(s)...
2022-04-06 18:18:06.707 CEST {}
....
2022-04-06 18:18:08.200 CEST europe-west1-docker.pkg.dev/project-id/container-registry/machine-events-srv
2022-04-06 18:18:08.524 CEST ✓ 1.4.0-alpha.1-212
2022-04-06 18:18:08.524 CEST ✓ 1.4.0-alpha.2-2
2022-04-06 18:18:08.524 CEST ✓ 1.4.0-alpha.3-3
2022-04-06 18:18:08.524 CEST ✓ sha256:29137bc3f368a7d47d854f70b53b18c713bafcb46b2f9beb7d1d1955fc15d217
2022-04-06 18:18:08.524 CEST ✓ sha256:c4c9b09141b84f595093676a1f86ad57c874272b9d6111e78fd10ab10bd0f0e3
2022-04-06 18:18:08.524 CEST ✓ sha256:c4c9b09141b84f595093676a1f86ad57c874272b9d6111e78fd10ab10bd0f0e3
2022-04-06 18:18:08.524 CEST {}
....

Do you have any suggestions ? Is there something wrong with my cleanup strategy ?

sethvargo commented 2 years ago

Hi @xpicio without seeing your repo layout, it's difficult to say. Could you please use the latest version of gcr-cleaner and set the environment variable GCRCLEANER_LOG=debug? That prints the decision tree which might reveal more details.

xpicio commented 2 years ago

Sure, i will do it

sethvargo commented 2 years ago

Hi there - I'm going to close this due to inactivity. If this is still an occurring, please open a new issue and include the debug log output. If you are running locally as a CLI, set the environment variable GCRCLEANER_LOG=debug. If you are running as a service, set the service environment as GCRCLEANER_LOG=debug and restart the service.