Permalink
Browse files

gracefully handle non-standard (no dashes) UUIDs

  • Loading branch information...
1 parent e0bb0f7 commit 1f3120f89b2e413d71c105e8f9a01b3575f80179 @danielsdeleo danielsdeleo committed Sep 15, 2010
Showing with 10 additions and 1 deletion.
  1. +10 −1 chef/lib/chef/index_queue/amqp_client.rb
@@ -75,7 +75,7 @@ def disconnected!
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 @@ def queue_for_object(obj_id)
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]

0 comments on commit 1f3120f

Please sign in to comment.