Skip to content

Commit 2c4479d

Browse files
committed
Display disk usage for transient-storage based clusters on the main CloudMan page
1 parent 01dd527 commit 2c4479d

File tree

2 files changed

+32
-20
lines changed

2 files changed

+32
-20
lines changed

cm/controllers/root.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -857,9 +857,7 @@ def instance_state_json(self, trans, no_json=False):
857857
'instance_status': {'idle': str(len(self.app.manager.get_idle_instances())),
858858
'available': str(self.app.manager.get_num_available_workers()),
859859
'requested': str(len(self.app.manager.worker_instances))},
860-
'disk_usage': {'used': str(self.app.manager.disk_used),
861-
'total': str(self.app.manager.disk_total),
862-
'pct': str(self.app.manager.disk_pct)},
860+
'disk_usage': self.app.manager.check_disk(),
863861
'data_status': self.app.manager.get_data_status(),
864862
'app_status': self.app.manager.get_app_status(),
865863
'cluster_storage_type': self.app.manager.cluster_storage_type,

cm/master.py

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ def __init__(self, app):
6060
# This initialization is applicable only when restarting a cluster.
6161
self.worker_instances = self.get_worker_instances() if (
6262
self.app.cloud_type == 'ec2' or self.app.cloud_type == 'openstack') else []
63-
self.disk_total = "0"
64-
self.disk_used = "0"
65-
self.disk_pct = "0%"
6663
self.manager_started = False
6764
self.cluster_manipulation_in_progress = False
6865
# If this is set to False, the master instance will not be an execution
@@ -822,19 +819,37 @@ def get_permanent_storage_size(self):
822819
return pss
823820

824821
def check_disk(self):
825-
try:
826-
fs_arr = self.get_services(svc_role=ServiceRole.GALAXY_DATA)
827-
if len(fs_arr) > 0:
828-
fs_name = fs_arr[0].name
829-
cmd = "df -h | grep %s$ | awk '{print $2, $3, $5}'" % fs_name
830-
disk_usage = commands.getoutput(cmd)
831-
disk_usage = disk_usage.split(' ')
832-
if len(disk_usage) == 3:
833-
self.disk_total = disk_usage[0]
834-
self.disk_used = disk_usage[1]
835-
self.disk_pct = disk_usage[2]
836-
except Exception, e:
837-
log.error("Failure checking disk usage. %s" % e)
822+
"""
823+
Check the usage of the main data disk and set appropriate object fields.
824+
825+
Depending on the cluster type, check the usage of the main disk (for the
826+
'Test' cluster type, this is `/mnt/transient_nfs` dir and for the other
827+
cluster types it is `/mnt/galaxy`) and return a dictionary with
828+
appropriate values.
829+
830+
:rtype: dictionary
831+
:return: A dictionary with keys `total`, `used`, and `used_percent` as
832+
strings. Also included is a bool `updated` field, which
833+
indicates if the disk status values were updated as part of
834+
this function call.
835+
"""
836+
disk_status = {'total': "0", 'used': "0", 'used_percent': "0%",
837+
'updated': False}
838+
if self.initial_cluster_type == 'Galaxy':
839+
fs_svc = self.service_registry.get_active('galaxy')
840+
else:
841+
fs_svc = self.service_registry.get_active('transient_nfs')
842+
if fs_svc:
843+
cmd = ("df -h {0} | sed 1d | awk '{{print $2, $3, $5}}'"
844+
.format(fs_svc.mount_point))
845+
disk_usage = misc.getoutput(cmd, quiet=True)
846+
disk_usage = disk_usage.split(' ')
847+
if len(disk_usage) == 3:
848+
disk_status = {'total': disk_usage[0],
849+
'used': disk_usage[1],
850+
'used_percent': disk_usage[2],
851+
'updated': True}
852+
return disk_status
838853

839854
def get_cluster_status(self):
840855
return self.cluster_status
@@ -2559,7 +2574,6 @@ def __monitor(self):
25592574
self._update_frequency()
25602575
if (Time.now() - self.last_update_time).seconds > self.update_frequency:
25612576
self.last_update_time = Time.now()
2562-
self.app.manager.check_disk()
25632577
for service in self.app.manager.service_registry.active():
25642578
service.status()
25652579
# Indicate migration is in progress

0 commit comments

Comments
 (0)