-
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
[4.0] Decrease the amount of node saves #102
Conversation
Rebase of PR crowbar#80 Only save the node when attribute(s) have changed Do not fetch monitor secret if we're the master
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 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)
@@ -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 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)
@@ -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 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)
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 |
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)
@@ -127,7 +137,7 @@ | |||
end | |||
device["device"] = d.name | |||
node.set["ceph"]["osd_devices"].push(device) | |||
node.save | |||
dirty = true |
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.
We were saving here explicitly for a reason, probably becasue we are using this values ["ceph"]["osd_devices"]
immediately below.
Are we sure this is still working as before? I would say yes, as its only used in this recipe, but would like confirmation that this has been tested properly and the devices are being picked up in the recipe afterwards without saving the node.
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.
Yes, the array of devices is enumerable (i.e. usable) immediately below even after moving node.save to the end of the file. The node.save is only needed to persist the values for subsequent executions of the cookbook.
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.
Thanks!
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.
Looks good, just a question and a nit
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.
Looks good, just a question and a nit
chef/cookbooks/ceph/recipes/osd.rb
Outdated
@@ -71,7 +71,7 @@ | |||
if is_crowbar? | |||
dirty = false | |||
|
|||
node.set["ceph"]["osd_devices"] ||= [] | |||
node.set["ceph"]["osd_devices"] = [] if node["ceph"]["osd_devices"].nil? |
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.
Same question as is in #103. Why the change?
Fix multiline comment Fix array initialization (was mistakenly initializing as a hash)
55455d5
to
ad1fbcc
Compare
Rebase of PR #80
Only save the node when attribute(s) have changed
Do not fetch monitor secret if we're the master