flapjack 1.6.0rc1 → 1.6.0rc2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -1
- data/lib/flapjack/gateways/aws_sns.rb +22 -7
- data/lib/flapjack/gateways/aws_sns/alert_subject.text.erb +4 -0
- data/lib/flapjack/gateways/aws_sns/rollup_subject.text.erb +1 -0
- data/lib/flapjack/gateways/pagerduty.rb +8 -3
- data/lib/flapjack/version.rb +1 -1
- data/spec/lib/flapjack/gateways/aws_sns_spec.rb +25 -2
- data/spec/lib/flapjack/gateways/pagerduty_spec.rb +2 -2
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77cf774d68b395a3d2c146b884788e5e71020479
|
4
|
+
data.tar.gz: 14de90365627b2362a59e6e0249861c4a070fc5c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef929d2621508fde4072e9b3d66e1139315d581ed2e8304b503fe6e95b8669c82127ce9561e1ceea989b26686d015086a0a213d703341f3d81bf246b08cf87b0
|
7
|
+
data.tar.gz: 85d21013929b673fc3ca4e0b991c2c6decaec14b7819bd0e19f61186073a3382f0f3b698d2e91f37decdbed0344d3bfb08eeb9ffed3e2be8853dc9ac3093a176
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
## Flapjack Changelog
|
2
2
|
|
3
|
-
# 1.6.
|
3
|
+
# 1.6.0rc2 - 2015-05-14
|
4
|
+
- Bug: Fix SNS query encoding and subject length #867 (@ali-graham, @xcxsxvx)
|
5
|
+
- Chore: improve debug logging in pagerduty when looking for acks e44abd5 (@jessereynolds)
|
6
|
+
|
7
|
+
# 1.6.0rc1 - 2015-05-13
|
4
8
|
- Feature: use token authentication for pagerduty gateway #831 (@alperkokmen)
|
5
9
|
- Feature: expose failure delays in web UI #849 (@jessereynolds)
|
6
10
|
- Bug: performance improvement - fix usage of KEYS command for entity check names c57d3a5 (@ali-graham)
|
@@ -66,7 +66,11 @@ module Flapjack
|
|
66
66
|
notification_id = alert.notification_id
|
67
67
|
message_type = alert.rollup ? 'rollup' : 'alert'
|
68
68
|
|
69
|
-
|
69
|
+
aws_sns_subject_template_erb, aws_sns_subject_template =
|
70
|
+
load_template(@config['templates'], "#{message_type}_subject",
|
71
|
+
'text', File.join(File.dirname(__FILE__), 'aws_sns'))
|
72
|
+
|
73
|
+
aws_sns_template_erb, aws_sns_template =
|
70
74
|
load_template(@config['templates'], message_type, 'text',
|
71
75
|
File.join(File.dirname(__FILE__), 'aws_sns'))
|
72
76
|
|
@@ -74,10 +78,14 @@ module Flapjack
|
|
74
78
|
bnd = binding
|
75
79
|
|
76
80
|
begin
|
77
|
-
|
81
|
+
erb_to_be_executed = aws_sns_subject_template
|
82
|
+
subject = aws_sns_subject_template_erb.result(bnd).chomp
|
83
|
+
|
84
|
+
erb_to_be_executed = aws_sns_template
|
85
|
+
message = aws_sns_template_erb.result(bnd).chomp
|
78
86
|
rescue => e
|
79
|
-
@logger.error "Error while executing the ERB for an
|
80
|
-
"ERB being executed: #{
|
87
|
+
@logger.error "Error while executing the ERB for an AWS SNS message: " +
|
88
|
+
"ERB being executed: #{erb_to_be_executed}"
|
81
89
|
raise
|
82
90
|
end
|
83
91
|
|
@@ -102,7 +110,8 @@ module Flapjack
|
|
102
110
|
return
|
103
111
|
end
|
104
112
|
|
105
|
-
query = {'Subject' =>
|
113
|
+
query = {'Subject' => (subject.length > 100) ?
|
114
|
+
subject[0..99].gsub(/...$/, '...') : subject,
|
106
115
|
'TopicArn' => address,
|
107
116
|
'Message' => message,
|
108
117
|
'Action' => 'Publish',
|
@@ -142,12 +151,18 @@ module Flapjack
|
|
142
151
|
end
|
143
152
|
|
144
153
|
def self.string_to_sign(method, host, uri, query)
|
145
|
-
|
154
|
+
@safe_re ||= Regexp.new("[^#{URI::PATTERN::UNRESERVED}]")
|
155
|
+
|
156
|
+
# we should possibly escape the keys as well, but they are less
|
157
|
+
# likely to have problematic characters
|
158
|
+
encoded_query = query.keys.sort.collect {|key|
|
159
|
+
"#{key}=#{URI.escape(query[key].to_s, @safe_re)}"
|
160
|
+
}.join("&")
|
146
161
|
|
147
162
|
[method.upcase,
|
148
163
|
host.downcase,
|
149
164
|
uri,
|
150
|
-
|
165
|
+
encoded_query
|
151
166
|
].join("\n")
|
152
167
|
end
|
153
168
|
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= @alert.type_sentence_case %>: <%= @alert.rollup_states_summary -%>
|
@@ -174,11 +174,16 @@ module Flapjack
|
|
174
174
|
end
|
175
175
|
|
176
176
|
def find_pagerduty_acknowledgements
|
177
|
-
@logger.debug("looking for acks in pagerduty for unack'd problems")
|
178
|
-
|
179
177
|
unacknowledged_failing_checks = Flapjack::Data::EntityCheck.unacknowledged_failing(:redis => @redis)
|
178
|
+
if unacknowledged_failing_checks.empty?
|
179
|
+
@logger.debug("skipping looking for acks in pagerduty as there are no unacknowledged failing checks")
|
180
|
+
return nil
|
181
|
+
else
|
182
|
+
@logger.debug("looking for acks in pagerduty for unack'd problems")
|
183
|
+
end
|
180
184
|
|
181
|
-
@logger.debug "found unacknowledged failing checks as follows: " +
|
185
|
+
@logger.debug "found #{unacknowledged_failing_checks.length} unacknowledged failing checks as follows: " +
|
186
|
+
unacknowledged_failing_checks.map {|c| "#{c.entity_name}:#{c.check}"}.join(', ')
|
182
187
|
|
183
188
|
unacknowledged_failing_checks.each do |entity_check|
|
184
189
|
|
data/lib/flapjack/version.rb
CHANGED
@@ -53,6 +53,28 @@ describe Flapjack::Gateways::AwsSns, :logger => true do
|
|
53
53
|
expect(req).to have_been_requested
|
54
54
|
end
|
55
55
|
|
56
|
+
it 'truncates an overly long subject when sending' do
|
57
|
+
req = stub_request(:post, "http://sns.us-east-1.amazonaws.com/").
|
58
|
+
with(:query => hash_including({'Action' => 'Publish',
|
59
|
+
'AWSAccessKeyId' => config['access_key'],
|
60
|
+
'TopicArn' => message['address'],
|
61
|
+
'SignatureVersion' => '2',
|
62
|
+
'SignatureMethod' => 'HmacSHA256',
|
63
|
+
'Subject' => "Recovery: '#{'1234567890' * 8}123456..."})).
|
64
|
+
to_return(:status => 200)
|
65
|
+
|
66
|
+
EM.synchrony do
|
67
|
+
expect(Flapjack::RedisPool).to receive(:new).and_return(redis)
|
68
|
+
|
69
|
+
long_event_id = "example.com:#{'1234567890' * 10}"
|
70
|
+
alert = Flapjack::Data::Alert.new(message.merge('event_id' => long_event_id), :logger => @logger)
|
71
|
+
aws_sns = Flapjack::Gateways::AwsSns.new(:config => config, :logger => @logger)
|
72
|
+
aws_sns.deliver(alert)
|
73
|
+
EM.stop
|
74
|
+
end
|
75
|
+
expect(req).to have_been_requested
|
76
|
+
end
|
77
|
+
|
56
78
|
it "does not send an SMS message with an invalid config" do
|
57
79
|
EM.synchrony do
|
58
80
|
expect(Flapjack::RedisPool).to receive(:new).and_return(redis)
|
@@ -75,7 +97,8 @@ describe Flapjack::Gateways::AwsSns, :logger => true do
|
|
75
97
|
let(:uri) { '/' }
|
76
98
|
|
77
99
|
let(:query) { {'TopicArn' => 'HelloWorld',
|
78
|
-
|
100
|
+
'Action' => 'Publish',
|
101
|
+
'Message' => 'Hello World'} }
|
79
102
|
|
80
103
|
let(:string_to_sign) { Flapjack::Gateways::AwsSns.string_to_sign(method, host, uri, query) }
|
81
104
|
|
@@ -94,7 +117,7 @@ describe Flapjack::Gateways::AwsSns, :logger => true do
|
|
94
117
|
end
|
95
118
|
|
96
119
|
it 'should put the encoded, sorted query-string on the fourth line' do
|
97
|
-
expect(lines[3]).to eq("Action=Publish&TopicArn=HelloWorld")
|
120
|
+
expect(lines[3]).to eq("Action=Publish&Message=Hello%20World&TopicArn=HelloWorld")
|
98
121
|
end
|
99
122
|
|
100
123
|
end
|
@@ -142,9 +142,9 @@ describe Flapjack::Gateways::Pagerduty, :logger => true do
|
|
142
142
|
})
|
143
143
|
|
144
144
|
entity_check = double('entity_check')
|
145
|
-
expect(entity_check).to receive(:check).exactly(
|
145
|
+
expect(entity_check).to receive(:check).exactly(2).times.and_return('PING')
|
146
146
|
expect(entity_check).to receive(:contacts).and_return([contact])
|
147
|
-
expect(entity_check).to receive(:entity_name).exactly(
|
147
|
+
expect(entity_check).to receive(:entity_name).exactly(2).times.and_return('foo-app-01.bar.net')
|
148
148
|
expect(entity_check).to receive(:in_unscheduled_maintenance?).exactly(1).times.and_return(false)
|
149
149
|
expect(entity_check).to receive(:failed?).exactly(1).times.and_return(true)
|
150
150
|
expect(Flapjack::Data::Event).to receive(:create_acknowledgement).with('foo-app-01.bar.net', 'PING',
|
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: 1.6.
|
4
|
+
version: 1.6.0rc2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lindsay Holmwood
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2015-05-
|
14
|
+
date: 2015-05-14 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: dante
|
@@ -442,7 +442,9 @@ files:
|
|
442
442
|
- lib/flapjack/filters/unscheduled_maintenance.rb
|
443
443
|
- lib/flapjack/gateways/aws_sns.rb
|
444
444
|
- lib/flapjack/gateways/aws_sns/alert.text.erb
|
445
|
+
- lib/flapjack/gateways/aws_sns/alert_subject.text.erb
|
445
446
|
- lib/flapjack/gateways/aws_sns/rollup.text.erb
|
447
|
+
- lib/flapjack/gateways/aws_sns/rollup_subject.text.erb
|
446
448
|
- lib/flapjack/gateways/email.rb
|
447
449
|
- lib/flapjack/gateways/email/alert.html.erb
|
448
450
|
- lib/flapjack/gateways/email/alert.text.erb
|