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

With version 1.5.0 images are no longer deleted #41

Closed
lokigin opened this issue Aug 15, 2022 · 11 comments
Closed

With version 1.5.0 images are no longer deleted #41

lokigin opened this issue Aug 15, 2022 · 11 comments

Comments

@lokigin
Copy link

lokigin commented Aug 15, 2022

The following still worked up to version 1.4.2, with version 1.5.0 images are no longer deleted:

  delete-older-images:
    name: Delete older ghcr images
    runs-on: ubuntu-latest
    steps:
      - name: Delete images
        uses: snok/container-retention-policy@v1
        with:
          image-names: repo/imagename
          cut-off: now UTC+1
          account-type: org
          org-name: my-org
          keep-at-least: 2
          skip-tags: latest
          token: ${{ secrets.PAT }}

Note: There is no log output or error message

@sondrelg
Copy link
Member

Huh, that's unfortunate. Are your workflow runs private, or could you link me one?

These are all the changes since v1.4.2: https://github.com/snok/container-retention-policy/compare/main..3e6a692f35a6d52db6fde535877fe2fd379dfcb4

@lokigin
Copy link
Author

lokigin commented Aug 15, 2022

@sondrelg
Copy link
Member

That's really helpful, thanks!

Looking at the changes from 1.4.2 again I wonder if there might be a problem with main.py line 409, or something like that.

My own projects seem to work fine on v1.5.0, and I'm guessing the only relevant difference between the two is that your image name contains a / while mine don't.

I won't have time to look at this properly for at least a few days, but if you have time, I'd consider calling the Github API directly to see what data you're receiving and whether the fnmatch logic needs to be adjusted to account for special characters. If you figure anything out, a PR is of course very welcome 🙂

The docs can be found here and here is the relevant code from the action 👍

@lukasz-mitka
Copy link
Contributor

@eickehnn how many packages do you have?
Try using @main it contains #44 which was a workaround for me.
Full fix will be done in #42.

@lokigin
Copy link
Author

lokigin commented Sep 15, 2022

In the current example, it's one image with currently four versions that should be reduced to two. I try it with main and the both latest commits from pr42 and pr44, but the issues is still there.

@lukasz-mitka
Copy link
Contributor

I didn't read sondrelg comment carefully before, he is definitely right. Things I have mentioned won't work in your case, sorry.

@den-is
Copy link
Contributor

den-is commented Oct 18, 2022

In my case / doesn't interfere with the action.
Tested this action python code locally. version and images show up just fine.
In my case, the problem is that I have more than 100 images, and images that require deleting are "deep" in the list.
Waiting for this PR to be merged: #42

@andreykaipov
Copy link

I made a test example: https://github.com/eickehnn/container-retention-policy-test

I think the issue in the example is it's using ${{ github.repository }} to search for the image names. But this variable actually expands to owner/repo.

This was my issue too, since I had wrongly assumed my username was part of the image name. But after checking the API, the name was... you know, the actual name:

gh api /users/andreykaipov/packages?package_type=container | jq -r .[].name
goobs

In hindsight that makes more sense than including the username. I ended up using ${{ github.event.repository.name }} as the image names to search for, so I could parametrize the policy to the repo name my workflow is in (since my image name is just the repo name).

Since the example pushes to ghcr.io/${{ github.repository }}/alpine-test, the image names to search for should actually be ${{ github.event.repository.name }}/alpine-test, where ${{ github.event.repository.name }} is the repo in owner/repo.

@lokigin
Copy link
Author

lokigin commented Dec 21, 2022

Change the variables from ${{ github.repository }} to ${{ github.event.repository.name }} or replacing them with absolute values makes no difference, the images in this example are not deleted with version 1.5.0, but with version 1.4.2 they are.

@fabricio-bastian
Copy link

I have the same issue with 1.5.0. Is this issue fixed in 1.5.1?

@sondrelg
Copy link
Member

The suggestions above seem to indicate that it's caused by an image name mismatch. I'll close this for now, under that assumption, since we've not otherwise been able to replicate 🙂 Feel free to reopen if anyone has new information

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants