summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel DeLeo <dan@opscode.com>2010-09-15 11:30:12 -0700
committersdelano <stephen@opscode.com>2010-11-04 14:00:51 -0700
commite04174414795c6f8984855c826f96f766bcb27a9 (patch)
treefbc7c6dec670429a6776b71d78d4b709c7e12b16
parent9c1f7c6969301491979651b62926d8ebdcfe6a2c (diff)
downloadchef-e04174414795c6f8984855c826f96f766bcb27a9.tar.gz
gracefully handle non-standard (no dashes) UUIDs
-rw-r--r--chef/lib/chef/index_queue/amqp_client.rb11
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 0666a10833..6f45d39bc1 100644
--- a/chef/lib/chef/index_queue/amqp_client.rb
+++ b/chef/lib/chef/index_queue/amqp_client.rb
@@ -76,7 +76,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
@@ -94,6 +94,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]