kitchen_hooks 1.7.5 → 1.7.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ef6e686e12474334dac278347907e0217f4c6988
4
- data.tar.gz: bffb695626d6390acaf5d20aeacdc10900d819fa
3
+ metadata.gz: ba6350e2e32bd9410d65d847737709e27864a974
4
+ data.tar.gz: f783adc4c5c19137fefb9969444891907be5475f
5
5
  SHA512:
6
- metadata.gz: 7cce1b540f68b1c9b5c29001dc973e9237a16c02cfa5ce9c725f5169b9794dc29e09999842b4140d22c52ba741530315773b9769fe27117a9131f3c86709da66
7
- data.tar.gz: 53b7d4986200d24f82cdac784045506583e3b0a90e3808b2f94f2880215cb8095386f7485d7e34c7e755d4fe0f65b9c8da1af02600d9ee4316612ec6cc8f21db
6
+ metadata.gz: d547cd54fbda16065b833ed61bf06b5d3f3df8fb69e0d610bbbfd4ecbb505015c4d95a9998d107a201c02432dad483fc20c660e9a75aa4554ce2b46d58fc4e2b
7
+ data.tar.gz: b0f1be8e6013b8083d201647e0baf9d0d2465b84bef0b3cff1eee4fd8459e448506c097ef88f05692eb811c93b111d439dbda17c77cb02d11190dc317f4c6ce1
data/Readme.md CHANGED
@@ -122,6 +122,7 @@ The `server` command also exposes some options for Sinatra configuration. See
122
122
  ### 1.7
123
123
 
124
124
  * Sync nodes between Chef servers
125
+ * Speedup sync by cachine Ohai update times
125
126
 
126
127
  ### 1.6
127
128
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.7.5
1
+ 1.7.6
@@ -18,7 +18,12 @@ module KitchenHooks
18
18
 
19
19
  enable :sessions
20
20
 
21
- def self.db! path
21
+ def self.db! path=@@db_path
22
+ if defined? @@db
23
+ @@db.flush
24
+ @@db.close
25
+ end
26
+ @@db_path = path
22
27
  @@db = Daybreak::DB.new path
23
28
  end
24
29
 
@@ -27,6 +32,7 @@ module KitchenHooks
27
32
  def self.close!
28
33
  @@sync_worker.kill
29
34
  @@backlog_worker.kill
35
+ @@db.flush
30
36
  @@db.close
31
37
  end
32
38
 
@@ -134,7 +140,7 @@ module KitchenHooks
134
140
  error = nil if error == true
135
141
  entry = { type: type, event: event }
136
142
  entry.merge!(error: error, type: 'failure') if error
137
- db.synchronize do
143
+ db.lock do
138
144
  db[Time.now.to_f] = entry
139
145
  end
140
146
  db.flush
@@ -159,14 +165,11 @@ module KitchenHooks
159
165
  db.set! 'meta_cached_nodes', sync_servers.cached_nodes
160
166
  end
161
167
  sync = sync_servers.status
162
-
163
- if sync.nil?
164
- mark "Couldn't sync Chef servers (unknown issue)", 'unsynced'
165
- return
166
- end
167
-
168
+ puts 'Sync completed'
169
+ db!
168
170
  sync_tag = sync[:num_failures].zero? ? 'synced' : 'unsynced'
169
171
  mark sync, sync_tag
172
+ db!
170
173
  end
171
174
 
172
175
 
@@ -107,7 +107,7 @@ private
107
107
  nodes.each do |n|
108
108
  next if failures.include? n.name
109
109
  @cached_nodes[n.name] = n.automatic.ohai_time.to_f
110
- successes << n
110
+ successes << n.name
111
111
  end
112
112
 
113
113
  deleted.each do |n|
@@ -118,18 +118,15 @@ private
118
118
  end
119
119
  end
120
120
 
121
- puts 'Sync completed'
122
121
  return {
123
122
  deleted: deleted,
124
123
  failures: failures,
125
124
  successes: successes,
126
- num_successes: nodes.length - failures.length,
125
+ num_successes: successes.length,
127
126
  num_failures: failures.length,
128
127
  num_deletions: deleted.length,
129
128
  num_nodes: nodes.length
130
129
  }
131
- # rescue
132
- # return nil
133
130
  end
134
131
 
135
132
  end
@@ -344,10 +344,13 @@ module KitchenHooks
344
344
  if event.is_a? String
345
345
  event
346
346
  else
347
- 'Synced <b>%d</b> of <b>%d</b> nodes (%s, %s elapsed)' % [
347
+ num_deletions = event[:num_deletions].to_i
348
+ deletions = '%s, ' % pluralize(num_deletions, 'deletion')
349
+ deletions = '' unless num_deletions > 0
350
+ 'Synced <b>%d</b> of <b>%d</b> nodes (%s%s elapsed)' % [
348
351
  event[:num_successes],
349
352
  event[:num_nodes],
350
- pluralize(event[:num_failures], 'failure'),
353
+ deletions,
351
354
  humanize_seconds(event[:elapsed])
352
355
  ]
353
356
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitchen_hooks
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.5
4
+ version: 1.7.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Clemmer