diff options
author | Daniel DeLeo <dan@opscode.com> | 2010-09-15 11:30:12 -0700 |
---|---|---|
committer | Daniel DeLeo <dan@opscode.com> | 2010-09-15 11:30:12 -0700 |
commit | 1f3120f89b2e413d71c105e8f9a01b3575f80179 (patch) | |
tree | 2bb42841931de9ae295867e545bcc0385c51bc74 | |
parent | e0bb0f7fdb0d0441bf50850d299deb3414d5c430 (diff) | |
download | chef-1f3120f89b2e413d71c105e8f9a01b3575f80179.tar.gz |
gracefully handle non-standard (no dashes) UUIDsbeta-1-pre
-rw-r--r-- | chef/lib/chef/index_queue/amqp_client.rb | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/chef/lib/chef/index_queue/amqp_client.rb b/chef/lib/chef/index_queue/amqp_client.rb index be60c4574e..d3d291d401 100644 --- a/chef/lib/chef/index_queue/amqp_client.rb +++ b/chef/lib/chef/index_queue/amqp_client.rb @@ -75,7 +75,7 @@ class Chef end def queue_for_object(obj_id) - vnode_tag = UUIDTools::UUID.parse(obj_id).to_i % VNODES + vnode_tag = obj_id_to_int(obj_id) % VNODES queue = amqp_client.queue("vnode-#{vnode_tag}") retries = 0 begin @@ -93,6 +93,15 @@ class Chef end private + + # Sometimes object ids are "proper" UUIDs, like "64bc00eb-120b-b6a2-ec0e-34fc90d151be" + # and sometimes they omit the dashes, like "64bc00eb120bb6a2ec0e34fc90d151be" + # UUIDTools uses different methods to parse the different styles. + def obj_id_to_int(obj_id) + UUIDTools::UUID.parse(obj_id).to_i + rescue ArgumentError + UUIDTools::UUID.parse_hexdigest(obj_id).to_i + end def durable_queue? !!Chef::Config[:amqp_consumer_id] |