aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jsir...@apache.org
Subject aurora git commit: Remove deprecated `HealthCheckConfig` fields.
Date Wed, 27 Jan 2016 20:18:04 GMT
Repository: aurora
Updated Branches:
  refs/heads/master 0d316cfbe -> e2a973e1e


Remove deprecated `HealthCheckConfig` fields.

Remove `endpoint`, `expected_response` and `expected_response_code`
which were all deprecated in Aurora 0.11.0 in favor of the same-named
fields in `HttpHealthChecker`.

This also removes health check validation in the client in favor of
leveraging the pystachio schema.  The one difference this allows for is
an empty string for the `ShellHealthChecker.shell_command`.  Since an
empty string is a valid shell command (equivalent to `true`), this
simplification seems justified.

Testing Done:
Locally green:
```
./build-support/jenkins/build.sh
./src/test/sh/org/apache/aurora/e2e/test_end_to_end.sh
```

Bugs closed: AURORA-1552, AURORA-1563

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


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

Branch: refs/heads/master
Commit: e2a973e1efb6476ad700919424c7117390c3359c
Parents: 0d316cf
Author: John Sirois <jsirois@apache.org>
Authored: Wed Jan 27 13:18:00 2016 -0700
Committer: John Sirois <jsirois@apache.org>
Committed: Wed Jan 27 13:18:00 2016 -0700

----------------------------------------------------------------------
 NEWS                                            |  3 +
 docs/configuration-reference.md                 |  3 -
 src/main/python/apache/aurora/client/config.py  | 40 ---------
 .../python/apache/aurora/config/schema/base.py  |  5 +-
 .../aurora/executor/common/health_checker.py    | 17 ++--
 .../python/apache/aurora/client/test_config.py  | 88 --------------------
 6 files changed, 9 insertions(+), 147 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aurora/blob/e2a973e1/NEWS
----------------------------------------------------------------------
diff --git a/NEWS b/NEWS
index 0e9f3b3..29702d5 100644
--- a/NEWS
+++ b/NEWS
@@ -39,6 +39,9 @@
   `--announcer-enable` and `--announcer-ensemble`, but now only `--announcer-ensemble` must
be set.
 - Deprecated `AddInstancesConfig` argument in `addInstances` thrift RPC. The new behavior
is to
   increase job instance count (scale out) based on the task template pointed by instance
`key`.
+- Removed the following deprecated `HealthCheckConfig` client-side configuration fields:
`endpoint`,
+  `expected_response`, `expected_response_code`.  These are now set exclusively in like-named
fields
+  of `HttpHealthChecker.`
 
 0.11.0
 ------

http://git-wip-us.apache.org/repos/asf/aurora/blob/e2a973e1/docs/configuration-reference.md
----------------------------------------------------------------------
diff --git a/docs/configuration-reference.md b/docs/configuration-reference.md
index c04f3b7..995f706 100644
--- a/docs/configuration-reference.md
+++ b/docs/configuration-reference.md
@@ -430,9 +430,6 @@ Parameters for controlling a task's health checks via HTTP or a shell
command.
 
 | param                          | type      | description
 | -------                        | :-------: | --------
-| *```endpoint```*               | String    | HTTP endpoint to check (Default: /health)
**Deprecated.**
-| *```expected_response```*      | String    | If not empty, fail the HTTP health check if
the response differs. Case insensitive. (Default: ok) **Deprecated.**
-| *```expected_response_code```* | Integer   | If not zero, fail the HTTP health check if
the response code differs. (Default: 0) **Deprecated.**
 | ```health_checker```           | HealthCheckerConfig | Configure what kind of health check
to use.
 | ```initial_interval_secs```    | Integer   | Initial delay for performing a health check.
(Default: 15)
 | ```interval_secs```            | Integer   | Interval on which to check the task's health.
(Default: 10)

http://git-wip-us.apache.org/repos/asf/aurora/blob/e2a973e1/src/main/python/apache/aurora/client/config.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/client/config.py b/src/main/python/apache/aurora/client/config.py
index a4fa485..2fc1255 100644
--- a/src/main/python/apache/aurora/client/config.py
+++ b/src/main/python/apache/aurora/client/config.py
@@ -22,8 +22,6 @@ import math
 import re
 import sys
 
-from twitter.common import log
-
 from apache.aurora.client import binding_helper
 from apache.aurora.client.base import die
 from apache.aurora.config import AuroraConfig
@@ -70,43 +68,6 @@ def _validate_environment_name(config):
   __validate_env(env_name, 'Environment')
 
 
-INVALID_HEALTH_CHECKER = '''
-Invalid health endpoint config.
-'''
-
-MUST_PROVIDE_SHELL_COMMAND_ERROR = '''
-Must provide a shell command if using ShellHealthChecker.
-'''
-
-HTTP_DEPRECATION_WARNING = '''
-WARNING: endpoint, expected_response, and expected_response_code are deprecated and will
be removed
-in the next release. Please consult updated documentation.
-'''
-
-HTTP_HEALTH_CHECK = 'http'
-SHELL_HEALTH_CHECK = 'shell'
-
-
-# TODO (AURORA-1552): Add config validation to the executor
-def _validate_health_check_config(config):
-  health_check_config = config.health_check_config().get()
-  health_checker = health_check_config.get('health_checker', {})
-  # If we have old-style of configuring.
-  # TODO (AURORA-1563): Remove this code after we drop support for defining these directly
in
-  # HealthCheckConfig.
-  for deprecated in {'endpoint', 'expected_response', 'expected_response_code'}:
-    if deprecated in health_check_config:
-      log.warn(HTTP_DEPRECATION_WARNING)
-      break
-  if SHELL_HEALTH_CHECK in health_checker:
-    # Make sure we specified a shell_command if we chose a shell config.
-    shell_health_checker = health_checker.get(SHELL_HEALTH_CHECK, {})
-    shell_command = shell_health_checker.get('shell_command')
-    if not shell_command:
-      # Must define a command.
-      die(MUST_PROVIDE_SHELL_COMMAND_ERROR)
-
-
 UPDATE_CONFIG_MAX_FAILURES_ERROR = '''
 max_total_failures in update_config must be lesser than the job size.
 Based on your job size (%s) you should use max_total_failures <= %s.
@@ -157,7 +118,6 @@ def validate_config(config, env=None):
   _validate_update_config(config)
   _validate_announce_configuration(config)
   _validate_environment_name(config)
-  _validate_health_check_config(config)
 
 
 class GlobalHookRegistry(object):

http://git-wip-us.apache.org/repos/asf/aurora/blob/e2a973e1/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 0e4dfc2..00be874 100644
--- a/src/main/python/apache/aurora/config/schema/base.py
+++ b/src/main/python/apache/aurora/config/schema/base.py
@@ -42,7 +42,7 @@ class HttpHealthChecker(Struct):
 
 
 class ShellHealthChecker(Struct):
-  shell_command            = String
+  shell_command            = Required(String)
 
 
 class HealthCheckerConfig(Struct):
@@ -54,9 +54,6 @@ DefaultHealthChecker      = HealthCheckerConfig(http=HttpHealthChecker())
 
 
 class HealthCheckConfig(Struct):
-  endpoint                 = Default(String, '/health')
-  expected_response        = Default(String, 'ok')
-  expected_response_code   = Default(Integer, 0)
   health_checker           = Default(HealthCheckerConfig, DefaultHealthChecker)
   initial_interval_secs    = Default(Float, 15.0)
   interval_secs            = Default(Float, 10.0)

http://git-wip-us.apache.org/repos/asf/aurora/blob/e2a973e1/src/main/python/apache/aurora/executor/common/health_checker.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/executor/common/health_checker.py b/src/main/python/apache/aurora/executor/common/health_checker.py
index 01194aa..3039727 100644
--- a/src/main/python/apache/aurora/executor/common/health_checker.py
+++ b/src/main/python/apache/aurora/executor/common/health_checker.py
@@ -224,18 +224,11 @@ class HealthCheckerProvider(StatusCheckerProvider):
       portmap = resolve_ports(mesos_task, assigned_task.assignedPorts)
       if 'health' not in portmap:
         return None
-      if HTTP_HEALTH_CHECK in health_checker:
-        # Assume user has already switched over to the new config since we found the key.
-        http_config = health_checker.get(HTTP_HEALTH_CHECK, {})
-        http_endpoint = http_config.get('endpoint')
-        http_expected_response = http_config.get('expected_response')
-        http_expected_response_code = http_config.get('expected_response_code')
-      else:
-        # TODO (AURORA-1563): Remove this clause after we deprecate support for following
keys
-        # directly in HealthCheckConfig
-        http_endpoint = health_check_config.get('endpoint')
-        http_expected_response = health_check_config.get('expected_response')
-        http_expected_response_code = health_check_config.get('expected_response_code')
+      http_config = health_checker.get(HTTP_HEALTH_CHECK, {})
+      http_endpoint = http_config.get('endpoint')
+      http_expected_response = http_config.get('expected_response')
+      http_expected_response_code = http_config.get('expected_response_code')
+
       http_signaler = HttpSignaler(
         portmap['health'],
         timeout_secs=timeout_secs)

http://git-wip-us.apache.org/repos/asf/aurora/blob/e2a973e1/src/test/python/apache/aurora/client/test_config.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/test_config.py b/src/test/python/apache/aurora/client/test_config.py
index de0973d..b1a3c18 100644
--- a/src/test/python/apache/aurora/client/test_config.py
+++ b/src/test/python/apache/aurora/client/test_config.py
@@ -16,22 +16,18 @@ import os
 from io import BytesIO
 
 import pytest
-from twitter.common import log
 from twitter.common.contextutil import temporary_dir
 
 from apache.aurora.client import config
 from apache.aurora.client.config import get_config as get_aurora_config
-from apache.aurora.client.config import HTTP_DEPRECATION_WARNING
 from apache.aurora.config import AuroraConfig
 from apache.aurora.config.loader import AuroraConfigLoader
 from apache.aurora.config.schema.base import (
     MB,
     Announcer,
     HealthCheckConfig,
-    HealthCheckerConfig,
     Job,
     Resources,
-    ShellHealthChecker,
     Task,
     UpdateConfig
 )
@@ -184,90 +180,6 @@ def test_dedicated_portmap():
                               constraints={'foo': 'bar'})))
 
 
-def test_health_check_config_http_ok():
-  base_job = Job(
-    name='hello_bond', role='james', cluster='marine-cluster',
-    health_check_config=HealthCheckConfig(
-      max_consecutive_failures=1,
-    ),
-    task=Task(name='main', processes=[],
-              resources=Resources(cpu=0.1, ram=64 * MB, disk=64 * MB)))
-  config._validate_health_check_config(AuroraConfig(base_job))
-
-
-def test_health_check_config_shell_ok():
-  base_job = Job(
-    name='hello_bond', role='james', cluster='marine-cluster',
-
-    health_check_config=HealthCheckConfig(
-      max_consecutive_failures=1,
-      health_checker=HealthCheckerConfig(
-        shell=ShellHealthChecker(shell_command='foo bar')
-      )
-    ),
-    task=Task(name='main', processes=[],
-              resources=Resources(cpu=0.1, ram=64 * MB, disk=64 * MB)))
-  config._validate_health_check_config(AuroraConfig(base_job))
-
-
-def test_health_check_config_invalid_type():
-  # Must be 'shell' or 'http' type of config.
-  with pytest.raises(ValueError):
-    Job(
-      name='hello_bond', role='james', cluster='marine-cluster',
-      health_check_config=HealthCheckConfig(
-      max_consecutive_failures=1,
-      health_checker='foo',
-    ),
-    task=Task(name='main', processes=[],
-              resources=Resources(cpu=0.1, ram=64 * MB, disk=64 * MB)))
-
-
-def test_health_check_config_deprecate_message(monkeypatch):
-  base_job = Job(
-    name='hello_bond', role='james', cluster='marine-cluster',
-    health_check_config=HealthCheckConfig(
-      max_consecutive_failures=1,
-      endpoint='/to_be_deprecated'
-    ),
-    task=Task(name='main', processes=[],
-              resources=Resources(cpu=0.1, ram=64 * MB, disk=64 * MB)))
-  log_items = []
-  def capture_log(msg):
-    log_items.append(msg)
-  monkeypatch.setattr(log, 'warn', capture_log)
-  config._validate_health_check_config(AuroraConfig(base_job))
-  assert log_items == [HTTP_DEPRECATION_WARNING]
-
-
-def test_health_check_config_shell_no_command():
-  # If we chose shell config, we must define shell_command.
-  base_job = Job(
-    name='hello_bond', role='james', cluster='marine-cluster',
-    health_check_config=HealthCheckConfig(
-      max_consecutive_failures=1,
-      health_checker=HealthCheckerConfig(shell=ShellHealthChecker())
-    ),
-    task=Task(name='main', processes=[],
-              resources=Resources(cpu=0.1, ram=64 * MB, disk=64 * MB)))
-  with pytest.raises(SystemExit):
-    config._validate_health_check_config(AuroraConfig(base_job))
-
-
-def test_health_check_config_shell_empty_command():
-  # shell_command must not be left empty.
-  base_job = Job(
-      name='hello_bond', role='james', cluster='marine-cluster',
-      health_check_config=HealthCheckConfig(
-        max_consecutive_failures=1,
-        health_checker=HealthCheckerConfig(shell=ShellHealthChecker(shell_command=''))
-      ),
-      task=Task(name='main', processes=[],
-                resources=Resources(cpu=0.1, ram=64 * MB, disk=64 * MB)))
-  with pytest.raises(SystemExit):
-    config._validate_health_check_config(AuroraConfig(base_job))
-
-
 def test_update_config_passes_with_default_values():
   base_job = Job(
     name='hello_world', role='john_doe', cluster='test-cluster',


Mime
View raw message