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