timed_rest_for_chef 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +43 -0
- data/lib/timed_rest_for_chef.rb +3 -0
- data/timed_rest_for_chef.gemspec +1 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -0,0 +1,43 @@
|
|
1
|
+
TimedRestForChef
|
2
|
+
================
|
3
|
+
|
4
|
+
This is a patching library to wrap REST calls in a
|
5
|
+
timeout to prevent hung chef processes.
|
6
|
+
|
7
|
+
Usage
|
8
|
+
=====
|
9
|
+
|
10
|
+
This library can be used in one of two ways:
|
11
|
+
|
12
|
+
1. A cookbook recipe can load it via chef_gem
|
13
|
+
2. The library can be required via the client.rb file
|
14
|
+
|
15
|
+
The first method would have something like this in a recipe:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
chef_gem 'timed_rest_for_chef'
|
19
|
+
require 'timed_rest_for_chef'
|
20
|
+
```
|
21
|
+
|
22
|
+
The downside of this method is that REST calls will not be wrapped
|
23
|
+
until chef gets to that recipe. This means all previous calls could
|
24
|
+
hang the chef process.
|
25
|
+
|
26
|
+
Using the second method, the gem will need to be available to chef,
|
27
|
+
and a new line added to the client.rb file:
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
# /etc/chef/client.rb
|
31
|
+
require 'timed_rest_for_chef'
|
32
|
+
...
|
33
|
+
```
|
34
|
+
|
35
|
+
Ensuring the gem is available to chef and that client.rb file has the
|
36
|
+
proper require line can be automated via the chef-client cookbook with
|
37
|
+
slight modifications.
|
38
|
+
|
39
|
+
References:
|
40
|
+
===========
|
41
|
+
|
42
|
+
* Ticket: http://tickets.opscode.com/browse/CHEF-2944
|
43
|
+
* chef-client cookbook: https://github.com/opscode-cookbooks/chef-client/pull/12
|
data/lib/timed_rest_for_chef.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
require 'timeout'
|
2
2
|
require 'chef/rest/rest_request'
|
3
3
|
|
4
|
+
# Be optimistic for when this will get patched. We can release and
|
5
|
+
# updated gem if it doesn't make it until a later version
|
4
6
|
if(Gem::Version.new(Chef::VERSION) < Gem::Version.new('10.14.0'))
|
7
|
+
Chef::Log.info "*** Adding timeout wrapper around REST requests"
|
5
8
|
|
6
9
|
# Custom timeout class to make it easy to log
|
7
10
|
# this specific type of timeout
|
data/timed_rest_for_chef.gemspec
CHANGED