connectors_utility 8.5.0.0 → 8.6.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1aa92692e811978885951049ebd040709d0f286ce4498d93dce54189ff7b8135
4
- data.tar.gz: deda3bf664bb03c0b41e75acfa68b4cfa0abce03fd9fd32909c2e0a130686d14
3
+ metadata.gz: e2ca64052bb1f5b2fc108b3610293b26783d42dc7aa957426bad95415d456527
4
+ data.tar.gz: c40091f7500e1ef3c39336e1f44a92e6ba9663ad26849af79283543283c3106b
5
5
  SHA512:
6
- metadata.gz: 648d92295a527ccb6541596e030322cd9d7f6d8858edb90981f635f00f83083667e1e29837649b3310226ba180d0dd2316dc6bcb3bd12d53d4ec7c27f0eeb287
7
- data.tar.gz: ac6c2c9b5f1bdf0334f0e7379fe0cddcb7a9cf1d32ed6ad7843da9292cd1e5c025cdd31b10f7c45a7a0d5c23969879ddeee9d7938ecc8a13b4ed577696ba0e08
6
+ metadata.gz: ca920820800ac34e4e3338c3d0c06799b6e18dcaefd588ef6830bbf5062c453ac30532622dc416b3949e831aee5dd683db68d1227fc2c3ce25bf17ec0ce7da25
7
+ data.tar.gz: 706728e5dc9e7c0c2dbb6dcdeba46f8efa4efe8ee42028adb47256de710702d928095143f261d92e257ae123797e0e6f9c2da918cf54c76979e70acf1fead187
@@ -21,6 +21,12 @@ module Connectors
21
21
  Utility::ExceptionTracking.log_exception(e, 'Could not retrieve Crawler connectors due to unexpected error.')
22
22
  []
23
23
  end
24
+
25
+ private
26
+
27
+ def connector_registered?(service_type)
28
+ service_type == 'elastic-crawler'
29
+ end
24
30
  end
25
31
  end
26
32
  end
@@ -45,7 +45,7 @@ module Core
45
45
  Utility::ExceptionTracking.log_exception(e, 'Sync failed due to unexpected error.')
46
46
  ensure
47
47
  if @poll_interval > 0 && !@is_shutting_down
48
- Utility::Logger.info("Sleeping for #{@poll_interval} seconds in #{self.class}.")
48
+ Utility::Logger.debug("Sleeping for #{@poll_interval} seconds in #{self.class}.")
49
49
  sleep(@poll_interval)
50
50
  end
51
51
  end
@@ -59,29 +59,36 @@ module Core
59
59
  private
60
60
 
61
61
  def sync_triggered?(connector_settings)
62
+ return false unless connector_registered?(connector_settings.service_type)
63
+
64
+ unless connector_settings.valid_index_name?
65
+ Utility::Logger.warn("The index name of #{connector_settings.formatted} is invalid.")
66
+ return false
67
+ end
68
+
62
69
  unless connector_settings.connector_status_allows_sync?
63
- Utility::Logger.info("Connector #{connector_settings.id} is in status \"#{connector_settings.connector_status}\" and won't sync yet. Connector needs to be in one of the following statuses: #{Connectors::ConnectorStatus::STATUSES_ALLOWING_SYNC} to run.")
70
+ Utility::Logger.info("#{connector_settings.formatted.capitalize} is in status \"#{connector_settings.connector_status}\" and won't sync yet. Connector needs to be in one of the following statuses: #{Connectors::ConnectorStatus::STATUSES_ALLOWING_SYNC} to run.")
64
71
 
65
72
  return false
66
73
  end
67
74
 
68
75
  # Sync when sync_now flag is true for the connector
69
76
  if connector_settings[:sync_now] == true
70
- Utility::Logger.info("Connector #{connector_settings.id} is manually triggered to sync now.")
77
+ Utility::Logger.info("#{connector_settings.formatted.capitalize} is manually triggered to sync now.")
71
78
  return true
72
79
  end
73
80
 
74
81
  # Don't sync if sync is explicitly disabled
75
82
  scheduling_settings = connector_settings.scheduling_settings
76
83
  unless scheduling_settings.present? && scheduling_settings[:enabled] == true
77
- Utility::Logger.info("Connector #{connector_settings.id} scheduling is disabled.")
84
+ Utility::Logger.debug("#{connector_settings.formatted.capitalize} scheduling is disabled.")
78
85
  return false
79
86
  end
80
87
 
81
88
  # We want to sync when sync never actually happened
82
89
  last_synced = connector_settings[:last_synced]
83
90
  if last_synced.nil? || last_synced.empty?
84
- Utility::Logger.info("Connector #{connector_settings.id} has never synced yet, running initial sync.")
91
+ Utility::Logger.info("#{connector_settings.formatted.capitalize} has never synced yet, running initial sync.")
85
92
  return true
86
93
  end
87
94
 
@@ -89,7 +96,7 @@ module Core
89
96
 
90
97
  # Don't sync if there is no actual scheduling interval
91
98
  if current_schedule.nil? || current_schedule.empty?
92
- Utility::Logger.warn("No sync schedule configured for connector #{connector_settings.id}.")
99
+ Utility::Logger.warn("No sync schedule configured for #{connector_settings.formatted}.")
93
100
  return false
94
101
  end
95
102
 
@@ -103,7 +110,7 @@ module Core
103
110
 
104
111
  # Don't sync if the scheduling interval is non-parsable
105
112
  unless cron_parser
106
- Utility::Logger.error("Unable to parse sync schedule for connector #{connector_settings.id}: expression #{current_schedule} is not a valid Quartz Cron definition.")
113
+ Utility::Logger.error("Unable to parse sync schedule for #{connector_settings.formatted}: expression #{current_schedule} is not a valid Quartz Cron definition.")
107
114
  return false
108
115
  end
109
116
 
@@ -111,7 +118,7 @@ module Core
111
118
 
112
119
  # Sync if next trigger for the connector is in past
113
120
  if next_trigger_time < Time.now
114
- Utility::Logger.info("Connector #{connector_settings.id} sync is triggered by cron schedule #{current_schedule}.")
121
+ Utility::Logger.info("#{connector_settings.formatted.capitalize} sync is triggered by cron schedule #{current_schedule}.")
115
122
  return true
116
123
  end
117
124
 
@@ -119,6 +126,8 @@ module Core
119
126
  end
120
127
 
121
128
  def heartbeat_triggered?(connector_settings)
129
+ return false unless connector_registered?(connector_settings.service_type)
130
+
122
131
  last_seen = connector_settings[:last_seen]
123
132
  return true if last_seen.nil? || last_seen.empty?
124
133
  last_seen = begin
@@ -132,7 +141,20 @@ module Core
132
141
  end
133
142
 
134
143
  def configuration_triggered?(connector_settings)
135
- connector_settings.connector_status == Connectors::ConnectorStatus::CREATED
144
+ if connector_settings.needs_service_type? || connector_registered?(connector_settings.service_type)
145
+ return connector_settings.connector_status == Connectors::ConnectorStatus::CREATED
146
+ end
147
+
148
+ false
149
+ end
150
+
151
+ def connector_registered?(service_type)
152
+ if Connectors::REGISTRY.registered?(service_type)
153
+ true
154
+ else
155
+ Utility::Logger.info("The service type (#{service_type}) is not supported.")
156
+ false
157
+ end
136
158
  end
137
159
  end
138
160
  end
@@ -21,13 +21,13 @@ module Utility
21
21
  end
22
22
 
23
23
  def capture_exception(exception, context = {})
24
- Utility::Logger.error(generate_stack_trace(exception))
24
+ Utility::Logger.log_stacktrace(generate_stack_trace(exception))
25
25
  Utility::Logger.error("Context: #{context.inspect}") if context
26
26
  end
27
27
 
28
28
  def log_exception(exception, message = nil)
29
29
  Utility::Logger.error(message) if message
30
- Utility::Logger.error(generate_stack_trace(exception))
30
+ Utility::Logger.log_stacktrace(generate_stack_trace(exception))
31
31
  end
32
32
 
33
33
  def augment_exception(exception)
@@ -29,13 +29,21 @@ module Utility
29
29
  SUPPORTED_LOG_LEVELS.each do |level|
30
30
  define_method(level) do |message|
31
31
  if logger.is_a?(EcsLogging::Logger)
32
- logger.public_send(level, message, service: { name: 'connectors-ruby' })
32
+ logger.public_send(level, message, extra_ecs_fields)
33
33
  else
34
34
  logger.public_send(level, message)
35
35
  end
36
36
  end
37
37
  end
38
38
 
39
+ def log_stacktrace(stacktrace)
40
+ if logger.is_a?(EcsLogging::Logger)
41
+ logger.error(nil, extra_ecs_fields.merge(:error => { :stack_trace => stacktrace }))
42
+ else
43
+ logger.error(stacktrace)
44
+ end
45
+ end
46
+
39
47
  def error_with_backtrace(message: nil, exception: nil, prog_name: nil)
40
48
  logger.error(prog_name) { message } if message
41
49
  logger.error exception.message if exception
@@ -53,6 +61,24 @@ module Utility
53
61
  def abbreviated_message(message)
54
62
  message.gsub(/\s+/, ' ').strip.truncate(MAX_SHORT_MESSAGE_LENGTH)
55
63
  end
64
+
65
+ private
66
+
67
+ def extra_ecs_fields
68
+ {
69
+ :labels => { :index_date => Time.now.strftime('%Y.%m.%d') },
70
+ :log => { :logger => logger.progname },
71
+ :service => {
72
+ :type => 'connectors-ruby',
73
+ :version => Settings.version
74
+ },
75
+ :process => {
76
+ :pid => Process.pid,
77
+ :name => $PROGRAM_NAME,
78
+ :thread => Thread.current.object_id
79
+ }
80
+ }
81
+ end
56
82
  end
57
83
  end
58
84
  end
metadata CHANGED
@@ -1,71 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: connectors_utility
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.5.0.0
4
+ version: 8.6.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-22 00:00:00.000000000 Z
11
+ date: 2022-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: ecs-logging
14
+ name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.0'
19
+ version: 5.2.6
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.0'
26
+ version: 5.2.6
27
27
  - !ruby/object:Gem::Dependency
28
- name: activesupport
28
+ name: ecs-logging
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 5.2.6
33
+ version: 1.0.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 5.2.6
40
+ version: 1.0.0
41
41
  - !ruby/object:Gem::Dependency
42
- name: mime-types
42
+ name: fugit
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '='
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '3.1'
47
+ version: 1.5.3
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '='
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '3.1'
54
+ version: 1.5.3
55
55
  - !ruby/object:Gem::Dependency
56
- name: tzinfo-data
56
+ name: mime-types
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: '3.1'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - '='
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: '3.1'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: tzinfo
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -81,33 +81,19 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: nokogiri
84
+ name: tzinfo-data
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: 1.13.6
89
+ version: '0'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: 1.13.6
97
- - !ruby/object:Gem::Dependency
98
- name: fugit
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: 1.5.3
104
- type: :runtime
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: 1.5.3
96
+ version: '0'
111
97
  description: ''
112
98
  email: ent-search-dev@elastic.co
113
99
  executables: []
@@ -139,9 +125,9 @@ homepage: https://github.com/elastic/connectors-ruby
139
125
  licenses:
140
126
  - Elastic-2.0
141
127
  metadata:
142
- revision: bf9b1793112d26e3f02f75d34874a3e8f0f02f5e
143
- repository: git@github.com:elastic/connectors.git
144
- post_install_message:
128
+ revision: d6342a5a66d1f3361ce4a2621d2cf64bad9c8a1c
129
+ repository: https://github.com/elastic/connectors-ruby.git
130
+ post_install_message:
145
131
  rdoc_options: []
146
132
  require_paths:
147
133
  - lib
@@ -157,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
143
  version: '0'
158
144
  requirements: []
159
145
  rubygems_version: 3.0.3.1
160
- signing_key:
146
+ signing_key:
161
147
  specification_version: 4
162
148
  summary: Gem containing shared Connector Services libraries
163
149
  test_files: []