The Puppet Labs Issue Tracker has Moved: https://tickets.puppetlabs.com

Bug #15162

Corosync prefetch fails if service is stopped prior to puppet run

Added by Trey Dockendorf over 2 years ago. Updated almost 2 years ago.

Status:UnreviewedStart date:06/22/2012
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:corosyncSpent time:-
Target version:-
Keywords: Branch:

We've Moved!

Ticket tracking is now hosted in JIRA: https://tickets.puppetlabs.com

This ticket may be automatically exported to the MODULES project on JIRA using the button below:


Description

In testing and getting the corosync module deployed I’ve found that if I define the corosync class and also any types, the puppet run fails on prefetch with this until the 120 second time out

debug: Prefetching crm resources for cs_property
debug: Executing '/usr/sbin/crm_attribute --type crm_config --query --name dc-version'
debug: Puppet::Type::Cs_property::ProviderCrm: Corosync not ready, retrying

The only way I’ve found to avoid this is to first define the corosync class, run puppet, then define the custom types

  
  class { 'corosync':
    enable_secauth    => false,
    bind_address      => '172.0.0.100',
    multicast_address => '226.94.1.1',
  }

  corosync::service { 'pacemaker':
    version => '1',
    notify  => Service['corosync'],
  }

 # Run puppet on client to apply above

  Cs_property {
    ensure  => present,
  }

  cs_property { 'stonith-enabled':              value   => 'false', }
  cs_property { 'no-quorum-policy':             value   => 'ignore', }
  cs_property { 'default-resource-stickiness':  value   => '200', }

In an attempt to solve this I made each type autorequire service ‘corosync’, but the prefetch still fails. So far I have this patch with one error generated

# The error
debug: Prefetching crm resources for cs_property
debug: Executing '/usr/sbin/crm configure show xml'
err: Could not prefetch cs_property provider 'crm': undefined method `elements' for nil:NilClass
# The patch thus far
<pre>
diff --git a/lib/puppet/provider/corosync.rb b/lib/puppet/provider/corosync.rb
index 332b7ac..852f53f 100644
--- a/lib/puppet/provider/corosync.rb
+++ b/lib/puppet/provider/corosync.rb
@@ -47,7 +47,7 @@ class Puppet::Provider::Corosync < Puppet::Provider
end
def exists?
-    self.class.block_until_ready
+#    self.class.block_until_ready
debug(@property_hash.inspect)
!(@property_hash[:ensure] == :absent or @property_hash.empty?)
end
diff --git a/lib/puppet/provider/cs_colocation/crm.rb b/lib/puppet/provider/cs_colocation/crm.rb
index 4d913c6..10640c3 100644
--- a/lib/puppet/provider/cs_colocation/crm.rb
+++ b/lib/puppet/provider/cs_colocation/crm.rb
@@ -11,7 +11,7 @@ Puppet::Type.type(:cs_colocation).provide(:crm, :parent => Puppet::Provider::Cor
def self.instances
-    block_until_ready
+#    block_until_ready
instances = []
diff --git a/lib/puppet/provider/cs_order/crm.rb b/lib/puppet/provider/cs_order/crm.rb
index 68d3521..1664098 100644
--- a/lib/puppet/provider/cs_order/crm.rb
+++ b/lib/puppet/provider/cs_order/crm.rb
@@ -11,7 +11,7 @@ Puppet::Type.type(:cs_order).provide(:crm, :parent => Puppet::Provider::Corosync
def self.instances
-    block_until_ready
+#    block_until_ready
instances = []
diff --git a/lib/puppet/provider/cs_primitive/crm.rb b/lib/puppet/provider/cs_primitive/crm.rb
index bc89fb7..d758bd0 100644
--- a/lib/puppet/provider/cs_primitive/crm.rb
+++ b/lib/puppet/provider/cs_primitive/crm.rb
@@ -14,7 +14,7 @@ Puppet::Type.type(:cs_primitive).provide(:crm, :parent => Puppet::Provider::Coro
def self.instances
-    block_until_ready
+#    block_until_ready
instances = []
diff --git a/lib/puppet/provider/cs_property/crm.rb b/lib/puppet/provider/cs_property/crm.rb
index d90e972..20eede4 100644
--- a/lib/puppet/provider/cs_property/crm.rb
+++ b/lib/puppet/provider/cs_property/crm.rb
@@ -11,7 +11,7 @@ Puppet::Type.type(:cs_property).provide(:crm, :parent => Puppet::Provider::Coros
def self.instances
-    block_until_ready
+#    block_until_ready
instances = []
diff --git a/lib/puppet/type/cs_colocation.rb b/lib/puppet/type/cs_colocation.rb
index 5de60a8..7e136e5 100644
--- a/lib/puppet/type/cs_colocation.rb
+++ b/lib/puppet/type/cs_colocation.rb
@@ -12,6 +12,10 @@ module Puppet
ensurable
+    autorequire(:service) do
+      ["corosync"]
+    end
+
newparam(:name) do
desc "Identifier of the colocation entry.  This value needs to be unique
across the entire Corosync/Pacemaker configuration since it doesn't have
diff --git a/lib/puppet/type/cs_order.rb b/lib/puppet/type/cs_order.rb
index 321dcf5..13f3fef 100644
--- a/lib/puppet/type/cs_order.rb
+++ b/lib/puppet/type/cs_order.rb
@@ -12,6 +12,10 @@ module Puppet
ensurable
+    autorequire(:service) do
+      ["corosync"]
+    end
+
newparam(:name) do
desc "Name identifier of this ordering entry.  This value needs to be unique
across the entire Corosync/Pacemaker configuration since it doesn't have
diff --git a/lib/puppet/type/cs_primitive.rb b/lib/puppet/type/cs_primitive.rb
index 8c75a1c..50ff8b4 100644
--- a/lib/puppet/type/cs_primitive.rb
+++ b/lib/puppet/type/cs_primitive.rb
@@ -17,6 +17,10 @@ module Puppet
ensurable
+    autorequire(:service) do
+      ["corosync"]
+    end
+
newparam(:name) do
desc "Name identifier of primitive.  This value needs to be unique
across the entire Corosync/Pacemaker configuration since it doesn't have
diff --git a/lib/puppet/type/cs_property.rb b/lib/puppet/type/cs_property.rb
index 3febb16..ae5847f 100644
--- a/lib/puppet/type/cs_property.rb
+++ b/lib/puppet/type/cs_property.rb
@@ -19,6 +19,10 @@ module Puppet
ensurable
+    autorequire(:service) do
+      ["corosync"]
+    end
+
newparam(:name) do
desc "Name identifier of this property.  Simply the name of the cluster
property.  Happily most of these are unique."

I really don’t like the above patch as the prefetch breaks. Is there maybe a way to ensure the service is started before prefetch or obtain the necessary information without the corosync service?

corosync_provider_type.patch Magnifier (5.3 KB) Trey Dockendorf, 06/22/2012 08:57 am

History

#1 Updated by Trey Dockendorf over 2 years ago

Provided a somewhat better patch that replaces crm configure show xml with a parse of /var/lib/heartbeat/crm/cib.xml. This ensures that the values can be read if the corosync services hasn’t yet been started. The path may be specific to EL6 (I’m on CentOS 6.2).

This may not be best practice, so please let me know what can be done to improve it and then I’ll submit a pull request if these changes look good.

#2 Updated by Adrian Allen almost 2 years ago

Thanks for the patch, it does indeed resolve this issue which was driving me nuts.

Also available in: Atom PDF