Add sleep to search_for function, so that node can be searched

Because Chef server build node index need some time, so when a node is
bootstrapped, it takes some time before it is searchable. So I added a
timeout for Chef building node index.

Closes-bug: 1208201
Change-Id: I55eb383ce98e4765c412ece799f7885e690ab188
This commit is contained in:
Chen Zhiwei 2013-12-04 20:33:19 -05:00
parent bf7f7bc3f2
commit 471b5a3c66
4 changed files with 17 additions and 3 deletions

View File

@ -2,6 +2,10 @@
This file is used to list changes made in each version of cookbook-openstack-common.
## 8.0.1:
### Bug
* Add sleep to search_for function, so that node can be searched
## 8.0.0:
* Upgrading to Havana
* Upgrading gems

View File

@ -201,11 +201,13 @@ License and Author
| **Author** | Craig Tracey (<craigtracey@gmail.com>) |
| **Author** | Sean Gallagher (<sean.gallagher@att.com>) |
| **Author** | Ionut Artarisi (<iartarisi@suse.cz>) |
| **Author** | Chen Zhiwei (<zhiwchen@cn.ibm.com>) |
| | |
| **Copyright** | Copyright (c) 2012-2013, AT&T Services, Inc. |
| **Copyright** | Copyright (c) 2013, Opscode, Inc. |
| **Copyright** | Copyright (c) 2013, Craig Tracey |
| **Copyright** | Copyright (c) 2013, SUSE Linux GmbH |
| **Copyright** | Copyright (c) 2013, IBM, Corp. |
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View File

@ -26,8 +26,16 @@ module ::Openstack
role_query = "(chef_environment:#{node.chef_environment} AND roles:#{r})"
recipe_query = "(chef_environment:#{node.chef_environment} AND recipes:#{r})".sub("::","\\:\\:")
query = "#{role_query} OR #{recipe_query}"
resp = search(:node, query, &block)
count = 1
sum = 7
while count < sum do
resp = search(:node, query, &block)
if resp != nil
break
end
sleep 2**count
count += 1
end
resp ? resp : []
end

View File

@ -4,7 +4,7 @@ maintainer_email "cookbooks@lists.tfoundry.com"
license "Apache 2.0"
description "Common OpenStack attributes, libraries and recipes."
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "8.0.0"
version "8.0.1"
recipe "openstack-common", "Installs/Configures common recipes"
recipe "openstack-common::set_endpoints_by_interface", "Set endpoints by interface"