-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Decrease the amount of node saves #101
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,13 +69,19 @@ | |
end | ||
|
||
if is_crowbar? | ||
node.set["ceph"]["osd_devices"] = [] if node["ceph"]["osd_devices"].nil? | ||
dirty = false | ||
|
||
node.set["ceph"]["osd_devices"] ||= [] | ||
min_size_blocks = node["ceph"]["osd"]["min_size_gb"] * 1024 * 1024 * 2 | ||
unclaimed_disks = BarclampLibrary::Barclamp::Inventory::Disk.unclaimed(node).sort.select { |d| d.size >= min_size_blocks } | ||
|
||
# if devices for journal are explicitely listed, do not use automatic journal assigning to SSD | ||
if !node["ceph"]["osd"]["journal_devices"].empty? | ||
node.set["ceph"]["osd"]["use_ssd_for_journal"] = false | ||
# explicit comparison because we don't want a condition that uses nil | ||
if node["ceph"]["osd"]["use_ssd_for_journal"] != false | ||
node.set["ceph"]["osd"]["use_ssd_for_journal"] = false | ||
dirty = true | ||
end | ||
end | ||
|
||
# If no OSDs have yet been deployed, check what type of disks are available. | ||
|
@@ -88,7 +94,11 @@ | |
has_ssds = unclaimed_disks.any? { |d| node[:block_device][d.name.gsub("/dev/", "")]["rotational"] == "0" } | ||
has_hdds = unclaimed_disks.any? { |d| node[:block_device][d.name.gsub("/dev/", "")]["rotational"] == "1" } | ||
|
||
node.set["ceph"]["osd"]["use_ssd_for_journal"] = false unless has_ssds && has_hdds | ||
use_ssd_for_journal = has_ssds && has_hdds | ||
if node["ceph"]["osd"]["use_ssd_for_journal"] != use_ssd_for_journal | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Metrics/BlockNesting: Avoid more than 3 levels of block nesting. (https://github.com/bbatsov/ruby-style-guide#three-is-the-number-thou-shalt-count) |
||
node.set["ceph"]["osd"]["use_ssd_for_journal"] = use_ssd_for_journal | ||
dirty = true | ||
end | ||
end | ||
|
||
if node["ceph"]["disk_mode"] == "first" && node["ceph"]["osd_devices"].empty? | ||
|
@@ -127,7 +137,7 @@ | |
end | ||
device["device"] = d.name | ||
node.set["ceph"]["osd_devices"].push(device) | ||
node.save | ||
dirty = true | ||
else | ||
Chef::Log.info("Ceph: Ignoring #{d.name}") | ||
end | ||
|
@@ -198,8 +208,15 @@ | |
end | ||
end | ||
end | ||
node.set["ceph"]["osd_devices"][index]["status"] = "deployed" | ||
node.set["ceph"]["osd_devices"][index]["journal"] = journal_device unless journal_device.nil? | ||
if node["ceph"]["osd_devices"][index]["status"] != "deployed" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Metrics/BlockNesting: Avoid more than 3 levels of block nesting. (https://github.com/bbatsov/ruby-style-guide#three-is-the-number-thou-shalt-count) |
||
node.set["ceph"]["osd_devices"][index]["status"] = "deployed" | ||
dirty = true | ||
end | ||
# if journal_device is nil, this will still work as expected | ||
if node["ceph"]["osd_devices"][index]["journal"] != journal_device | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Metrics/BlockNesting: Avoid more than 3 levels of block nesting. (https://github.com/bbatsov/ruby-style-guide#three-is-the-number-thou-shalt-count) |
||
node.set["ceph"]["osd_devices"][index]["journal"] = journal_device | ||
dirty = true | ||
end | ||
|
||
execute "Writing Ceph OSD device mappings to fstab" do | ||
command "tail -n1 /etc/mtab >> /etc/fstab" | ||
|
@@ -209,7 +226,6 @@ | |
# No need to specifically enable ceph-osd@N on systemd systems, as this | ||
# is done automatically by ceph-disk-activate | ||
end | ||
node.save | ||
|
||
service "ceph_osd" do | ||
case service_type | ||
|
@@ -234,5 +250,7 @@ | |
end | ||
end | ||
end | ||
|
||
node.save if dirty | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/BlockNesting: Avoid more than 3 levels of block nesting. (https://github.com/bbatsov/ruby-style-guide#three-is-the-number-thou-shalt-count)