summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlejandro Sirgo Rica <asirgo@soleta.eu>2024-09-26 10:21:19 +0200
committerAlejandro Sirgo Rica <asirgo@soleta.eu>2024-09-26 10:21:19 +0200
commit77a60b717af0db3deed845745c39a3fd1e52e6e2 (patch)
tree92581eff4855492539c2f5ad7495dd852875deb6
parent340b7fde54b4f57321e03761125eaefb2d77c684 (diff)
views: check if image fits in cache before /cache/fetch
Check if the image fits in cache before a /cache/fetch request. Report the clients unable to store the image.
-rw-r--r--ogcp/views.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/ogcp/views.py b/ogcp/views.py
index edcc2ab..b41a2bc 100644
--- a/ogcp/views.py
+++ b/ogcp/views.py
@@ -1411,6 +1411,17 @@ def action_image_fetch():
flash(_(f'Image to fetch was not found'), category='error')
return redirect(url_for('commands'))
+ r = server.get('/cache/list', payload={'clients': ips})
+ if not r:
+ return ogserver_down('commands')
+ if r.status_code != requests.codes.ok:
+ return ogserver_error('commands')
+
+ clients_info = r.json()['clients']
+
+ if not image_fits_in_cache(server, clients_info, image):
+ return redirect(url_for('commands'))
+
payload = {'clients': ips,
'repository_id': image['repo_id'],
'type': form.method.data,