-
Notifications
You must be signed in to change notification settings - Fork 449
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
Add shard plugin #877
Add shard plugin #877
Changes from 1 commit
528777e
ef11cdf
7a3fef3
5c48bb6
ee3dbf7
336910b
ab62d1f
a9a2d44
ad3c4b5
98c8a76
3f8e820
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# | ||
# Author:: Phil Dibowitz <[email protected]> | ||
# Copyright:: Copyright (c) 2016 Facebook, Inc. | ||
# License:: Apache License, Version 2.0 | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
def get_dmi_thing(dmi, thing) | ||
%w{system base_board chassis}.each do |section| | ||
unless dmi[:thing][thing].compact.empty? | ||
return dmi[:thing][thing] | ||
end | ||
end | ||
end | ||
|
||
Ohai.plugin(:ShardSeed) do | ||
depends "hostname", "dmi" | ||
provides "shard_seed" | ||
|
||
collect_data(:default) do | ||
base = Ohai.config[:plugin][:shard_seed][:base] || :hostname | ||
data = case base | ||
when :hostname | ||
fqdn | ||
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. fqdns can, and often are, nil because DNS. machinename would possibly be better, but you get into a religious warfare there with the short-hostname people who may have collisions in short hostnames across their infrastructure. |
||
when :serial | ||
get_dmi_thing(dmi, :serial_number) | ||
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. seen so many |
||
when :uuid | ||
get_dmi_thing(dmi, :uuid) | ||
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. i'd bet money this isn't guaranteed to be unique either -- of course i've also seen NIC cards with the same Mac address as well... |
||
end | ||
shard_seed Digest::MD5.hexdigest(data)[0...7].to_i(16) | ||
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. You aren't 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. And why trim to 8 characters? 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. yeah I'll add the requires. Um, I don't remember why we did the 8 characters. Something something crytpo widths. Let me see if I can track that down. 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. So best we can tell that 2^15 buckets seemed sufficient and I think we had overflowed a variable or something somewhere without that.... 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. Anyone know if this will be an issue with FIPS? ISTR that the md5 functions get removed if you have OpenSSL in FIPS mode (groan). Alternatively, just using SHA-2 probably won't hurt anything. 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. I think |
||
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.
Don't declare a global helper method in a plugin file, either make is a true global helper or put it in the plugin class.