Skip to content

Commit

Permalink
Merge pull request #105 from Jakob3xD/jh-data-stream-dry-run
Browse files Browse the repository at this point in the history
out_opensearch_data_stream: Don't connect to opensearch on dry-run
  • Loading branch information
cosmo0920 authored Jun 26, 2023
2 parents fcbf9c0 + 95d901c commit 9b5a5a0
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions lib/fluent/plugin/out_opensearch_data_stream.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,24 +69,26 @@ def validate_data_stream_parameters

def create_index_template(datastream_name, template_name, host = nil)
# Create index template from file
if @template_file
return if data_stream_exist?(datastream_name, host) or template_exists?(template_name, host)
template_installation_actual(template_name, @customize_template, @application_name, datastream_name, host)
else # Create default index template
return if data_stream_exist?(datastream_name, host) or template_exists?(template_name, host)
body = {
"index_patterns" => ["#{datastream_name}*"],
"data_stream" => {},
}

params = {
name: template_name,
body: body
}
retry_operate(@max_retry_putting_template,
@fail_on_putting_template_retry_exceed,
@catch_transport_exception_on_retry) do
client(host).indices.put_index_template(params)
if !dry_run?
if @template_file
return if data_stream_exist?(datastream_name, host) or template_exists?(template_name, host)
template_installation_actual(template_name, @customize_template, @application_name, datastream_name, host)
else # Create default index template
return if data_stream_exist?(datastream_name, host) or template_exists?(template_name, host)
body = {
"index_patterns" => ["#{datastream_name}*"],
"data_stream" => {},
}

params = {
name: template_name,
body: body
}
retry_operate(@max_retry_putting_template,
@fail_on_putting_template_retry_exceed,
@catch_transport_exception_on_retry) do
client(host).indices.put_index_template(params)
end
end
end
end
Expand Down

0 comments on commit 9b5a5a0

Please sign in to comment.