aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject git commit: Removing --groups_per_batch option.
Date Fri, 23 May 2014 00:30:21 GMT
Repository: incubator-aurora
Updated Branches:
  refs/heads/master ccd6a492c -> b055ec9ff


Removing --groups_per_batch option.

Bugs closed: AURORA-446

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


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

Branch: refs/heads/master
Commit: b055ec9ff1966df3fbf3ee760856da2b2b35d693
Parents: ccd6a49
Author: Maxim Khutornenko <maxim@apache.org>
Authored: Thu May 22 17:29:51 2014 -0700
Committer: Maxim Khutornenko <maxim@apache.org>
Committed: Thu May 22 17:29:51 2014 -0700

----------------------------------------------------------------------
 .../python/apache/aurora/admin/host_maintenance.py | 12 +++++-------
 .../apache/aurora/client/commands/maintenance.py   |  4 ----
 .../apache/aurora/admin/test_host_maintenance.py   | 17 ++---------------
 3 files changed, 7 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/b055ec9f/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 16c18bc..1890f80 100644
--- a/src/main/python/apache/aurora/admin/host_maintenance.py
+++ b/src/main/python/apache/aurora/admin/host_maintenance.py
@@ -53,13 +53,11 @@ class HostMaintenance(object):
     return groups
 
   @classmethod
-  def iter_batches(cls, hostnames, groups_per_batch, grouping_function=DEFAULT_GROUPING):
-    if groups_per_batch <= 0:
-      raise ValueError('Batch size must be > 0!')
+  def iter_batches(cls, hostnames, grouping_function=DEFAULT_GROUPING):
     groups = cls.group_hosts(hostnames, grouping_function)
     groups = sorted(groups.items(), key=lambda v: v[0])
-    for k in range(0, len(groups), groups_per_batch):
-      yield Hosts(set.union(*(hostset for (key, hostset) in groups[k:k + groups_per_batch])))
+    for group in groups:
+      yield Hosts(group[1])
 
   def __init__(self, cluster, verbosity):
     self._client = AuroraClientAPI(cluster, verbosity == 'verbose')
@@ -102,7 +100,7 @@ class HostMaintenance(object):
     """Put a list of hosts into maintenance mode, to de-prioritize scheduling."""
     check_and_log_response(self._client.start_maintenance(Hosts(set(hosts))))
 
-  def perform_maintenance(self, hosts, groups_per_batch=1, grouping_function=DEFAULT_GROUPING,
+  def perform_maintenance(self, hosts, grouping_function=DEFAULT_GROUPING,
                           callback=None):
     """The wrap a callback in between sending hosts into maintenance mode and back.
 
@@ -113,7 +111,7 @@ class HostMaintenance(object):
     self._complete_maintenance(Hosts(set(hosts)))
     self.start_maintenance(hosts)
 
-    for hosts in self.iter_batches(hosts, groups_per_batch, grouping_function):
+    for hosts in self.iter_batches(hosts, grouping_function):
       self._drain_hosts(hosts)
       if callback:
         self._operate_on_hosts(hosts, callback)

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/b055ec9f/src/main/python/apache/aurora/client/commands/maintenance.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/client/commands/maintenance.py b/src/main/python/apache/aurora/client/commands/maintenance.py
index 68d63a1..d020e4c 100644
--- a/src/main/python/apache/aurora/client/commands/maintenance.py
+++ b/src/main/python/apache/aurora/client/commands/maintenance.py
@@ -62,8 +62,6 @@ def end_maintenance_hosts(cluster):
 
 
 @app.command
-@app.command_option('--groups_per_batch', dest='groups_per_batch', default=1,
-    help='Number of groups to operate on at a time.')
 @app.command_option('--post_drain_script', dest='post_drain_script', default=None,
     help='Path to a script to run for each host.')
 @app.command_option(FILENAME_OPTION)
@@ -72,7 +70,6 @@ def end_maintenance_hosts(cluster):
 @requires.exactly('cluster')
 def perform_maintenance_hosts(cluster):
   """usage: perform_maintenance_hosts {--filename=filename | --hosts=hosts}
-                                      [--groups_per_batch=num]
                                       [--post_drain_script=path]
                                       [--grouping=function]
                                       cluster
@@ -94,7 +91,6 @@ def perform_maintenance_hosts(cluster):
 
   HostMaintenance(CLUSTERS[cluster], options.verbosity).perform_maintenance(
       drainable_hosts,
-      groups_per_batch=int(options.groups_per_batch),
       callback=drained_callback,
       grouping_function=options.grouping)
 

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/b055ec9f/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 18bf622..8c76638 100644
--- a/src/test/python/apache/aurora/admin/test_host_maintenance.py
+++ b/src/test/python/apache/aurora/admin/test_host_maintenance.py
@@ -46,15 +46,11 @@ def test_default_grouping():
     'foo001.example.com',
   ]
 
-  batches = list(HostMaintenance.iter_batches(example_host_list, 1))
+  batches = list(HostMaintenance.iter_batches(example_host_list))
   assert batches[0] == Hosts(set(['bar337.example.com']))
   assert batches[1] == Hosts(set(['foo001.example.com']))
   assert batches[2] == Hosts(set(['xyz321.example.com']))
 
-  batches = list(HostMaintenance.iter_batches(example_host_list, 2))
-  assert batches[0] == Hosts(set(['bar337.example.com', 'foo001.example.com']))
-  assert batches[1] == Hosts(set(['xyz321.example.com']))
-
 
 def rack_grouping(hostname):
   return hostname.split('-')[1]
@@ -73,7 +69,7 @@ def test_rack_grouping():
   ]
 
   try:
-    batches = list(HostMaintenance.iter_batches(example_host_list, 1, 'by_rack'))
+    batches = list(HostMaintenance.iter_batches(example_host_list, 'by_rack'))
     assert batches[0] == Hosts(set([
         'west-aaa-001.example.com',
         'west-aaa-002.example.com'
@@ -84,14 +80,5 @@ def test_rack_grouping():
         'east-xyz-004.example.com',
     ]))
 
-    batches = list(HostMaintenance.iter_batches(example_host_list, 2, 'by_rack'))
-    assert batches[0] == Hosts(set(example_host_list))
-
-    batches = list(HostMaintenance.iter_batches(example_host_list, 3, 'by_rack'))
-    assert batches[0] == Hosts(set(example_host_list))
-
-    with pytest.raises(ValueError):
-      list(HostMaintenance.iter_batches(example_host_list, 0))
-
   finally:
     HostMaintenance.GROUPING_FUNCTIONS = old_grouping_functions


Mime
View raw message