Blame SOURCES/0016-Keepalived-add-more-virtual-real-server-settings-and.patch

c537d4
From 6eba1a21df59cc1638a2047f24080ebe657b497e Mon Sep 17 00:00:00 2001
c537d4
From: Dominic Cleal <dcleal@redhat.com>
c537d4
Date: Fri, 21 Feb 2014 10:56:57 +0000
c537d4
Subject: [PATCH 2/3] Keepalived: add more virtual/real server settings and
c537d4
 checks
c537d4
c537d4
Fixes RHBZ#1064388
c537d4
c537d4
(cherry picked from commit 1f6ec69ffcd46a5b6937025973a2f2337df2727d)
c537d4
c537d4
Conflicts:
c537d4
	NEWS
c537d4
---
c537d4
 lenses/keepalived.aug            |  81 +++++++++++++++++++++++--
c537d4
 lenses/tests/test_keepalived.aug | 128 +++++++++++++++++++++++++++++++++++++++
c537d4
 2 files changed, 203 insertions(+), 6 deletions(-)
c537d4
c537d4
diff --git a/lenses/keepalived.aug b/lenses/keepalived.aug
c537d4
index 1fe3aa2..9fd02ff 100644
c537d4
--- a/lenses/keepalived.aug
c537d4
+++ b/lenses/keepalived.aug
c537d4
@@ -83,6 +83,10 @@ let field (kw:regexp) (sto:lens) = indent . Build.key_value_line_comment kw sep_
c537d4
 A single word *)
c537d4
 let flag (kw:regexp) = [ indent . key kw . comment_or_eol ]
c537d4
 
c537d4
+(* View: ip_port
c537d4
+   An IP <space> port pair *)
c537d4
+let ip_port = [ label "ip" . sto_word ] . sep_spc . [ label "port" . sto_num ]
c537d4
+
c537d4
 (* View: lens_block 
c537d4
 A generic block with a title lens.
c537d4
 The definition is very similar to Build.block_newlines
c537d4
@@ -220,22 +224,87 @@ let vrrpd_conf = vrrp_sync_group | vrrp_instance | vrrp_script
c537d4
 
c537d4
 
c537d4
 (************************************************************************
c537d4
- * Group:                 LVS CONFIGURATION
c537d4
+ * Group:                 REAL SERVER CHECKS CONFIGURATION
c537d4
  *************************************************************************)
c537d4
 
c537d4
 (* View: tcp_check_field *)
c537d4
-let tcp_check_field = field /connect_(timeout|port)/ sto_num
c537d4
+let tcp_check_field =
c537d4
+      let word_re = "bindto"
c537d4
+   in let num_re = /connect_(timeout|port)/
c537d4
+   in field word_re sto_word
c537d4
+    | field num_re sto_num
c537d4
+
c537d4
+(* View: misc_check_field *)
c537d4
+let misc_check_field =
c537d4
+      let flag_re = "misc_dynamic"
c537d4
+   in let num_re = "misc_timeout"
c537d4
+   in let to_eol_re = "misc_path"
c537d4
+   in field num_re sto_num
c537d4
+    | flag flag_re
c537d4
+    | field to_eol_re sto_to_eol
c537d4
+
c537d4
+(* View: smtp_host_check_field *)
c537d4
+let smtp_host_check_field =
c537d4
+      let word_re = "connect_ip" | "bindto"
c537d4
+   in let num_re = "connect_port"
c537d4
+   in field word_re sto_word
c537d4
+    | field num_re sto_num
c537d4
+
c537d4
+(* View: smtp_check_field *)
c537d4
+let smtp_check_field =
c537d4
+      let word_re = "connect_ip" | "bindto"
c537d4
+   in let num_re = "connect_timeout" | "retry" | "delay_before_retry"
c537d4
+   in let to_eol_re = "helo_name"
c537d4
+   in field word_re sto_word
c537d4
+    | field num_re sto_num
c537d4
+    | field to_eol_re sto_to_eol
c537d4
+    | block "host" smtp_host_check_field
c537d4
+
c537d4
+(* View: http_url_check_field *)
c537d4
+let http_url_check_field =
c537d4
+      let word_re = "digest"
c537d4
+   in let num_re = "status_code"
c537d4
+   in let to_eol_re = "path"
c537d4
+   in field word_re sto_word
c537d4
+    | field num_re sto_num
c537d4
+    | field to_eol_re sto_to_eol
c537d4
+
c537d4
+(* View: http_check_field *)
c537d4
+let http_check_field =
c537d4
+      let num_re = /connect_(timeout|port)/ | "nb_get_retry" | "delay_before_retry"
c537d4
+   in field num_re sto_num
c537d4
+    | block "url" http_url_check_field
c537d4
 
c537d4
 (* View: real_server_field *)
c537d4
-let real_server_field = field "weight" sto_num
c537d4
-                      | block "TCP_CHECK" tcp_check_field
c537d4
+let real_server_field =
c537d4
+      let num_re = "weight"
c537d4
+   in let flag_re = "inhibit_on_failure"
c537d4
+   in let to_eol_re = /notify_(up|down)/
c537d4
+   in field num_re sto_num
c537d4
+    | flag flag_re
c537d4
+    | field to_eol_re sto_to_eol
c537d4
+    | block "TCP_CHECK" tcp_check_field
c537d4
+    | block "MISC_CHECK" misc_check_field
c537d4
+    | block "SMTP_CHECK" smtp_check_field
c537d4
+    | block /(HTTP|SSL)_GET/ http_check_field
c537d4
+
c537d4
+(************************************************************************
c537d4
+ * Group:                 LVS CONFIGURATION
c537d4
+ *************************************************************************)
c537d4
 
c537d4
 (* View: virtual_server_field *)
c537d4
 let virtual_server_field =
c537d4
-      let num_re = "delay_loop"
c537d4
-   in let word_re = /lb_(algo|kind)/ | "nat_mask" | "protocol"
c537d4
+      let num_re = "delay_loop" | "persistence_timeout" | "quorum" | "hysteresis"
c537d4
+   in let word_re = /lb_(algo|kind)/ | "nat_mask" | "protocol" | "persistence_granularity"
c537d4
+                      | "virtualhost"
c537d4
+   in let flag_re = "ops" | "ha_suspend" | "alpha" | "omega"
c537d4
+   in let to_eol_re = /quorum_(up|down)/
c537d4
+   in let ip_port_re = "sorry_server"
c537d4
    in field num_re sto_num
c537d4
     | field word_re sto_word
c537d4
+    | flag flag_re
c537d4
+    | field to_eol_re sto_to_eol
c537d4
+    | field ip_port_re ip_port
c537d4
     | named_block_arg "real_server" "ip" "port" real_server_field
c537d4
 
c537d4
 (* View: virtual_server *)
c537d4
diff --git a/lenses/tests/test_keepalived.aug b/lenses/tests/test_keepalived.aug
c537d4
index 615509e..371df25 100644
c537d4
--- a/lenses/tests/test_keepalived.aug
c537d4
+++ b/lenses/tests/test_keepalived.aug
c537d4
@@ -118,6 +118,8 @@ virtual_server 192.168.1.11 22 {
c537d4
 
c537d4
     protocol TCP 
c537d4
 
c537d4
+    sorry_server 10.20.40.30 22
c537d4
+
c537d4
     ! there can be as many real_server blocks as you need 
c537d4
 
c537d4
     real_server 10.20.40.10 22 { 
c537d4
@@ -269,6 +271,10 @@ weight 2                        # add 2 points of prio if OK
c537d4
          { }
c537d4
          { "protocol" = "TCP" }
c537d4
          { }
c537d4
+         { "sorry_server"
c537d4
+           { "ip" = "10.20.40.30" }
c537d4
+           { "port" = "22" } }
c537d4
+         { }
c537d4
          { "#comment" = "there can be as many real_server blocks as you need" }
c537d4
          { }
c537d4
          { "real_server"
c537d4
@@ -312,3 +318,125 @@ weight 2                        # add 2 points of prio if OK
c537d4
        { }
c537d4
        { "#comment" = "that's all" }
c537d4
 
c537d4
+(* Variable: tcp_check
c537d4
+   An example of a TCP health checker *)
c537d4
+let tcp_check = "virtual_server 192.168.1.11 22 {
c537d4
+    real_server 10.20.40.10 22 {
c537d4
+        TCP_CHECK {
c537d4
+            connect_timeout 3
c537d4
+            connect_port 22
c537d4
+            bindto 192.168.1.1
c537d4
+        }
c537d4
+    }
c537d4
+}
c537d4
+"
c537d4
+test Keepalived.lns get tcp_check =
c537d4
+  { "virtual_server"
c537d4
+    { "ip" = "192.168.1.11" }
c537d4
+    { "port" = "22" }
c537d4
+    { "real_server"
c537d4
+      { "ip" = "10.20.40.10" }
c537d4
+      { "port" = "22" }
c537d4
+      { "TCP_CHECK"
c537d4
+        { "connect_timeout" = "3" }
c537d4
+        { "connect_port" = "22" }
c537d4
+        { "bindto" = "192.168.1.1" } } } }
c537d4
+
c537d4
+(* Variable: misc_check
c537d4
+   An example of a MISC health checker *)
c537d4
+let misc_check = "virtual_server 192.168.1.11 22 {
c537d4
+    real_server 10.20.40.10 22 {
c537d4
+        MISC_CHECK {
c537d4
+            misc_path /usr/local/bin/server_test
c537d4
+            misc_timeout 3
c537d4
+            misc_dynamic
c537d4
+        }
c537d4
+    }
c537d4
+}
c537d4
+"
c537d4
+test Keepalived.lns get misc_check =
c537d4
+  { "virtual_server"
c537d4
+    { "ip" = "192.168.1.11" }
c537d4
+    { "port" = "22" }
c537d4
+    { "real_server"
c537d4
+      { "ip" = "10.20.40.10" }
c537d4
+      { "port" = "22" }
c537d4
+      { "MISC_CHECK"
c537d4
+        { "misc_path" = "/usr/local/bin/server_test" }
c537d4
+        { "misc_timeout" = "3" }
c537d4
+        { "misc_dynamic" } } } }
c537d4
+
c537d4
+(* Variable: smtp_check
c537d4
+   An example of an SMTP health checker *)
c537d4
+let smtp_check = "virtual_server 192.168.1.11 22 {
c537d4
+    real_server 10.20.40.10 22 {
c537d4
+        SMTP_CHECK {
c537d4
+            host {
c537d4
+              connect_ip 10.20.40.11
c537d4
+              connect_port 587
c537d4
+              bindto 192.168.1.1
c537d4
+            }
c537d4
+            connect_timeout 3
c537d4
+            retry 5
c537d4
+            delay_before_retry 10
c537d4
+            helo_name \"Testing Augeas\"
c537d4
+        }
c537d4
+    }
c537d4
+}
c537d4
+"
c537d4
+test Keepalived.lns get smtp_check =
c537d4
+  { "virtual_server"
c537d4
+    { "ip" = "192.168.1.11" }
c537d4
+    { "port" = "22" }
c537d4
+    { "real_server"
c537d4
+      { "ip" = "10.20.40.10" }
c537d4
+      { "port" = "22" }
c537d4
+      { "SMTP_CHECK"
c537d4
+        { "host"
c537d4
+          { "connect_ip" = "10.20.40.11" }
c537d4
+          { "connect_port" = "587" }
c537d4
+          { "bindto" = "192.168.1.1" } }
c537d4
+        { "connect_timeout" = "3" }
c537d4
+        { "retry" = "5" }
c537d4
+        { "delay_before_retry" = "10" }
c537d4
+        { "helo_name" = "\"Testing Augeas\"" } } } }
c537d4
+
c537d4
+(* Variable: http_check
c537d4
+   An example of an HTTP health checker *)
c537d4
+let http_check = "virtual_server 192.168.1.11 22 {
c537d4
+    real_server 10.20.40.10 22 {
c537d4
+        HTTP_GET {
c537d4
+            url {
c537d4
+              path /mrtg2/
c537d4
+              digest 9b3a0c85a887a256d6939da88aabd8cd
c537d4
+              status_code 200
c537d4
+            }
c537d4
+            connect_timeout 3
c537d4
+            connect_port 8080
c537d4
+            nb_get_retry 5
c537d4
+            delay_before_retry 10
c537d4
+        }
c537d4
+        SSL_GET {
c537d4
+            connect_port 8443
c537d4
+        }
c537d4
+    }
c537d4
+}
c537d4
+"
c537d4
+test Keepalived.lns get http_check =
c537d4
+  { "virtual_server"
c537d4
+    { "ip" = "192.168.1.11" }
c537d4
+    { "port" = "22" }
c537d4
+    { "real_server"
c537d4
+      { "ip" = "10.20.40.10" }
c537d4
+      { "port" = "22" }
c537d4
+      { "HTTP_GET"
c537d4
+        { "url"
c537d4
+          { "path" = "/mrtg2/" }
c537d4
+          { "digest" = "9b3a0c85a887a256d6939da88aabd8cd" }
c537d4
+          { "status_code" = "200" } }
c537d4
+        { "connect_timeout" = "3" }
c537d4
+        { "connect_port" = "8080" }
c537d4
+        { "nb_get_retry" = "5" }
c537d4
+        { "delay_before_retry" = "10" } }
c537d4
+      { "SSL_GET"
c537d4
+        { "connect_port" = "8443" } } } }
c537d4
-- 
c537d4
1.8.5.3
c537d4