GoogleCloudPlatform / gcr-cleaner

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

Reordering tags #46

Closed bygui86 closed 3 years ago

bygui86 commented 3 years ago

Hi guys, First of all thank you for this amazing tool.

I tested the gcr-clear-cli locally with dry-run flag and I noticed something weird:

Screenshot 2021-09-29 at 10 02 26

After running gcr-cleaner, all tags were reordered because the Uploaded timestamp was updated. Unfortunately I don't have a screenshot of the order before running gcr-cleaner :(

Is this an expected behaviour? Can I prevent this to happen?

To be sure I tried on another repo and the behaviour was not the same, the order of tags remained the same]

Screenshot 2021-09-29 at 10 12 17

Some additional info:

bygui86 commented 3 years ago

I did another test and I noticed that if in the repo there are "numeric tags", gcr-cleaner seems to perform a weird "sorting/reorder".

here you see the situation BEFORE

Screenshot 2021-09-29 at 10 31 48

and here AFTER running gcr-cleaner

Screenshot 2021-09-29 at 10 33 58

and here gcr-cleaner logs


go run ./cmd/gcr-cleaner-cli/main.go -repo eu.gcr.io/*** -dry-run
WARNING: Running in dry run mode! Nothing will actually be cleaned.eu.gcr.io/***: deleting refs since 2021-09-29 08:32:46.018935 +0000 UTC
[dry-run] would delete: eu.gcr.io/***@sha256:89bf4ea21946c3cbfb410d946b16dbe25036502ae70ac4a4239c7c350ac126d2
[dry-run] would delete: eu.gcr.io/***@sha256:dcf92545839cac45f0d2dd262085f562c43c87b7156c45bebad6b03b2d690985
[dry-run] would delete: eu.gcr.io/***@sha256:bb16860b9c44c88dd4fe57979f7d70fd69a47bb9824946d125e27730548be02f
[dry-run] would delete: eu.gcr.io/***@sha256:2eead905735fc4cc8f473eb06b237d6b7db4b00623f7fb59e4f5cf00280606bc
eu.gcr.io/***: successfully deleted 4 refs

is this behaviour expected?

sethvargo commented 3 years ago

The "updated_at" timestamp is changing, which is why you're seeing the items move. If you sort by tag (click on the header) or another column, it should remain consistent. As for why the timestamp is being updated, I'm not entirely sure. I think that's just how the API works.

bygui86 commented 3 years ago

@sethvargo ok probably I got my mistake. In the test done in the previous comment, I added the tags "0.0.1" and "1.0.0" on purpose right before running gcr-cleaner, to see the behaviour of the tool with different kind of tag. After adding them, I didn't refresh the page and I thought the reordering was due to the tool but I was wrong!

Sorry for this issue and thanks for your patience!