You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aurora.apache.org by ma...@apache.org on 2014/12/11 21:47:20 UTC

incubator-aurora git commit: Improving logging experience in admin drain_hosts.

Repository: incubator-aurora
Updated Branches:
  refs/heads/master dabe63a69 -> 4c280fff9


Improving logging experience in admin drain_hosts.

Bugs closed: AURORA-943

Reviewed at https://reviews.apache.org/r/28811/


Project: http://git-wip-us.apache.org/repos/asf/incubator-aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-aurora/commit/4c280fff
Tree: http://git-wip-us.apache.org/repos/asf/incubator-aurora/tree/4c280fff
Diff: http://git-wip-us.apache.org/repos/asf/incubator-aurora/diff/4c280fff

Branch: refs/heads/master
Commit: 4c280fff974847aee06d666200051d9aa00667e4
Parents: dabe63a
Author: Maxim Khutornenko <ma...@apache.org>
Authored: Thu Dec 11 12:47:00 2014 -0800
Committer: -l <ma...@apache.org>
Committed: Thu Dec 11 12:47:00 2014 -0800

----------------------------------------------------------------------
 .../python/apache/aurora/admin/host_maintenance.py  | 16 +++-------------
 .../apache/aurora/admin/test_host_maintenance.py    |  6 ++----
 2 files changed, 5 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/4c280fff/src/main/python/apache/aurora/admin/host_maintenance.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/admin/host_maintenance.py b/src/main/python/apache/aurora/admin/host_maintenance.py
index bff8afd..8fa5182 100644
--- a/src/main/python/apache/aurora/admin/host_maintenance.py
+++ b/src/main/python/apache/aurora/admin/host_maintenance.py
@@ -51,18 +51,6 @@ class HostMaintenance(object):
     self._client = AuroraClientAPI(cluster, verbosity == 'verbose')
     self._wait_event = wait_event or Event()
 
-  def check_if_drained(self, hostnames):
-    """Checks if host names reached DRAINED status.
-
-    :param hostnames: Host names to check for DRAINED status
-    :type hostnames: list of strings
-    :rtype: set of host names not in DRAINED state
-    """
-    statuses = self.check_status(hostnames)
-    not_ready_hostnames = [h[0] for h in statuses if h[1] != 'DRAINED']
-    log.info('Waiting for hosts to be in DRAINED: %s' % not_ready_hostnames)
-    return set(not_ready_hostnames)
-
   def _drain_hosts(self, drainable_hosts):
     """"Drains tasks from the specified hosts.
 
@@ -79,9 +67,11 @@ class HostMaintenance(object):
     total_wait = self.STATUS_POLL_INTERVAL
     not_drained_hostnames = set(drainable_hostnames)
     while not self._wait_event.is_set() and not_drained_hostnames:
+      log.info('Waiting for hosts to be in DRAINED: %s' % not_drained_hostnames)
       self._wait_event.wait(self.STATUS_POLL_INTERVAL.as_(Time.SECONDS))
 
-      not_drained_hostnames = self.check_if_drained(drainable_hostnames)
+      statuses = self.check_status(list(not_drained_hostnames))
+      not_drained_hostnames = set([h[0] for h in statuses if h[1] != 'DRAINED'])
 
       total_wait += self.STATUS_POLL_INTERVAL
       if not_drained_hostnames and total_wait > self.MAX_STATUS_WAIT:

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/4c280fff/src/test/python/apache/aurora/admin/test_host_maintenance.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/admin/test_host_maintenance.py b/src/test/python/apache/aurora/admin/test_host_maintenance.py
index 4b8072c..bb58670 100644
--- a/src/test/python/apache/aurora/admin/test_host_maintenance.py
+++ b/src/test/python/apache/aurora/admin/test_host_maintenance.py
@@ -79,9 +79,7 @@ class TestHostMaintenance(unittest.TestCase):
         Response(
             responseCode=ResponseCode.OK,
             result=Result(maintenanceStatusResult=MaintenanceStatusResult(set([
-                HostStatus(host=TEST_HOSTNAMES[0], mode=MaintenanceMode.DRAINED),
-                HostStatus(host=TEST_HOSTNAMES[1], mode=MaintenanceMode.DRAINED),
-                HostStatus(host=TEST_HOSTNAMES[2], mode=MaintenanceMode.DRAINED)
+                HostStatus(host=TEST_HOSTNAMES[0], mode=MaintenanceMode.DRAINED)
             ]))))]
 
     fake_maintenance_status_call_args = []
@@ -103,7 +101,7 @@ class TestHostMaintenance(unittest.TestCase):
         (Hosts(set(TEST_HOSTNAMES))),
         (Hosts(set(TEST_HOSTNAMES))),
         (Hosts(set(TEST_HOSTNAMES))),
-        (Hosts(set(TEST_HOSTNAMES)))]
+        (Hosts(set([TEST_HOSTNAMES[0]])))]
 
   @mock.patch("apache.aurora.client.api.AuroraClientAPI.maintenance_status",
               spec=AuroraClientAPI.maintenance_status)