diff options
author | Alejandro Sirgo Rica <asirgo@soleta.eu> | 2024-09-26 10:19:37 +0200 |
---|---|---|
committer | Alejandro Sirgo Rica <asirgo@soleta.eu> | 2024-09-26 10:19:37 +0200 |
commit | 340b7fde54b4f57321e03761125eaefb2d77c684 (patch) | |
tree | 19b70a4b7a05af8b7d13b9405f8090243c711b56 /ogcp | |
parent | ec209480ea6cf287d9e12101ac744cdb22f0ecff (diff) |
views: improve checks for space available in cache
Use the new "free_cache" field in GET /cache/list to check
against the real available space to check if an image fits in
cache.
Diffstat (limited to 'ogcp')
-rw-r--r-- | ogcp/views.py | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/ogcp/views.py b/ogcp/views.py index 5418018..edcc2ab 100644 --- a/ogcp/views.py +++ b/ogcp/views.py @@ -956,20 +956,17 @@ def image_fits_in_cache(server, clients_info, image): for client_info in clients_info: ip = client_info['ip'] - cache_size = int(client_info['cache_size']) - used_cache = 0 + cache_size = client_info['cache_size'] * 1024 has_image = False; for image_info in client_info['images']: - used_cache += int(image_info['size']) - if image_info['checksum'] == image_checksum: has_image = True if has_image: continue - free_cache = cache_size - used_cache + free_cache = client_info['free_cache'] if free_cache < image_size: missing_cache = image_size - free_cache err_report += f'{ip} requires {(missing_cache / (1024 ** 3)):.3f} free GiB<br>' |