Skip to content

Add ability to remove keys by type or API call #85

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

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

porunov
Copy link

@porunov porunov commented Dec 28, 2024

This PR adds keys eviction strategy by specified keys "type" (key prefix).
Additionally, this PR adds a custom endpoint which can be used to clear all keys associated with specific prefix (useful for PR closing events or other types of events which indicate that some keys won't be used anymore).

This functionality was tested manually on self-hosted GitHub runners.
Migration is not needed for these features to work.
See updated documentation for more information: docs/content/1.getting-started/1.index.md

Fixes #79
Partially related to #74

@porunov porunov force-pushed the feature/keys-eviction-options branch from 1a0d5d8 to 6db0282 Compare December 28, 2024 20:05
@porunov porunov changed the title Add ability to remove keys by type of API call Add ability to remove keys by type or API call Dec 28, 2024
@porunov porunov force-pushed the feature/keys-eviction-options branch from 6db0282 to 8363583 Compare December 28, 2024 21:00
@porunov porunov force-pushed the feature/keys-eviction-options branch from 8363583 to e940ac8 Compare April 23, 2025 23:49
@porunov
Copy link
Author

porunov commented Apr 23, 2025

@LouisHaftmann @DrJume let me know if you think these features are viable or you would prefer seeing it differently. Thank you!

@porunov porunov force-pushed the feature/keys-eviction-options branch from e940ac8 to 922234e Compare April 24, 2025 03:15
Fixes falcondev-oss#79
Partially related to falcondev-oss#74

Signed-off-by: Oleksandr Porunov <[email protected]>
@porunov porunov force-pushed the feature/keys-eviction-options branch from 922234e to 6840204 Compare April 24, 2025 17:19
@LouisHaftmann LouisHaftmann self-requested a review April 25, 2025 08:45
If enabled then any specifically structured keys will be automatically removed if there are more keys of such type than
the amount specified via `MAX_STORED_KEYS_PER_TYPE`.
Key type is defined by the following format:
`{key_type}{TYPED_KEY_DELIMITER}{optional custom string}`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of the optional custom string?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably take the same params as the GET _apis/artifactcache/cache route:

  • keys
  • optional version

I would also prefer a route name like /extra/caches/prune

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of adding more functions for the different methods of pruning caches, I would just add filter functionality to the existing pruneCaches function. This file now also has many untyped functions which should be avoided.

If `ENABLE_TYPED_KEY_PREFIX_REMOVAL` is `true` then this is the maximum amount of the most recent keys to keep per key type.
Any other older keys will be automatically removed.

#### `TYPED_KEY_DELIMITER`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe cache keys cannot contain , so we could just use it as a delimiter

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

Successfully merging this pull request may close these issues.

How to remove specific cache key?
2 participants