@@ -60,9 +60,6 @@ def __init__(self, app):
60
60
# This initialization is applicable only when restarting a cluster.
61
61
self.worker_instances = self.get_worker_instances() if (
62
62
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%"
66
63
self.manager_started = False
67
64
self.cluster_manipulation_in_progress = False
68
65
# If this is set to False, the master instance will not be an execution
@@ -822,19 +819,37 @@ def get_permanent_storage_size(self):
822
819
return pss
823
820
824
821
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
838
853
839
854
def get_cluster_status(self):
840
855
return self.cluster_status
@@ -2559,7 +2574,6 @@ def __monitor(self):
2559
2574
self._update_frequency()
2560
2575
if (Time.now() - self.last_update_time).seconds > self.update_frequency:
2561
2576
self.last_update_time = Time.now()
2562
- self.app.manager.check_disk()
2563
2577
for service in self.app.manager.service_registry.active():
2564
2578
service.status()
2565
2579
# Indicate migration is in progress
0 commit comments