Skip to contentSkip to conversation

How to set a limit and clear Avocado cache?

DISCUSSION Philippe Mathieu-Daudé 2 participants 2 messages Jan 21, 2020 – Jan 22, 2020

lore
Share & tools
lore
#0 lore raw

Hello,

Today I ran out of space in my /home, I ran the 'baobab' tool and while the first bigger directory was obvious to me (~/.ccache), the second wasn't: ~/avocado/data/cache/by_location/, with various GiB.

Note, this directory is not listed in my config...

$ avocado config | fgrep ${HOME}/avocado
$

I might already have asked on qemu-devel mailing list, but is there a way to set a particular location for the cache directory, different than my data directory where I keep the job-results log files?

From the doc, get_cache_dirs() "Returns the list of cache dirs, according to configuration and convention" but doesn't explain how to configure it:
https://avocado-framework.readthedocs.io/en/75.1/api/core/avocado.core.html#avocado.core.data_dir.get_cache_dirs

I searched if there was an Avocado command displaying cache use, and to eventually flush it, like ccache --cleanup/--clear options, but couldn't find any, so I ended calling a rmdir ~/avocado, which I know it is not correct, but saved me some headaches.

Is there a clean way to do this?

I see the clean_tmp_files() function, but no equivalent for the cache:
https://avocado-framework.readthedocs.io/en/75.1/api/core/avocado.core.html#avocado.core.data_dir.clean_tmp_files

Bonus question, can I set a size limit for the cache directory?

Thanks,

Phil.

#1 lore raw

Dne 21. 01. 20 v 10:15 Philippe Mathieu-Daudé napsal(a):

Quoted 10 lines

Hello,

Today I ran out of space in my /home, I ran the 'baobab' tool and while the first bigger directory was obvious to me (~/.ccache), the second wasn't: ~/avocado/data/cache/by_location/, with various GiB.

Note, this directory is not listed in my config...

$ avocado config | fgrep ${HOME}/avocado
$

I might already have asked on qemu-devel mailing list, but is there a way to set a particular location for the cache directory, different than my data directory where I keep the job-results log files?

Hello Philippe,

yes, the cache dirs can be specified in the config files in [datadir.paths] section via cache_dirs = ['/some/location', '/other/location']. The simplest way is to put this to ~/.config/avocado/avocado.conf (or to $VIRTUAL_ENV/.config/avocado/avocado.conf in case you use virtual env).

The default is data_dir/cache (therefor usually ~/avocado/cache) and when it's not specified in the custom cache_dirs it is appended to the list of available cache_dirs. When writing assets we go through the cache_dirs attempting to write them to the first RW location proceeding to the next one.

Quoted 3 lines

From the doc, get_cache_dirs() "Returns the list of cache dirs, according to configuration and convention" but doesn't explain how to configure it:
https://avocado-framework.readthedocs.io/en/75.1/api/core/avocado.core.html#avocado.core.data_dir.get_cache_dirs

PRs are welcome.

Quoted 2 lines

I searched if there was an Avocado command displaying cache use, and to eventually flush it, like ccache --cleanup/--clear options, but couldn't find any, so I ended calling a rmdir ~/avocado, which I know it is not correct, but saved me some headaches.

I'm not aware of any such option, we only support asset expiration and IIRC it only replaces the file on use. Willian do you know if there are any plans for this? Can it be included to the asset handler?

Quoted 7 lines

Is there a clean way to do this?

I see the clean_tmp_files() function, but no equivalent for the cache:
https://avocado-framework.readthedocs.io/en/75.1/api/core/avocado.core.html#avocado.core.data_dir.clean_tmp_files

Bonus question, can I set a size limit for the cache directory?

The same here, shouldn't be hard to add to the asset handler or at least contrib script. (again, PRs welcome)

Quoted 4 lines

Thanks,

Phil.

Regards,
Lukáš