Skip to content

Commit 80b26ee

Browse files
committed
Better selection for a nodes with ceph-mds and ceph-calamari roles.
We cannot use standard select_nodes_for_role method for ceph-mds role because it limits the search for available nodes to maximum of 'count', which is a number that is defined in role_constraints for each role. We also don't want to remove that count for ceph-mds, because is also used to limit user when manually assigning role. Also, make sure ceph-calamari is not deployed to cluster node.
1 parent 0c6d6bf commit 80b26ee

File tree

1 file changed

+30
-15
lines changed

1 file changed

+30
-15
lines changed

crowbar_framework/app/models/ceph_service.rb

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,27 @@ def proposal_dependencies(role)
106106
answer
107107
end
108108

109+
# Helper to find a suitable node for ceph-mds role.
110+
# ceph-mds conflicts with ceph-osd, and should not be assigned to the cluster node
111+
def select_node_for_mds_role(nodes)
112+
# do not modify array given by caller
113+
mds_nodes = nodes.dup
114+
mds_nodes.delete_if(&:nil?)
115+
mds_nodes.reject! do |n|
116+
node_is_valid_for_role(n.name, "ceph-mds")
117+
end
118+
119+
mds_node = mds_nodes.find { |n| n.intended_role != "controller" }
120+
if mds_node.nil? && !mds_nodes.empty?
121+
mds_node = mds_nodes.first
122+
@logger.debug("Not enough nodes: putting ceph-mds on controller node (unsupported scenario)")
123+
end
124+
if mds_node.nil?
125+
@logger.warn("Not enough nodes: there seems to be no node for ceph-mds role!")
126+
end
127+
mds_node
128+
end
129+
109130
def create_proposal
110131
@logger.debug("Ceph create_proposal: entering")
111132
base = super
@@ -116,14 +137,17 @@ def create_proposal
116137

117138
base["attributes"][@bc_name]["keystone_instance"] = find_dep_proposal("keystone", true)
118139

119-
nodes = NodeObject.all
140+
nodes = NodeObject.all.reject do |n|
141+
# Do not deploy any ceph roles to the nodes in HA cluster
142+
n.roles.include?("pacemaker-cluster-member")
143+
end
120144

121145
osd_nodes = select_nodes_for_role(nodes, "ceph-osd", "storage")
122146
if osd_nodes.size < 2
123147
osd_nodes_all = select_nodes_for_role(nodes, "ceph-osd")
124148
# avoid controllers if possible (ceph should not be used with openstack roles)
125149
osd_nodes_no_controller = osd_nodes_all.reject do |n|
126-
n.intended_role == "controller" || n.roles.include?("pacemaker-cluster-member")
150+
n.intended_role == "controller"
127151
end
128152
osd_nodes = [osd_nodes, osd_nodes_no_controller, osd_nodes_all].flatten.uniq(&:name)
129153
osd_nodes = osd_nodes.take(2)
@@ -133,30 +157,21 @@ def create_proposal
133157

134158
if mon_nodes.size < 3
135159
mon_nodes_more = select_nodes_for_role(nodes, "ceph-mon").reject do |n|
136-
n.intended_role == "controller" || n.roles.include?("pacemaker-cluster-member")
160+
n.intended_role == "controller"
137161
end
138162
mon_nodes = [mon_nodes, mon_nodes_more].flatten.uniq(&:name)
139163
end
140164
mon_nodes = mon_nodes.take(mon_nodes.length > 2 ? 3 : 1)
141165

142-
mds_node = select_nodes_for_role(nodes, "ceph-mds").reject do |n|
143-
n.intended_role == "controller" or osd_nodes.include? n or n.roles.include?("pacemaker-cluster-member")
144-
end.first
145-
if mds_node.nil?
146-
mds_node = select_nodes_for_role(nodes, "ceph-mds", "controller").first
147-
@logger.debug("Not enought nodes: putting ceph-mds on controller node (unsupported scenario)")
148-
end
166+
mds_node = select_node_for_mds_role(nodes - osd_nodes)
149167

150168
radosgw_node = select_nodes_for_role(nodes, "ceph-radosgw", "storage").first
151169

152170
# Any spare node after allocating mons and osds is fair game
153171
# to automatically use as the calamari server
154-
calamari_nodes = select_nodes_for_role(nodes, "ceph-calamari")
172+
calamari_nodes = select_nodes_for_role(nodes - osd_nodes - mon_nodes, "ceph-calamari")
155173
calamari_nodes.reject! do |n|
156-
osd_nodes.include? n or
157-
mon_nodes.include? n or
158-
mds_node.name == n.name or
159-
n.intended_role == "controller"
174+
(!mds_node.nil? && mds_node.name == n.name) || n.intended_role == "controller"
160175
end
161176
calamari_node = calamari_nodes.first
162177

0 commit comments

Comments
 (0)