aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject incubator-aurora git commit: Adding pulse_interval_secs into client UpdateConfig.
Date Thu, 12 Feb 2015 18:18:04 GMT
Repository: incubator-aurora
Updated Branches:
  refs/heads/master 994d66938 -> ab8fae2ad


Adding pulse_interval_secs into client UpdateConfig.

Bugs closed: AURORA-1071

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


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

Branch: refs/heads/master
Commit: ab8fae2ad8a270f440576d0079d7f487e5233981
Parents: 994d669
Author: Maxim Khutornenko <maxim@apache.org>
Authored: Thu Feb 12 10:17:46 2015 -0800
Committer: Maxim Khutornenko <maxim@apache.org>
Committed: Thu Feb 12 10:17:46 2015 -0800

----------------------------------------------------------------------
 src/main/python/apache/aurora/client/api/updater.py |  2 ++
 .../python/apache/aurora/client/api/updater_util.py | 13 +++++++++++--
 src/main/python/apache/aurora/config/schema/base.py |  1 +
 .../python/apache/aurora/client/api/test_updater.py | 10 +++++++++-
 .../apache/aurora/client/api/test_updater_util.py   | 16 ++++++++++++++++
 5 files changed, 39 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/ab8fae2a/src/main/python/apache/aurora/client/api/updater.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/client/api/updater.py b/src/main/python/apache/aurora/client/api/updater.py
index 9f91de6..7fd6fda 100644
--- a/src/main/python/apache/aurora/client/api/updater.py
+++ b/src/main/python/apache/aurora/client/api/updater.py
@@ -95,6 +95,8 @@ class Updater(object):
       self._update_config = UpdaterConfig(**config.update_config().get())
     except ValueError as e:
       raise self.Error(str(e))
+    if self._update_config.pulse_interval_secs:
+      raise self.Error('Pulse interval seconds is not supported by the client updater.')
     self._lock = None
     self._thread_lock = threading_lock()
     self._batch_wait_event = Event()

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/ab8fae2a/src/main/python/apache/aurora/client/api/updater_util.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/client/api/updater_util.py b/src/main/python/apache/aurora/client/api/updater_util.py
index 9d2e893..b54691e 100644
--- a/src/main/python/apache/aurora/client/api/updater_util.py
+++ b/src/main/python/apache/aurora/client/api/updater_util.py
@@ -22,6 +22,8 @@ from gen.apache.aurora.api.ttypes import JobUpdateSettings, Range
 
 
 class UpdaterConfig(object):
+  MIN_PULSE_INTERVAL_SECONDS = 60
+
   """
   For updates involving a health check,
 
@@ -42,7 +44,8 @@ class UpdaterConfig(object):
                max_per_shard_failures,
                max_total_failures,
                rollback_on_failure=True,
-               wait_for_batch_completion=False):
+               wait_for_batch_completion=False,
+               pulse_interval_secs=None):
 
     if batch_size <= 0:
       raise ValueError('Batch size should be greater than 0')
@@ -50,6 +53,9 @@ class UpdaterConfig(object):
       raise ValueError('Restart Threshold should be greater than 0')
     if watch_secs <= 0:
       raise ValueError('Watch seconds should be greater than 0')
+    if pulse_interval_secs is not None and pulse_interval_secs < self.MIN_PULSE_INTERVAL_SECONDS:
+      raise ValueError('Pulse interval seconds must be at least %s seconds.'
+                       % self.MIN_PULSE_INTERVAL_SECONDS)
     self.batch_size = batch_size
     self.restart_threshold = restart_threshold
     self.watch_secs = watch_secs
@@ -57,6 +63,7 @@ class UpdaterConfig(object):
     self.max_per_instance_failures = max_per_shard_failures
     self.rollback_on_failure = rollback_on_failure
     self.wait_for_batch_completion = wait_for_batch_completion
+    self.pulse_interval_secs = pulse_interval_secs
 
   @classmethod
   def instances_to_ranges(cls, instances):
@@ -95,7 +102,9 @@ class UpdaterConfig(object):
         minWaitInInstanceRunningMs=self.watch_secs * 1000,
         rollbackOnFailure=self.rollback_on_failure,
         waitForBatchCompletion=self.wait_for_batch_completion,
-        updateOnlyTheseInstances=self.instances_to_ranges(instances) if instances else None)
+        updateOnlyTheseInstances=self.instances_to_ranges(instances) if instances else None,
+        blockIfNoPulsesAfterMs=self.pulse_interval_secs * 1000 if self.pulse_interval_secs
else None
+    )
 
   def __eq__(self, other):
     return self.__dict__ == other.__dict__

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/ab8fae2a/src/main/python/apache/aurora/config/schema/base.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/config/schema/base.py b/src/main/python/apache/aurora/config/schema/base.py
index e4433d2..a87524a 100644
--- a/src/main/python/apache/aurora/config/schema/base.py
+++ b/src/main/python/apache/aurora/config/schema/base.py
@@ -32,6 +32,7 @@ class UpdateConfig(Struct):
   max_total_failures          = Default(Integer, 0)
   rollback_on_failure         = Default(Boolean, True)
   wait_for_batch_completion   = Default(Boolean, False)
+  pulse_interval_secs         = Integer
 
 
 class HealthCheckConfig(Struct):

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/ab8fae2a/src/test/python/apache/aurora/client/api/test_updater.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/api/test_updater.py b/src/test/python/apache/aurora/client/api/test_updater.py
index dd3f228..7f3bc28 100644
--- a/src/test/python/apache/aurora/client/api/test_updater.py
+++ b/src/test/python/apache/aurora/client/api/test_updater.py
@@ -347,7 +347,15 @@ class UpdaterTest(TestCase):
         'Unexpected error count:%s' % len(resp.details))
 
       assert message in resp.details[0].message, (
-        "Expected %s message not found in: %s" % (message, resp.details[0].message))
+        'Expected %s message not found in: %s' % (message, resp.details[0].message))
+
+  def test_pulse_interval_not_supported(self):
+    update_config = self.UPDATE_CONFIG.copy()
+    update_config.update(pulse_interval_secs=60)
+
+    with raises(Updater.Error) as e:
+      self.init_updater(update_config)
+      assert 'Pulse interval seconds is not supported in client updater.' in e.message
 
   def test_grow(self):
     """Adds instances to the existing job."""

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/ab8fae2a/src/test/python/apache/aurora/client/api/test_updater_util.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/api/test_updater_util.py b/src/test/python/apache/aurora/client/api/test_updater_util.py
index fe3ac49..11b95c6 100644
--- a/src/test/python/apache/aurora/client/api/test_updater_util.py
+++ b/src/test/python/apache/aurora/client/api/test_updater_util.py
@@ -13,6 +13,8 @@
 #
 import unittest
 
+from pytest import raises
+
 from apache.aurora.client.api import UpdaterConfig
 
 from gen.apache.aurora.api.ttypes import Range
@@ -42,3 +44,17 @@ class TestRangeConversion(unittest.TestCase):
   def test_empty_list(self):
     """Test empty list produces None result."""
     assert UpdaterConfig.instances_to_ranges([]) is None, "Result must be None."
+
+  def test_pulse_interval_secs(self):
+    config = UpdaterConfig(1, 1, 1, 1, 1, pulse_interval_secs=60)
+    assert 60000 == config.to_thrift_update_settings().blockIfNoPulsesAfterMs
+
+  def test_pulse_interval_unset(self):
+    config = UpdaterConfig(1, 1, 1, 1, 1)
+    assert config.to_thrift_update_settings().blockIfNoPulsesAfterMs is None
+
+  def test_pulse_interval_too_low(self):
+    threshold = UpdaterConfig.MIN_PULSE_INTERVAL_SECONDS
+    with raises(ValueError) as e:
+      UpdaterConfig(1, 1, 1, 1, 1, pulse_interval_secs=threshold - 1)
+    assert 'Pulse interval seconds must be at least %s seconds.' % threshold in e.value.message


Mime
View raw message