File tree Expand file tree Collapse file tree 4 files changed +64
-5
lines changed Expand file tree Collapse file tree 4 files changed +64
-5
lines changed Original file line number Diff line number Diff line change
1
+ ## 3.0.6
2
+ - Improve malformed-input handling by using updated FTW
3
+ - Improve webserver crash recovery
4
+ - Properly support plugin stopping & reloading
5
+
1
6
## 3.0.5
2
7
- Update gemspec summary
3
8
Original file line number Diff line number Diff line change @@ -42,6 +42,13 @@ def run(output_queue)
42
42
response . body = "Accepted!"
43
43
end
44
44
@server . run
45
+ rescue Exception => original_exception
46
+ # If our server crashes, it may not have cleaned up after itself;
47
+ # since `FTW::WebServer#stop` is idempotent, make one last attempt
48
+ # before propagating the original exception.
49
+ @server && @server . stop rescue logger . error ( "Error while stopping FTW::WebServer" , exception : $!. message , backtrace : $!. backtrace )
50
+
51
+ raise original_exception
45
52
end # def run
46
53
47
54
def build_event_from_request ( body , headers )
@@ -69,8 +76,8 @@ def verify_signature(event,body)
69
76
return is_valid
70
77
end
71
78
72
- def close
73
- @server . stop
74
- end # def close
79
+ def stop
80
+ @server && @server . stop
81
+ end # def stop
75
82
76
83
end # class LogStash::Inputs::Github
Original file line number Diff line number Diff line change 1
1
Gem ::Specification . new do |s |
2
2
3
3
s . name = 'logstash-input-github'
4
- s . version = '3.0.5 '
4
+ s . version = '3.0.6 '
5
5
s . licenses = [ 'Apache License (2.0)' ]
6
6
s . summary = "Reads events from a GitHub webhook"
7
7
s . description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
24
24
25
25
s . add_runtime_dependency 'addressable'
26
26
s . add_runtime_dependency 'logstash-codec-plain'
27
- s . add_runtime_dependency 'ftw' , '~> 0.0.42 '
27
+ s . add_runtime_dependency 'ftw' , '~> 0.0.48 '
28
28
29
29
s . add_development_dependency 'logstash-devutils'
30
30
end
Original file line number Diff line number Diff line change 55
55
end
56
56
57
57
end
58
+
59
+ describe 'graceful shutdown' do
60
+ context 'when underlying webserver crashes' do
61
+
62
+ # Stubbing out our FTW::WebServer allows us to force it to raise an exception when we try to run it.
63
+ let ( :mock_webserver_class ) { double ( 'FTW::WebServer::class' ) . as_null_object }
64
+ let ( :mock_webserver ) { double ( 'FTW::WebServer' ) . as_null_object }
65
+ before ( :each ) do
66
+ stub_const ( 'FTW::WebServer' , mock_webserver_class )
67
+ allow ( mock_webserver_class ) . to receive ( :new ) . and_return ( mock_webserver )
68
+ expect ( mock_webserver ) . to receive ( :run ) . and_raise ( 'testing: intentional uncaught exception' )
69
+ end
70
+
71
+ it 'makes an attempt to stop the webserver' do
72
+ expect ( mock_webserver ) . to receive ( :stop )
73
+
74
+ plugin . run ( [ ] ) rescue nil
75
+ end
76
+
77
+ it 'propagates the original exception' do
78
+ expect do
79
+ plugin . run ( [ ] )
80
+ end . to raise_exception ( 'testing: intentional uncaught exception' )
81
+ end
82
+
83
+ context 'and an attempt to stop the webserver also crashes' do
84
+ let ( :mock_logger ) { double ( 'Logger' ) . as_null_object }
85
+ before ( :each ) do
86
+ allow ( plugin ) . to receive ( :logger ) . and_return ( mock_logger )
87
+ allow ( mock_webserver ) . to receive ( :stop ) . and_raise ( 'yo dawg' )
88
+ end
89
+
90
+ it 'logs helpfully' do
91
+ expect ( mock_logger ) . to receive ( :error ) . with ( "Error while stopping FTW::WebServer" ,
92
+ exception : 'yo dawg' , backtrace : instance_of ( Array ) )
93
+
94
+ plugin . run ( [ ] ) rescue nil
95
+ end
96
+
97
+ it 'propagates the original exception' do
98
+ expect do
99
+ plugin . run ( [ ] )
100
+ end . to raise_exception ( 'testing: intentional uncaught exception' )
101
+ end
102
+ end
103
+ end
104
+ end
58
105
end
You can’t perform that action at this time.
0 commit comments