Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ source "https://rubygems.org"
gem "sprockets-standalone", "~> 1.2.1"

group :development do
gem "rake", "< 12.0.0"
gem "closure-compiler", "~> 1.1.10"
gem "sass", "~> 3.2.19"
gem "sprockets", "~> 2.11.0"
Expand Down
5 changes: 4 additions & 1 deletion chef/cookbooks/crowbar-pacemaker/recipes/drbd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,7 @@
lvm_group lvm_group
end

include_recipe "drbd::default"
# Disable drbd as it should never be started on boot (pacemaker should do it)
service "drbd" do
action :disable
end
55 changes: 24 additions & 31 deletions chef/cookbooks/drbd/providers/resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
raise "Remote node #{remote_host} not found!" if remote_nodes.empty?
remote = remote_nodes.first

template "/etc/drbd.d/#{name}.res" do
drbd_resource_template = template "/etc/drbd.d/#{name}.res" do
cookbook "drbd"
source "resource.erb"
variables(
Expand All @@ -47,45 +47,35 @@
owner "root"
group "root"
action :nothing
end.run_action(:create)
end
drbd_resource_template.run_action(:create)

# first pass only, initialize drbd
# for disks re-usage from old resources we will run with force option
p = execute "drbdadm -- --force create-md #{name}" do
only_if do
overview = DrbdOverview.get(name)
!overview.nil? && overview["state"] == "Unconfigured"
end
drbdadm_create_md = execute "drbdadm -- --force create-md #{name}" do
only_if { drbd_resource_template.updated_by_last_action? }
action :nothing
end
p.run_action(:run)
drbdadm_create_md.run_action(:run)

if p.updated_by_last_action?
# we would usually do something like:
# notifies :restart, "service[drbd]", :immediately
# in the execute above; but the notification doesn't work (probably because
# we're already in a LWRP). So we hack around this.
service "drbd(#{name})" do
service_name "drbd"
action :nothing
end.run_action(:restart)
drbdadm_up = execute "drbdadm up #{name}" do
only_if { drbd_resource_template.updated_by_last_action? }
action :nothing
end
drbdadm_up.run_action(:run)

overview = DrbdOverview.get(name)
if !overview.nil? && overview["state"] != "Unconfigured" && overview["primary"].nil?
# claim primary based off of master
execute "drbdadm -- --overwrite-data-of-peer primary #{name}" do
only_if { master }
action :nothing
end.run_action(:run)
# claim primary based off of master
execute "drbdadm -- --overwrite-data-of-peer primary #{name}" do
only_if { drbd_resource_template.updated_by_last_action? && master }
action :nothing
end.run_action(:run)

# you may now create a filesystem on the device, use it as a raw block device
# for disks re-usage from old resources we will run with force option
execute "mkfs -t #{fstype} -f #{device}" do
only_if { master }
action :nothing
end.run_action(:run)
end
# you may now create a filesystem on the device, use it as a raw block device
# for disks re-usage from old resources we will run with force option
execute "mkfs -t #{fstype} -f #{device}" do
only_if { drbd_resource_template.updated_by_last_action? && master }
action :nothing
end.run_action(:run)

unless mount.nil? or mount.empty?
directory mount do
Expand All @@ -100,7 +90,10 @@
action :nothing
end.run_action(:mount)
end
end

action :wait do
name = new_resource.name
begin
Timeout.timeout(20) do
while true
Expand Down
2 changes: 1 addition & 1 deletion chef/cookbooks/drbd/resources/resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# limitations under the License.
#

actions :create
actions :create, :wait
default_action :create

attribute :name, kind_of: String, name_attribute: true
Expand Down
1 change: 1 addition & 0 deletions chef/cookbooks/pacemaker/Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
source "https://rubygems.org"

#gem 'berkshelf', '~> 2.0'
gem "rack", "< 2.0.0"
gem "rake"

group :test, :development do
Expand Down
3 changes: 2 additions & 1 deletion crowbar_framework/app/models/pacemaker_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ def apply_cluster_roles_to_new_nodes_for(cluster_element, relevant_nodes, all_ro
end

expanded_nodes.sort!
old_expanded_nodes = deployment["elements_expanded"][role_name].sort
old_expanded_nodes = deployment["elements_expanded"][role_name] || []
old_expanded_nodes.sort!

if old_expanded_nodes != expanded_nodes
deployment["elements_expanded"][role_name] = expanded_nodes
Expand Down