Add IP to HAProxy kind=Optional constraint
authorGiulio Fidente <gfidente@redhat.com>
Thu, 2 Jul 2015 15:15:07 +0000 (17:15 +0200)
committerGiulio Fidente <gfidente@redhat.com>
Fri, 3 Jul 2015 06:46:56 +0000 (08:46 +0200)
Without the constraint the VIP could get assigned to a node without
an active haproxy instance, which ultimately means everything stops
working.

kind=Optional allows a VIP to relocate to a healthy haproxy instance
in the event of a failure without tearing down the entire stack in the
process.

Change-Id: I44d44952fb42cf91a2a248250a4063e3034d119e

puppet/manifests/overcloud_controller_pacemaker.pp

index 6dbed84..e3f0206 100644 (file)
@@ -175,13 +175,78 @@ if hiera('step') >= 2 {
     # parameters here to configure pacemaker VIPs. The configuration
     # of pacemaker VIPs could move into puppet-tripleo or we should
     # make use of less specific hiera parameters here for the settings.
+    pacemaker::resource::service { 'haproxy':
+      clone_params => true,
+    }
+
     $control_vip = hiera('tripleo::loadbalancer::controller_virtual_ip')
     pacemaker::resource::ip { 'control_vip':
       ip_address => $control_vip,
     }
+    pacemaker::constraint::base { 'control_vip-then-haproxy':
+      constraint_type   => 'order',
+      first_resource    => "ip-${control_vip}",
+      second_resource   => 'haproxy-clone',
+      first_action      => 'start',
+      second_action     => 'start',
+      constraint_params => 'kind=Optional',
+      require => [Pacemaker::Resource::Service['haproxy'],
+                  Pacemaker::Resource::Ip['control_vip']],
+    }
+    pacemaker::constraint::colocation { 'control_vip-with-haproxy':
+      source  => "ip-${control_vip}",
+      target  => 'haproxy-clone',
+      score   => 'INFINITY',
+      require => [Pacemaker::Resource::Service['haproxy'],
+                  Pacemaker::Resource::Ip['control_vip']],
+    }
+
     $public_vip = hiera('tripleo::loadbalancer::public_virtual_ip')
-    pacemaker::resource::ip { 'public_vip':
-      ip_address => $public_vip,
+    if $public_vip and $public_vip != $control_vip {
+      pacemaker::resource::ip { 'public_vip':
+        ip_address => $public_vip,
+      }
+      pacemaker::constraint::base { 'public_vip-then-haproxy':
+        constraint_type   => 'order',
+        first_resource    => "ip-${public_vip}",
+        second_resource   => 'haproxy-clone',
+        first_action      => 'start',
+        second_action     => 'start',
+        constraint_params => 'kind=Optional',
+        require => [Pacemaker::Resource::Service['haproxy'],
+                    Pacemaker::Resource::Ip['public_vip']],
+      }
+      pacemaker::constraint::colocation { 'public_vip-with-haproxy':
+        source  => "ip-${public_vip}",
+        target  => 'haproxy-clone',
+        score   => 'INFINITY',
+        require => [Pacemaker::Resource::Service['haproxy'],
+                    Pacemaker::Resource::Ip['public_vip']],
+      }
+    }
+
+    $redis_vip = hiera('redis_vip')
+    if $redis_vip and $redis_vip != $control_vip {
+      pacemaker::resource::ip { 'redis_vip':
+        ip_address => $redis_vip,
+      }
+      pacemaker::constraint::base { 'redis_vip-then-haproxy':
+        constraint_type   => 'order',
+        first_resource    => "ip-${redis_vip}",
+        second_resource   => 'haproxy-clone',
+        first_action      => 'start',
+        second_action     => 'start',
+        constraint_params => 'kind=Optional',
+        require => [Pacemaker::Resource::Service['haproxy'],
+                    Pacemaker::Resource::Ip['redis_vip']],
+      }
+      pacemaker::constraint::colocation { 'redis_vip-with-haproxy':
+        source  => "ip-${redis_vip}",
+        target  => 'haproxy-clone',
+        score   => 'INFINITY',
+        require => [Pacemaker::Resource::Service['haproxy'],
+                    Pacemaker::Resource::Ip['redis_vip']],
+      }
     }
 
     $internal_api_vip = hiera('tripleo::loadbalancer::internal_api_virtual_ip')
@@ -189,6 +254,23 @@ if hiera('step') >= 2 {
       pacemaker::resource::ip { 'internal_api_vip':
         ip_address => $internal_api_vip,
       }
+      pacemaker::constraint::base { 'internal_api_vip-then-haproxy':
+        constraint_type   => 'order',
+        first_resource    => "ip-${internal_api_vip}",
+        second_resource   => 'haproxy-clone',
+        first_action      => 'start',
+        second_action     => 'start',
+        constraint_params => 'kind=Optional',
+        require => [Pacemaker::Resource::Service['haproxy'],
+                    Pacemaker::Resource::Ip['internal_api_vip']],
+      }
+      pacemaker::constraint::colocation { 'internal_api_vip-with-haproxy':
+        source  => "ip-${internal_api_vip}",
+        target  => 'haproxy-clone',
+        score   => 'INFINITY',
+        require => [Pacemaker::Resource::Service['haproxy'],
+                    Pacemaker::Resource::Ip['internal_api_vip']],
+      }
     }
 
     $storage_vip = hiera('tripleo::loadbalancer::storage_virtual_ip')
@@ -196,6 +278,23 @@ if hiera('step') >= 2 {
       pacemaker::resource::ip { 'storage_vip':
         ip_address => $storage_vip,
       }
+      pacemaker::constraint::base { 'storage_vip-then-haproxy':
+        constraint_type   => 'order',
+        first_resource    => "ip-${storage_vip}",
+        second_resource   => 'haproxy-clone',
+        first_action      => 'start',
+        second_action     => 'start',
+        constraint_params => 'kind=Optional',
+        require => [Pacemaker::Resource::Service['haproxy'],
+                    Pacemaker::Resource::Ip['storage_vip']],
+      }
+      pacemaker::constraint::colocation { 'storage_vip-with-haproxy':
+        source  => "ip-${storage_vip}",
+        target  => 'haproxy-clone',
+        score   => 'INFINITY',
+        require => [Pacemaker::Resource::Service['haproxy'],
+                    Pacemaker::Resource::Ip['storage_vip']],
+      }
     }
 
     $storage_mgmt_vip = hiera('tripleo::loadbalancer::storage_mgmt_virtual_ip')
@@ -203,11 +302,25 @@ if hiera('step') >= 2 {
       pacemaker::resource::ip { 'storage_mgmt_vip':
         ip_address => $storage_mgmt_vip,
       }
+      pacemaker::constraint::base { 'storage_mgmt_vip-then-haproxy':
+        constraint_type   => 'order',
+        first_resource    => "ip-${storage_mgmt_vip}",
+        second_resource   => 'haproxy-clone',
+        first_action      => 'start',
+        second_action     => 'start',
+        constraint_params => 'kind=Optional',
+        require => [Pacemaker::Resource::Service['haproxy'],
+                    Pacemaker::Resource::Ip['storage_mgmt_vip']],
+      }
+      pacemaker::constraint::colocation { 'storage_mgmt_vip-with-haproxy':
+        source  => "ip-${storage_mgmt_vip}",
+        target  => 'haproxy-clone',
+        score   => 'INFINITY',
+        require => [Pacemaker::Resource::Service['haproxy'],
+                    Pacemaker::Resource::Ip['storage_mgmt_vip']],
+      }
     }
 
-    pacemaker::resource::service { 'haproxy':
-      clone_params => true,
-    }
     pacemaker::resource::service { $::memcached::params::service_name :
       clone_params => true,
       require      => Class['::memcached'],
@@ -255,12 +368,6 @@ if hiera('step') >= 2 {
       resource_params => 'wait_last_known_master=true',
       require         => Class['::redis'],
     }
-    $redis_vip = hiera('redis_vip')
-    if $redis_vip and $redis_vip != $control_vip {
-        pacemaker::resource::ip { 'vip-redis':
-          ip_address => $redis_vip,
-        }
-    }
 
   }