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

Add a tag to skip caching for a task #256

Open
ZXCroon opened this issue Jun 4, 2021 · 1 comment
Open

Add a tag to skip caching for a task #256

ZXCroon opened this issue Jun 4, 2021 · 1 comment
Labels
enhancement New feature or request UX Improve user experience

Comments

@ZXCroon
Copy link

ZXCroon commented Jun 4, 2021

There are cases where I want to avoid caching a task. This happens if this task is just a "debug" task, which I don't want ansible-bender to spend a lot of time doing caching for the task. And we don't want to cache it also because I want it to be executed for every run for debugging purpose. Another example is "set_fact" or any kinds of tasks that register a variable. I want to avoid caching for these tasks, because if it is cached and skipped, the variable will not be set which is wrong.

Note that this is different than no-cache or stop-layering, which will stop caching for all following tasks.

I think the implementation is easy (at least from my experiment). Just add a tag like SKIP_CACHE_TAG=skip-cache. And in snapshoter.py, add

if SKIP_CACHE_TAG in getattr(task, "tags", []):
    return

into both _maybe_load_from_cache and _snapshot functions. I can also create the MR. Just want to make sure you are ok with this enhancement

@TomasTomecek
Copy link
Collaborator

Thank you for your time submitting this request!

If what you imply is skipping caching of one task and continue further with the caching process: I don't think this is a good idea because one could get inconsistent results easily or even weird errors which won't make sense.

On the other hand, I understand the request and would accept such a pull request with a big fat disclaimer in the docs about the consequences of this behaviour :)

@TomasTomecek TomasTomecek added enhancement New feature or request UX Improve user experience labels Jun 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request UX Improve user experience
Projects
None yet
Development

No branches or pull requests

2 participants