aboutsummaryrefslogtreecommitdiffstats
path: root/policyhandler/deploy_handler.py
diff options
context:
space:
mode:
authorAlex Shatov <alexs@att.com>2018-03-13 17:50:51 -0400
committerAlex Shatov <alexs@att.com>2018-03-13 17:50:51 -0400
commita2b262994a62286e1c98fd9939115c6e64ed27ee (patch)
treef6ef7056c70a34485d1ed047a296b89bb3354ee2 /policyhandler/deploy_handler.py
parentb9b955c0c2875effc1ce02d5576f0d2a59284c5d (diff)
2.3.0 policy-handler - periodically catch_up
- periodically catchup - interval is configurable = max_skips defines the number of times the catch_up message that is identical to previous one can be skipped - do not catchup more often than the interval even between the manual catchup and auto catchup - do not send the same catchup message twice in a row to the deployment-handler but not exceed a hard limit on catchup max_skips - catchup if the deployment-handler instance is changed Change-Id: I9a3fcc941e8a9e553abb3952dd882c37e0f5fdfe Signed-off-by: Alex Shatov <alexs@att.com> Issue-ID: DCAEGEN2-389
Diffstat (limited to 'policyhandler/deploy_handler.py')
-rw-r--r--policyhandler/deploy_handler.py31
1 files changed, 26 insertions, 5 deletions
diff --git a/policyhandler/deploy_handler.py b/policyhandler/deploy_handler.py
index 0950dfd..493b7d5 100644
--- a/policyhandler/deploy_handler.py
+++ b/policyhandler/deploy_handler.py
@@ -41,6 +41,7 @@ class DeployHandler(object):
_url_path = None
_target_entity = None
_custom_kwargs = None
+ _server_instance_uuid = None
@staticmethod
def _lazy_init(audit):
@@ -72,7 +73,11 @@ class DeployHandler(object):
@staticmethod
def policy_update(audit, message):
- """post policy_updated message to deploy-handler"""
+ """
+ post policy_updated message to deploy-handler
+
+ returns condition whether it needs to catch_up
+ """
if not message:
return
@@ -116,8 +121,24 @@ class DeployHandler(object):
sub_aud.set_http_status_code(res.status_code)
audit.set_http_status_code(res.status_code)
- sub_aud.metrics("response {0} from {1}: text={2}{3}" \
- .format(res.status_code, log_action, res.text, log_data))
+ log_line = "response {0} from {1}: text={2}{3}" \
+ .format(res.status_code, log_action, res.text, log_data)
+ sub_aud.metrics(log_line)
+ DeployHandler._logger.info(log_line)
+
+ if res.status_code != requests.codes.ok:
+ return
+
+ result = res.json() or {}
+ prev_server_instance_uuid = DeployHandler._server_instance_uuid
+ DeployHandler._server_instance_uuid = result.get("server_instance_uuid")
+
+ need_to_catch_up = (prev_server_instance_uuid
+ and prev_server_instance_uuid != DeployHandler._server_instance_uuid)
+ if need_to_catch_up:
+ log_line = "need_to_catch_up: {1} != {0}" \
+ .format(prev_server_instance_uuid, DeployHandler._server_instance_uuid)
+ sub_aud.info(log_line)
+ DeployHandler._logger.info(log_line)
- if res.status_code == requests.codes.ok:
- return res.json()
+ return need_to_catch_up