From a8e1639bed65b04cb3608d35b7aeacafe2936a9a Mon Sep 17 00:00:00 2001 From: Yuki Sekiguchi Date: Tue, 5 Mar 2024 14:25:48 +0900 Subject: [PATCH] Prevent AWS credentials refresh from stopping on exception If `aws_credentials()` fails due to an unstable network or other issues, it throws an exception. This stops `timer_execute()` from repeating its block, preventing `OpenSearchOutput` from updating `@_aws_credentials`. As a result, `@_aws_credentials` will expire. This commit catches the exception and prevents it from propagating to `timer_execute()`, ensuring continuous credential updates. Signed-off-by: Yuki Sekiguchi --- lib/fluent/plugin/out_opensearch.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/fluent/plugin/out_opensearch.rb b/lib/fluent/plugin/out_opensearch.rb index 7fd543c..0c03f69 100644 --- a/lib/fluent/plugin/out_opensearch.rb +++ b/lib/fluent/plugin/out_opensearch.rb @@ -350,7 +350,11 @@ class << self @credential_mutex.synchronize do @_os = nil - @_aws_credentials = aws_credentials(@endpoint) + begin + @_aws_credentials = aws_credentials(@endpoint) + rescue => e + log.error("Failed to get new AWS credentials: #{e}") + end end end end