Commit 6c84bdd4 authored by Daniele Venzano's avatar Daniele Venzano

Implement disk quotas (only for CEPHFS, disabled by default)

parent 3dcdd65c
......@@ -15,9 +15,14 @@
"""Main points of entry for the Zoe web interface."""
import os
import subprocess
from zoe_api.web.request_handler import ZoeWebRequestHandler
from zoe_api.auth.base import BaseAuthenticator
import zoe_lib.config
class RootWeb(ZoeWebRequestHandler):
"""Handler class"""
......@@ -100,10 +105,26 @@ class HomeWeb(ZoeWebRequestHandler):
total_memory = sum([r.memory.min for r in running_reservations])
total_cores = sum([r.cores.min for r in running_reservations])
if zoe_lib.config.get_conf().enable_cephfs_quotas:
try:
disk_quota = subprocess.check_output(['sudo', '/usr/bin/getfattr', '-n', 'ceph.quota.max_bytes', os.path.join(zoe_lib.config.get_conf().workspace_base_path, zoe_lib.config.get_conf().workspace_deployment_path, self.current_user.username)])
except subprocess.CalledProcessError:
disk_quota = -1
disk_usage = -1
else:
disk_quota = int(disk_quota.decode('utf-8').split('=')[1].lstrip('"').strip().rstrip('"'))
disk_usage = os.stat(os.path.join(zoe_lib.config.get_conf().workspace_base_path, zoe_lib.config.get_conf().workspace_deployment_path, self.current_user.username)).st_size
else:
disk_quota = -1
disk_usage = -1
template_vars = {
"total_memory": total_memory,
"total_cores": total_cores,
'last_executions': sorted(last_executions, key=lambda e: e.id),
'running_executions': sorted(last_running_executions, key=lambda e: e.id)
'running_executions': sorted(last_running_executions, key=lambda e: e.id),
'disk_quota': disk_quota,
'disk_usage': disk_usage
}
self.render('home_user.jinja2', **template_vars)
......@@ -23,6 +23,9 @@
<li>{{ running_executions|length }} of {{ user.quota.concurrent_executions }} running execution{{ "s" if user.quota.concurrent_executions > 1 }}</li>
<li><script>format_bytes({{ total_memory }}, 2);</script> of <script>format_bytes({{ user.quota.memory }}, 2);</script> of memory</li>
<li>{{ total_cores }} of {{ user.quota.cores }} cores</li>
{% if disk_quota > -1 %}
<li><script>format_bytes({{ disk_usage }}, 2)</script> of <script>format_bytes({{ disk_quota }}, 2)</script> of disk space</li>
{% endif %}
<li>Executions will be automatically killed after <script>document.write(moment.duration({{ user.quota.runtime_limit }}, "hours").humanize())</script></li>
</ul>
......
......@@ -114,6 +114,7 @@ def load_configuration(test_conf=None):
argparser.add_argument('--max-memory-limit', help='Maximum amount of memory services can use (in GiB)', type=int, default=64)
argparser.add_argument('--additional-volumes', help='Additional volumes to mount in services filesystems. (ex: /mnt/data:data,/mnt/data_n:data_n)', default='')
argparser.add_argument('--enable-plots', action='store_true', help='Enable generation of URLs to Grafana')
argparser.add_argument('--enable-cephfs-quotas', action='store_true', help='Enable reading cephfs quotas (needs sudo configuration)')
opts = argparser.parse_args()
if opts.debug:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment