File tree Expand file tree Collapse file tree 4 files changed +29
-2
lines changed Expand file tree Collapse file tree 4 files changed +29
-2
lines changed Original file line number Diff line number Diff line change 1
1
## 5.4.1
2
- - Docs: Add retry policy description [ #130 ] ( https://github.com/logstash-plugins/logstash-output-http/pull/130 )
2
+ - Fix retry indefinitely in termination process. This feature requires Logstash 8.1 [ #129 ] ( https://github.com/logstash-plugins/logstash-output-http/pull/129 )
3
+ - Docs: Add retry policy description [ #130 ] ( https://github.com/logstash-plugins/logstash-output-http/pull/130 )
3
4
4
5
## 5.4.0
5
6
- Introduce retryable unknown exceptions for "connection reset by peer" and "timeout" [ #127 ] ( https://github.com/logstash-plugins/logstash-output-http/pull/127 )
Original file line number Diff line number Diff line change @@ -445,4 +445,4 @@ See https://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache
445
445
[id="plugins-{type}s-{plugin}-common-options"]
446
446
include::{include_path}/{type}.asciidoc[]
447
447
448
- :default_codec!:
448
+ :default_codec!:
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ class LogStash::Outputs::Http < LogStash::Outputs::Base
28
28
/Read Timed out/i
29
29
]
30
30
31
+ class PluginInternalQueueLeftoverError < StandardError ; end
31
32
32
33
# This output lets you send events to a
33
34
# generic HTTP(S) endpoint
@@ -179,6 +180,9 @@ def send_events(events)
179
180
180
181
event , attempt = popped
181
182
183
+ raise PluginInternalQueueLeftoverError . new ( "Received pipeline shutdown request but http output has unfinished events. " \
184
+ "If persistent queue is enabled, events will be retried." ) if attempt > 2 && pipeline_shutdown_requested?
185
+
182
186
action , event , attempt = send_event ( event , attempt )
183
187
begin
184
188
action = :failure if action == :retry && !@retry_failed
@@ -223,6 +227,11 @@ def send_events(events)
223
227
raise e
224
228
end
225
229
230
+ def pipeline_shutdown_requested?
231
+ return super if defined? ( super ) # since LS 8.1.0
232
+ nil
233
+ end
234
+
226
235
def sleep_for_attempt ( attempt )
227
236
sleep_for = attempt **2
228
237
sleep_for = sleep_for <= 60 ? sleep_for : 60
Original file line number Diff line number Diff line change @@ -501,6 +501,23 @@ def start_app_and_wait(app, opts = {})
501
501
let ( :base_config ) { { "http_compression" => true } }
502
502
end
503
503
end
504
+
505
+ describe "retryable error in termination" do
506
+ let ( :url ) { "http://localhost:#{ port -1 } /invalid" }
507
+ let ( :events ) { [ event ] }
508
+ let ( :config ) { { "url" => url , "http_method" => "get" , "pool_max" => 1 } }
509
+
510
+ subject { LogStash ::Outputs ::Http . new ( config ) }
511
+
512
+ before do
513
+ subject . register
514
+ allow ( subject ) . to receive ( :pipeline_shutdown_requested? ) . and_return ( true )
515
+ end
516
+
517
+ it "raise exception to exit indefinitely retry" do
518
+ expect { subject . multi_receive ( events ) } . to raise_error ( LogStash ::Outputs ::Http ::PluginInternalQueueLeftoverError )
519
+ end
520
+ end
504
521
end
505
522
506
523
describe LogStash ::Outputs ::Http do # different block as we're starting web server with TLS
You can’t perform that action at this time.
0 commit comments