flapjack 0.7.9 → 0.7.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,8 @@
1
1
  ## Flapjack Changelog
2
2
 
3
+ # 0.7.10 - 2013-06-05
4
+ - Bug: unknown events not fully treated as problems - no notification delay blocking gh-154 (@jessereynolds)
5
+
3
6
  # 0.7.9 - 2013-06-04
4
7
  - Feature: Include summary and details in the /status API call gh-179 (@ali-graham)
5
8
 
@@ -186,6 +186,24 @@ Feature: events
186
186
  And an ok event is received
187
187
  Then a notification should not be generated
188
188
 
189
+ @time
190
+ Scenario: Quick stream of unknown
191
+ Given the check is in an ok state
192
+ When an unknown event is received
193
+ Then a notification should not be generated
194
+ When 60 seconds passes
195
+ And an unknown event is received
196
+ Then a notification should be generated
197
+ When 10 seconds passes
198
+ And an unknown event is received
199
+ Then a notification should not be generated
200
+ When 10 seconds passes
201
+ And an unknown event is received
202
+ Then a notification should not be generated
203
+ When 10 seconds passes
204
+ And an unknown event is received
205
+ Then a notification should not be generated
206
+
189
207
  @time
190
208
  Scenario: Flapper (down for one minute, up for one minute, repeat)
191
209
  Given the check is in an ok state
@@ -98,6 +98,18 @@ def submit_critical(entity, check)
98
98
  submit_event(event)
99
99
  end
100
100
 
101
+ def submit_unknown(entity, check)
102
+ event = {
103
+ 'type' => 'service',
104
+ 'state' => 'unknown',
105
+ 'summary' => 'check execution error',
106
+ 'entity' => entity,
107
+ 'check' => check,
108
+ 'client' => 'clientx'
109
+ }
110
+ submit_event(event)
111
+ end
112
+
101
113
  def submit_acknowledgement(entity, check)
102
114
  event = {
103
115
  'type' => 'action',
@@ -198,6 +210,13 @@ When /^a warning event is received(?: for check '([\w\.\-]+)' on entity '([\w\.\
198
210
  drain_events
199
211
  end
200
212
 
213
+ When /^an unknown event is received(?: for check '([\w\.\-]+)' on entity '([\w\.\-]+)')?$/ do |check, entity|
214
+ check ||= @check
215
+ entity ||= @entity
216
+ submit_unknown(entity, check)
217
+ drain_events
218
+ end
219
+
201
220
  When /^an acknowledgement .*is received(?: for check '([\w\.\-]+)' on entity '([\w\.\-]+)')?$/ do |check, entity|
202
221
  check ||= @check
203
222
  entity ||= @entity
@@ -131,27 +131,24 @@ module Flapjack
131
131
  entity_id = $1
132
132
  check = $2
133
133
 
134
- unless ret.has_key?(entity_id)
135
- ret[entity_id] = {}
136
- if entity_name = @redis.hget("entity:#{entity_id}", 'name')
137
- entity = Flapjack::Data::Entity.new(:name => entity_name,
138
- :id => entity_id, :redis => @redis)
139
- ret[entity_id][:entity] = entity
140
- end
141
- if options[:checks]
142
- # using a set to ensure unique check values
143
- ret[entity_id][:checks] = Set.new
144
- end
134
+ entity = nil
135
+
136
+ if ret.has_key?(entity_id)
137
+ entity = ret[entity_id][:entity]
138
+ else
139
+ entity = Flapjack::Data::Entity.find_by_id(entity_id, :redis => @redis)
140
+ ret[entity_id] = {
141
+ :entity => entity
142
+ }
143
+ # using a set to ensure unique check values
144
+ ret[entity_id][:checks] = Set.new if options[:checks]
145
+ ret[entity_id][:tags] = entity.tags if entity && options[:tags]
145
146
  end
146
147
 
147
148
  if options[:checks]
148
149
  # if not registered for the check, then was registered for
149
150
  # the entity, so add all checks
150
- ret[entity_id][:checks] |= (check || entity.check_list)
151
- end
152
-
153
- if options[:tags]
154
- ret[entity_id][:tags] = entity.tags
151
+ ret[entity_id][:checks] |= (check || (entity ? entity.check_list : []))
155
152
  end
156
153
  end
157
154
  end
@@ -286,6 +286,12 @@ module Flapjack
286
286
  lcn.to_i
287
287
  end
288
288
 
289
+ def last_unknown_notification
290
+ lcn = @redis.get("#{@key}:last_unknown_notification")
291
+ return unless (lcn && lcn =~ /^\d+$/)
292
+ lcn.to_i
293
+ end
294
+
289
295
  def last_recovery_notification
290
296
  lrn = @redis.get("#{@key}:last_recovery_notification")
291
297
  return unless (lrn && lrn =~ /^\d+$/)
@@ -302,6 +308,7 @@ module Flapjack
302
308
  ln = {:problem => last_problem_notification,
303
309
  :warning => last_warning_notification,
304
310
  :critical => last_critical_notification,
311
+ :unknown => last_unknown_notification,
305
312
  :recovery => last_recovery_notification,
306
313
  :acknowledgement => last_acknowledgement_notification }
307
314
  ln
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  module Flapjack
4
- VERSION = "0.7.9"
4
+ VERSION = "0.7.10"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flapjack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.9
4
+ version: 0.7.10
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2013-06-04 00:00:00.000000000 Z
14
+ date: 2013-06-05 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: dante
@@ -553,7 +553,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
553
553
  version: '0'
554
554
  segments:
555
555
  - 0
556
- hash: 4072946799112620353
556
+ hash: 1212130592798831749
557
557
  required_rubygems_version: !ruby/object:Gem::Requirement
558
558
  none: false
559
559
  requirements:
@@ -562,7 +562,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
562
562
  version: '0'
563
563
  segments:
564
564
  - 0
565
- hash: 4072946799112620353
565
+ hash: 1212130592798831749
566
566
  requirements: []
567
567
  rubyforge_project:
568
568
  rubygems_version: 1.8.23