|
69 | 69 | end |
70 | 70 |
|
71 | 71 | if is_crowbar? |
72 | | - node.set["ceph"]["osd_devices"] = [] if node["ceph"]["osd_devices"].nil? |
| 72 | + dirty = false |
| 73 | + |
| 74 | + node.set["ceph"]["osd_devices"] ||= [] |
73 | 75 | min_size_blocks = node["ceph"]["osd"]["min_size_gb"] * 1024 * 1024 * 2 |
74 | 76 | unclaimed_disks = BarclampLibrary::Barclamp::Inventory::Disk.unclaimed(node).sort.select { |d| d.size >= min_size_blocks } |
75 | 77 |
|
76 | 78 | # if devices for journal are explicitely listed, do not use automatic journal assigning to SSD |
77 | 79 | if !node["ceph"]["osd"]["journal_devices"].empty? |
78 | | - node.set["ceph"]["osd"]["use_ssd_for_journal"] = false |
| 80 | + # explicit comparison because we don't want a condition that uses nil |
| 81 | + if node["ceph"]["osd"]["use_ssd_for_journal"] != false |
| 82 | + node.set["ceph"]["osd"]["use_ssd_for_journal"] = false |
| 83 | + dirty = true |
| 84 | + end |
79 | 85 | end |
80 | 86 |
|
81 | 87 | # If no OSDs have yet been deployed, check what type of disks are available. |
|
88 | 94 | has_ssds = unclaimed_disks.any? { |d| node[:block_device][d.name.gsub("/dev/", "")]["rotational"] == "0" } |
89 | 95 | has_hdds = unclaimed_disks.any? { |d| node[:block_device][d.name.gsub("/dev/", "")]["rotational"] == "1" } |
90 | 96 |
|
91 | | - node.set["ceph"]["osd"]["use_ssd_for_journal"] = false unless has_ssds && has_hdds |
| 97 | + use_ssd_for_journal = has_ssds && has_hdds |
| 98 | + if node["ceph"]["osd"]["use_ssd_for_journal"] != use_ssd_for_journal |
| 99 | + node.set["ceph"]["osd"]["use_ssd_for_journal"] = use_ssd_for_journal |
| 100 | + dirty = true |
| 101 | + end |
92 | 102 | end |
93 | 103 |
|
94 | 104 | if node["ceph"]["disk_mode"] == "first" && node["ceph"]["osd_devices"].empty? |
|
127 | 137 | end |
128 | 138 | device["device"] = d.name |
129 | 139 | node.set["ceph"]["osd_devices"].push(device) |
130 | | - node.save |
| 140 | + dirty = true |
131 | 141 | else |
132 | 142 | Chef::Log.info("Ceph: Ignoring #{d.name}") |
133 | 143 | end |
|
198 | 208 | end |
199 | 209 | end |
200 | 210 | end |
201 | | - node.set["ceph"]["osd_devices"][index]["status"] = "deployed" |
202 | | - node.set["ceph"]["osd_devices"][index]["journal"] = journal_device unless journal_device.nil? |
| 211 | + if node["ceph"]["osd_devices"][index]["status"] != "deployed" |
| 212 | + node.set["ceph"]["osd_devices"][index]["status"] = "deployed" |
| 213 | + dirty = true |
| 214 | + end |
| 215 | + # if journal_device is nil, this will still work as expected |
| 216 | + if node["ceph"]["osd_devices"][index]["journal"] != journal_device |
| 217 | + node.set["ceph"]["osd_devices"][index]["journal"] = journal_device |
| 218 | + dirty = true |
| 219 | + end |
203 | 220 |
|
204 | 221 | execute "Writing Ceph OSD device mappings to fstab" do |
205 | 222 | command "tail -n1 /etc/mtab >> /etc/fstab" |
|
209 | 226 | # No need to specifically enable ceph-osd@N on systemd systems, as this |
210 | 227 | # is done automatically by ceph-disk-activate |
211 | 228 | end |
212 | | - node.save |
213 | 229 |
|
214 | 230 | service "ceph_osd" do |
215 | 231 | case service_type |
|
234 | 250 | end |
235 | 251 | end |
236 | 252 | end |
| 253 | + |
| 254 | + node.save if dirty |
237 | 255 | end |
238 | 256 | end |
0 commit comments