Blame SOURCES/bz1678480-migrate-failed-checkers-reload.patch

9cfb40
From 6c5646bec26fe86214a34a877b84da83f9d9cfb4 Mon Sep 17 00:00:00 2001
9cfb40
From: YAMAMOTO Masaya <pandax381@gmail.com>
9cfb40
Date: Tue, 4 Jul 2017 15:08:36 +0900
9cfb40
Subject: [PATCH 2/8] Migrate failed checkers at reload (provisional
9cfb40
 implementation)
9cfb40
9cfb40
---
9cfb40
 keepalived/check/ipwrapper.c | 36 +++++++++++++++++++++++++-----------
9cfb40
 1 file changed, 25 insertions(+), 11 deletions(-)
9cfb40
9cfb40
diff --git a/keepalived/check/ipwrapper.c b/keepalived/check/ipwrapper.c
9cfb40
index ecf12713..6acf18ba 100644
9cfb40
--- a/keepalived/check/ipwrapper.c
9cfb40
+++ b/keepalived/check/ipwrapper.c
9cfb40
@@ -623,9 +623,28 @@ rs_exist(real_server_t * old_rs, list l)
9cfb40
 	return NULL;
9cfb40
 }
9cfb40
 
9cfb40
+static void
9cfb40
+migrate_failed_checkers(real_server_t *old_rs, real_server_t *new_rs)
9cfb40
+{
9cfb40
+	element e;
9cfb40
+	checker_t *checker;
9cfb40
+	checker_id_t *id;
9cfb40
+
9cfb40
+	/* Notes: It's a provisional implementation */
9cfb40
+	(void)old_rs;
9cfb40
+	for (e = LIST_HEAD(checkers_queue); e; ELEMENT_NEXT(e)) {
9cfb40
+		checker = ELEMENT_DATA(e);
9cfb40
+		if (checker->rs == new_rs) {
9cfb40
+			id = (checker_id_t *) MALLOC(sizeof(checker_id_t));
9cfb40
+			*id = checker->id;
9cfb40
+			list_add(new_rs->failed_checkers, id);
9cfb40
+		}
9cfb40
+	}
9cfb40
+}
9cfb40
+
9cfb40
 /* Clear the diff rs of the old vs */
9cfb40
 static void
9cfb40
-clear_diff_rs(virtual_server_t * old_vs, list new_rs_list)
9cfb40
+clear_diff_rs(virtual_server_t *old_vs, virtual_server_t *new_vs)
9cfb40
 {
9cfb40
 	element e;
9cfb40
 	list l = old_vs->rs;
9cfb40
@@ -639,7 +658,7 @@ clear_diff_rs(virtual_server_t * old_vs, list new_rs_list)
9cfb40
 	list rs_to_remove = alloc_list (NULL, NULL);
9cfb40
 	for (e = LIST_HEAD(l); e; ELEMENT_NEXT(e)) {
9cfb40
 		rs = ELEMENT_DATA(e);
9cfb40
-		new_rs = rs_exist(rs, new_rs_list);
9cfb40
+		new_rs = rs_exist(rs, new_vs->rs);
9cfb40
 		if (!new_rs) {
9cfb40
 			/* Reset inhibit flag to delete inhibit entries */
9cfb40
 			log_message(LOG_INFO, "service %s no longer exist"
9cfb40
@@ -662,20 +681,15 @@ clear_diff_rs(virtual_server_t * old_vs, list new_rs_list)
9cfb40
 				free_list_elements(new_rs->failed_checkers);
9cfb40
 			} else {
9cfb40
 				/*
9cfb40
-				 * if not alive, we must copy the failed checker list
9cfb40
+				 * if not alive, we must migrate the failed checker list
9cfb40
 				 * If we do not, the new RS is in a state where it’s reported
9cfb40
 				 * as down with no check failed. As a result, the server will never
9cfb40
 				 * be put up back when it’s alive again in check_tcp.c#83 because
9cfb40
 				 * of the check that put a rs up only if it was not previously up
9cfb40
 				 * based on the failed_checkers list
9cfb40
 				 */
9cfb40
-				element hc_e;
9cfb40
-				list hc_l = rs->failed_checkers;
9cfb40
-				list new_hc_l = new_rs->failed_checkers;
9cfb40
-				for (hc_e = LIST_HEAD(hc_l); hc_e; ELEMENT_NEXT(hc_e)) {
9cfb40
-					list_add(new_hc_l, ELEMENT_DATA(hc_e));
9cfb40
-					ELEMENT_DATA(hc_e) = NULL;
9cfb40
-				}
9cfb40
+				if (!new_vs->alpha)
9cfb40
+					migrate_failed_checkers(rs, new_rs);
9cfb40
 			}
9cfb40
 		}
9cfb40
 	}
9cfb40
@@ -748,7 +762,7 @@ clear_diff_services(void)
9cfb40
 			/* omega = false must not prevent the notifiers from being called,
9cfb40
 			   because the VS still exists in new configuration */
9cfb40
 			vs->omega = true;
9cfb40
-			clear_diff_rs(vs, new_vs->rs);
9cfb40
+			clear_diff_rs(vs, new_vs);
9cfb40
 			clear_diff_s_srv(vs, new_vs->s_svr);
9cfb40
 		}
9cfb40
 	}
9cfb40
-- 
9cfb40
2.20.1
9cfb40