aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject git commit: Avoiding cluster-wide query in case hosts-scoped call did not produce any tasks.
Date Fri, 20 Jun 2014 23:10:42 GMT
Repository: incubator-aurora
Updated Branches:
  refs/heads/master b18f89c1d -> 5fa29f138


Avoiding cluster-wide query in case hosts-scoped call did not produce any tasks.

Bugs closed: AURORA-537

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


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

Branch: refs/heads/master
Commit: 5fa29f13888d33c91de60f2a78029c4ba486d4d8
Parents: b18f89c
Author: Maxim Khutornenko <maxim@apache.org>
Authored: Fri Jun 20 16:10:23 2014 -0700
Committer: Maxim Khutornenko <maxim@apache.org>
Committed: Fri Jun 20 16:10:23 2014 -0700

----------------------------------------------------------------------
 src/main/python/apache/aurora/admin/host_maintenance.py | 2 ++
 src/main/python/apache/aurora/client/api/sla.py         | 5 ++++-
 src/test/python/apache/aurora/client/api/test_sla.py    | 7 +++++++
 3 files changed, 13 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/5fa29f13/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 97d484f..3c04773 100644
--- a/src/main/python/apache/aurora/admin/host_maintenance.py
+++ b/src/main/python/apache/aurora/admin/host_maintenance.py
@@ -122,6 +122,7 @@ class HostMaintenance(object):
     sla_percentage = percentage or self.SLA_UPTIME_PERCENTAGE_LIMIT
     sla_duration = duration or self.SLA_UPTIME_DURATION_LIMIT
 
+    log.info('Beginning SLA check for %s' % hostnames)
     vector = self._client.sla_get_safe_domain_vector(self.SLA_MIN_JOB_INSTANCE_COUNT, hostnames)
     host_groups = vector.probe_hosts(
       sla_percentage,
@@ -141,6 +142,7 @@ class HostMaintenance(object):
         log.warning('Some hosts in a group did not pass SLA check. Skipping group:%s' % hostnames)
         return False
 
+    log.info('All hosts passed SLA check.')
     return True
 
   def end_maintenance(self, hostnames):

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/5fa29f13/src/main/python/apache/aurora/client/api/sla.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/client/api/sla.py b/src/main/python/apache/aurora/client/api/sla.py
index a7b8760..8fc9af3 100644
--- a/src/main/python/apache/aurora/client/api/sla.py
+++ b/src/main/python/apache/aurora/client/api/sla.py
@@ -312,9 +312,12 @@ class Sla(object):
     """
     tasks = self._get_tasks(task_query(hosts=hosts)) if hosts else None
     job_keys = set(job_key_from_scheduled(t, cluster) for t in tasks) if tasks else None
+
+    # Avoid full cluster pull if job_keys are missing for any reason but the hosts are specified.
+    job_tasks = [] if hosts and not job_keys else self._get_tasks(task_query(job_keys=job_keys))
     return DomainUpTimeSlaVector(
         cluster,
-        self._get_tasks(task_query(job_keys=job_keys)),
+        job_tasks,
         min_instance_count=min_instance_count,
         hosts=hosts)
 

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/5fa29f13/src/test/python/apache/aurora/client/api/test_sla.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/api/test_sla.py b/src/test/python/apache/aurora/client/api/test_sla.py
index 9ca8102..abeed6a 100644
--- a/src/test/python/apache/aurora/client/api/test_sla.py
+++ b/src/test/python/apache/aurora/client/api/test_sla.py
@@ -443,6 +443,13 @@ class SlaTest(unittest.TestCase):
       self._sla.get_domain_uptime_vector(self._cluster, self._min_count, hosts)
       mock_query.assert_has_calls([call(hosts=hosts), call(job_keys=jobs)], any_order=False)
 
+  def test_get_domain_uptime_vector_with_hosts_no_job_tasks(self):
+    with patch('apache.aurora.client.api.sla.task_query', return_value=TaskQuery()) as (mock_query):
+      self.mock_get_tasks([])
+
+      self._sla.get_domain_uptime_vector(self._cluster, self._min_count, ['h1'])
+      mock_query.assert_called_once_with(hosts=['h1'])
+
   def test_task_query(self):
     jobs = set([
         AuroraJobKey(self._cluster.name, self._role, self._env, 'j1'),


Mime
View raw message