-
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 3 commits
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,52 @@ | ||
# | ||
# 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. | ||
# | ||
|
||
require 'digest/md5' | ||
|
||
Ohai.plugin(:ShardSeed) do | ||
depends "hostname", "dmi", "machine_id" | ||
provides "shard_seed" | ||
|
||
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 | ||
|
||
collect_data(:default) do | ||
sources = Ohai.config[:plugin][:shard_seed][:source] || [:fqdn] | ||
data = '' | ||
sources.each do |src| | ||
data << case base | ||
when :fqdn | ||
fqdn | ||
when :hostname | ||
hostname | ||
when :serial | ||
get_dmi_thing(dmi, :serial_number) | ||
when :uuid | ||
get_dmi_thing(dmi, :uuid) | ||
when :machine_id | ||
machine_id | ||
end | ||
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.
stil don't like the default on fqdn.
machinename
would be better since it avoid DNS issues.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.
in fact i'd prefer to not even give the option of using :fqdn here because that depends on DNS and a transient DNS hiccup my change the sharding.