From f412d8521c79d9361c86dc1a1d74a119b1942b7c Mon Sep 17 00:00:00 2001 From: Noboru Iwamatsu Date: Tue, 25 Jun 2019 18:24:48 +0900 Subject: [PATCH] Add failover logging to show the amphora details. When failover occurs, Octavia health-manager doesn't log any information about the loadbalancer. Due to this, operators can't specify which loadbalancer got failed and which user was affected by the failover. This commit fix this issue by logging not only amphora_id but also the linking information (e.g. loadbalancer_id, compute_id, ..) when performing/completed the failover. Change-Id: I9bdd6f2913c0da2b0772b4b694309ef993289360 Task: 34312 Story: 2005947 (cherry picked from commit 93e06a9239a0f4b2bcdcdca9e13e800e75b1f237) --- .../controller/worker/controller_worker.py | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/octavia/controller/worker/controller_worker.py b/octavia/controller/worker/controller_worker.py index 0de233d726..3aa74c4476 100644 --- a/octavia/controller/worker/controller_worker.py +++ b/octavia/controller/worker/controller_worker.py @@ -803,6 +803,22 @@ class ControllerWorker(base_taskflow.BaseTaskFlowEngine): constants.LOADBALANCER_ID: amp.load_balancer_id, constants.BUILD_TYPE_PRIORITY: priority, } + if amp.role in (constants.ROLE_MASTER, constants.ROLE_BACKUP): + amp_role = 'master_or_backup' + elif amp.role == constants.ROLE_STANDALONE: + amp_role = 'standalone' + elif amp.role is None: + amp_role = 'spare' + else: + amp_role = 'undefined' + + LOG.info("Perform failover for an amphora: %s", + {"id": amp.id, + "load_balancer_id": amp.load_balancer_id, + "lb_network_ip": amp.lb_network_ip, + "compute_id": amp.compute_id, + "role": amp_role}) + if amp.status == constants.DELETED: LOG.warning('Amphora %s is marked DELETED in the database but ' 'was submitted for failover. Deleting it from the ' @@ -839,6 +855,13 @@ class ControllerWorker(base_taskflow.BaseTaskFlowEngine): with tf_logging.DynamicLoggingListener(failover_amphora_tf, log=LOG): failover_amphora_tf.run() + LOG.info("Successfully completed the failover for an amphora: %s", + {"id": amp.id, + "load_balancer_id": amp.load_balancer_id, + "lb_network_ip": amp.lb_network_ip, + "compute_id": amp.compute_id, + "role": amp_role}) + def failover_amphora(self, amphora_id): """Perform failover operations for an amphora. @@ -869,7 +892,8 @@ class ControllerWorker(base_taskflow.BaseTaskFlowEngine): except Exception: LOG.error("Unable to revert LB status to ERROR.") with excutils.save_and_reraise_exception(): - LOG.error("Failover exception: %s", e) + LOG.error("Amphora %(id)s failover exception: %(exc)s", + {'id': amphora_id, 'exc': e}) def failover_loadbalancer(self, load_balancer_id): """Perform failover operations for a load balancer.