@@ -262,12 +262,18 @@ def register
262
262
# To support BWC, we check if DLQ exists in core (< 5.4). If it doesn't, we use nil to resort to previous behavior.
263
263
@dlq_writer = dlq_enabled? ? execution_context . dlq_writer : nil
264
264
265
+ check_action_validity
266
+
265
267
# the license_checking behaviour in the Pool class is externalized in the LogStash::ElasticSearchOutputLicenseChecker
266
268
# class defined in license_check.rb. This license checking is specific to the elasticsearch output here and passed
267
269
# to build_client down to the Pool class.
268
270
build_client ( LicenseChecker . new ( @logger ) )
269
- setup_after_successful_connection
270
- check_action_validity
271
+
272
+ @template_installer = setup_after_successful_connection do
273
+ discover_cluster_uuid
274
+ install_template
275
+ setup_ilm if ilm_in_use?
276
+ end
271
277
@bulk_request_metrics = metric . namespace ( :bulk_requests )
272
278
@document_level_metrics = metric . namespace ( :documents )
273
279
@logger . info ( "New Elasticsearch output" , :class => self . class . name , :hosts => @hosts . map ( &:sanitized ) . map ( &:to_s ) )
@@ -373,19 +379,6 @@ def retry_on_conflict_action_name
373
379
374
380
private
375
381
376
- def discover_cluster_uuid
377
- return unless defined? ( plugin_metadata )
378
- cluster_info = client . get ( '/' )
379
- plugin_metadata . set ( :cluster_uuid , cluster_info [ 'cluster_uuid' ] )
380
- rescue => e
381
- # TODO introducing this logging message breaks many tests that need refactoring
382
- # @logger.error("Unable to retrieve elasticsearch cluster uuid", error => e.message)
383
- end
384
-
385
- def successful_connection?
386
- !!maximum_seen_major_version
387
- end
388
-
389
382
def routing_field_name
390
383
maximum_seen_major_version >= 6 ? :routing : :_routing
391
384
end
@@ -432,22 +425,6 @@ def install_template
432
425
@template_installed . make_true
433
426
end
434
427
435
- def setup_after_successful_connection
436
- @template_installer ||= Thread . new do
437
- sleep_interval = @retry_initial_interval
438
- until successful_connection? || @stopping . true?
439
- @logger . debug ( "Waiting for connectivity to Elasticsearch cluster. Retrying in #{ sleep_interval } s" )
440
- Stud . stoppable_sleep ( sleep_interval ) { @stopping . true? }
441
- sleep_interval = next_sleep_interval ( sleep_interval )
442
- end
443
- if successful_connection?
444
- discover_cluster_uuid
445
- install_template
446
- setup_ilm if ilm_in_use?
447
- end
448
- end
449
- end
450
-
451
428
def setup_ecs_compatibility_related_defaults
452
429
case ecs_compatibility
453
430
when :disabled
0 commit comments