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

Wrongly removes conan metadata files #47

Closed
Pro opened this issue Jun 29, 2022 · 2 comments · Fixed by #52
Closed

Wrongly removes conan metadata files #47

Pro opened this issue Jun 29, 2022 · 2 comments · Fixed by #52

Comments

@Pro
Copy link
Contributor

Pro commented Jun 29, 2022

Thank you for your awesome tool!

We would like to use it for cleaning up a conan repository.

When the conan client deploys a package, it uploads:

  • conan_package.tgz

At the same time, the server side generates some metadata (see also conan-io/conan#8418)

  • .timestamp
  • index.json

When dowloading a conan package, it only downloads package.tar.gz, but not the additional meta files.

If I now run the rules.delete_not_used_since(days=60), rule on packages which were deployed before 60 days, but still regularly downloaded, it will delete the meta files, but keep the conan_package.tgz file. A conan package download does not trigger the download counter on the metadata files.

And this will invalidate the whole conan package (as also mentioned here jfrog/artifactory-user-plugins#319).

One solution would be to use rules.exclude_filename(['.timestamp', 'index.json']) (also suggested here jfrog/artifactory-user-plugins#399).
This would then only delete the package, but not the metadata. And therefore, the metadata is never cleaned up... So also not the perfect solution.

Do you have any suggestions how to handle this?
I guess to solve this we would need dedicated rules just for conan, similar to the docker rules?

There may also other package types affected by this (e.g., npm, pypi, conda, debian, ...), see also jfrog/artifactory-user-plugins#319 (comment)

@Pro
Copy link
Contributor Author

Pro commented Jun 29, 2022

I found a solution:

  1. Delete any conan files, but keep the metadata
  2. Delete all directories which only contain metadata files and nothing else

This can be achieved like this, considering that you apply the MR proposed in #48

RULES = [

    # ------ ALL REPOS --------
    CleanupPolicy(
       'Delete files older than 60 days',
        rules.repo('conan-testing'),
        rules.delete_not_used_since(days=60),
        # Make sure to keep conan metadata. See also
        # https://github.com/devopshq/artifactory-cleanup/issues/47
        rules.exclude_filename(['.timestamp', 'index.json']),
    ),
    CleanupPolicy(
       'Delete empty folders',
        rules.repo('conan-testing'),
        rules.delete_empty_folder(),
        # Exclude metadata files. I.e., if a folder only contains these files, consider it as
        # empty
        rules.exclude_filename(['.timestamp', 'index.json']),
    ),
]

@allburov
Copy link
Member

I like the workaround! Let's add it to FAQ section in readme to help other conan's users after #48

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

Successfully merging a pull request may close this issue.

2 participants