topological_inventory-core 1.1.1 → 1.1.6

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: 7bafb3cb3b7789833d6fafd71e34da8e172039ae49f7fe03a16fac40cba7be4e
4
- data.tar.gz: e642d51826923f406e0a24ca75ea57fea47af01386217b7c1d240e0dad7dded1
3
+ metadata.gz: 574cd191dd5ad268210d1299a4b8cc71355482eead4316b873836effcb63f0bb
4
+ data.tar.gz: b8ad635b7f2b2cb052e54c7e3e84ebdd5bb428d8645e847cb707c5922f60d366
5
5
  SHA512:
6
- metadata.gz: 4728c1a6494e41e969d034f14ad64bd4bdb2ec1b1c2ce16bc61d00d327ae49b4fbde05d23dc313b773bb2b261af791b0882ab4803626b785e069f4e4e5f7bcf1
7
- data.tar.gz: ac02e6f01322313ece2855c8876a3ae9224cf23a7c3bf86da66a597df76ee8affcfd43aef48693dc30752a8a9fce5b4df1035df08ba39e7beb9d7e4746b9b347
6
+ metadata.gz: 03a5c8a8eeca049ddbb546598fdf328859247674e033f370ddf4f339bba856b6011cb0421846f91c66158862fd24490f5fb6af11ed4a5f6d208c3534040cd860
7
+ data.tar.gz: d4be6b1a789b5be5dbfc1a0296f7e01606dce53731416e477c76445dc8b8e3f23ffa6fd4f35b9878e3c730aadac596c5fb45fa9606405f15bb329feae5a1c41a
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # TopologicalInventory
1
+ # Topological Inventory Core
2
2
 
3
3
  [![Build Status](https://travis-ci.org/RedHatInsights/topological_inventory-core.svg)](https://travis-ci.org/RedHatInsights/topological_inventory-core)
4
4
  [![Maintainability](https://api.codeclimate.com/v1/badges/34f9bd9412e35c1a36fd/maintainability)](https://codeclimate.com/github/RedHatInsights/topological_inventory-core/maintainability)
@@ -1,20 +1,23 @@
1
1
  default: &default
2
2
  adapter: postgresql
3
3
  encoding: utf8
4
+ host: 127.0.0.1
5
+ port: 5432
4
6
  username: root
7
+ password: buttons
5
8
  pool: 5
6
9
  wait_timeout: 5
7
10
  min_messages: warning
8
11
 
9
12
  development:
10
13
  <<: *default
11
- database: topological_inventory_core_development
14
+ database: topological_inventory_development
12
15
  min_messages: notice
13
16
 
14
17
  test:
15
18
  <<: *default
16
- database: topological_inventory_core_test
19
+ database: topological_inventory_test
17
20
 
18
21
  production:
19
22
  <<: *default
20
- database: topological_inventory_core_production
23
+ database: topological_inventory_production
@@ -1,6 +1,11 @@
1
1
  class ExtractTasksSourceRefFromContext < ActiveRecord::Migration[5.2]
2
2
  def up
3
3
  Task.find_each do |task|
4
+ if task.context.is_a?(String)
5
+ say "Found legacy data in Task #{task.id}, converting String to Hash..."
6
+ task.context = JSON.parse(task.context)
7
+ end
8
+
4
9
  source_ref = task.context&.dig('service_instance', 'source_ref')
5
10
  next if source_ref.nil?
6
11
 
@@ -0,0 +1,5 @@
1
+ class AddSourceUpdatedAt < ActiveRecord::Migration[5.2]
2
+ def change
3
+ add_column :volumes, :source_updated_at, :timestamp
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class AddRequestIdToTask < ActiveRecord::Migration[5.2]
2
+ def change
3
+ add_column :tasks, :x_rh_insights_request, :string
4
+ end
5
+ end
@@ -0,0 +1,11 @@
1
+ class AddForwardableHeadersRemoveRequestIdOnTask < ActiveRecord::Migration[5.2]
2
+ def up
3
+ add_column :tasks, :forwardable_headers, :jsonb
4
+ remove_column :tasks, :x_rh_insights_request
5
+ end
6
+
7
+ def down
8
+ add_column :tasks, :x_rh_insights_request, :string
9
+ remove_column :tasks, :forwardable_headers
10
+ end
11
+ end
@@ -0,0 +1,6 @@
1
+ class AddIndexToRefreshStateParts < ActiveRecord::Migration[5.2]
2
+ def change
3
+ add_index :refresh_state_parts, :uuid
4
+ add_index :refresh_states, :uuid
5
+ end
6
+ end
@@ -10,7 +10,7 @@
10
10
  #
11
11
  # It's strongly recommended that you check this file into your version control system.
12
12
 
13
- ActiveRecord::Schema.define(version: 2020_04_14_123737) do
13
+ ActiveRecord::Schema.define(version: 2020_08_11_154716) do
14
14
 
15
15
  # These are extensions that must be enabled in order to support this database
16
16
  enable_extension "plpgsql"
@@ -622,6 +622,7 @@ ActiveRecord::Schema.define(version: 2020_04_14_123737) do
622
622
  t.datetime "updated_at", null: false
623
623
  t.index ["refresh_state_id", "uuid"], name: "index_refresh_state_parts_on_refresh_state_id_and_uuid", unique: true
624
624
  t.index ["tenant_id"], name: "index_refresh_state_parts_on_tenant_id"
625
+ t.index ["uuid"], name: "index_refresh_state_parts_on_uuid"
625
626
  end
626
627
 
627
628
  create_table "refresh_states", force: :cascade do |t|
@@ -639,6 +640,7 @@ ActiveRecord::Schema.define(version: 2020_04_14_123737) do
639
640
  t.datetime "finished_at"
640
641
  t.index ["source_id", "uuid"], name: "index_refresh_states_on_source_id_and_uuid", unique: true
641
642
  t.index ["tenant_id"], name: "index_refresh_states_on_tenant_id"
643
+ t.index ["uuid"], name: "index_refresh_states_on_uuid"
642
644
  end
643
645
 
644
646
  create_table "reservation_tags", id: :serial, force: :cascade do |t|
@@ -1190,6 +1192,7 @@ ActiveRecord::Schema.define(version: 2020_04_14_123737) do
1190
1192
  t.string "target_source_ref"
1191
1193
  t.string "target_type"
1192
1194
  t.bigint "source_id"
1195
+ t.jsonb "forwardable_headers"
1193
1196
  t.index ["source_id"], name: "index_tasks_on_source_id"
1194
1197
  t.index ["target_type", "target_source_ref"], name: "index_tasks_on_target_type_and_target_source_ref"
1195
1198
  t.index ["tenant_id"], name: "index_tasks_on_tenant_id"
@@ -1327,6 +1330,7 @@ ActiveRecord::Schema.define(version: 2020_04_14_123737) do
1327
1330
  t.bigint "orchestration_stack_id"
1328
1331
  t.bigint "subscription_id"
1329
1332
  t.bigint "refresh_state_part_id"
1333
+ t.datetime "source_updated_at"
1330
1334
  t.index ["archived_at"], name: "index_volumes_on_archived_at"
1331
1335
  t.index ["last_seen_at"], name: "index_volumes_on_last_seen_at"
1332
1336
  t.index ["orchestration_stack_id"], name: "index_volumes_on_orchestration_stack_id"
@@ -1,5 +1,5 @@
1
1
  module TopologicalInventory
2
2
  module Core
3
- VERSION = '1.1.1'
3
+ VERSION = '1.1.6'
4
4
  end
5
5
  end
@@ -147,11 +147,11 @@ module TopologicalInventory
147
147
  return if src_refs.blank?
148
148
 
149
149
  # Updating Tasks
150
- # service_instance_tasks_update_effective(source)
151
- service_instance_tasks_update_ineffective(source, src_refs)
150
+ # service_instance_tasks_update_by_raw_sql(source)
151
+ service_instance_tasks_update_by_activerecord(tasks_collection, source, src_refs)
152
152
  end
153
153
 
154
- def task_update_values(svc_instance_id, external_url, status, task_status, finished_timestamp)
154
+ def task_update_values(svc_instance_id, source_ref, external_url, status, task_status, finished_timestamp, source_id)
155
155
  {
156
156
  :state => finished_timestamp.blank? ? 'running' : 'completed',
157
157
  :status => task_status,
@@ -159,6 +159,8 @@ module TopologicalInventory
159
159
  :service_instance => {
160
160
  :id => svc_instance_id,
161
161
  :job_status => status,
162
+ :source_id => source_id,
163
+ :source_ref => source_ref,
162
164
  :url => external_url
163
165
  }
164
166
  }
@@ -166,24 +168,29 @@ module TopologicalInventory
166
168
  end
167
169
 
168
170
  # This method is updating one by one using ActiveRecord
169
- def service_instance_tasks_update_ineffective(source, svc_instances_source_ref)
171
+ def service_instance_tasks_update_by_activerecord(tasks_collection, source, svc_instances_source_ref)
170
172
  service_instances = ServiceInstance.where(:source_id => source.id, :source_ref => svc_instances_source_ref)
171
173
  tasks_by_source_ref = Task.where(:state => 'running', :target_type => 'ServiceInstance', :source_id => source.id, :target_source_ref => service_instances.pluck(:source_ref)).index_by(&:target_source_ref)
172
174
 
173
175
  service_instances.select(:id, :external_url, :source_ref, :extra).find_in_batches do |group|
174
176
  ActiveRecord::Base.transaction do
175
177
  group.each do |svc_instance|
176
- next if tasks_by_source_ref[svc_instance.source_ref].nil?
178
+ next if (task = tasks_by_source_ref[svc_instance.source_ref]).nil?
177
179
 
178
- values = task_update_values(svc_instance.id, svc_instance.external_url, svc_instance.extra['status'], svc_instance.extra['task_status'], svc_instance.extra['finished'])
179
- tasks_by_source_ref[svc_instance.source_ref].update(values)
180
+ values = task_update_values(svc_instance.id, svc_instance.source_ref, svc_instance.external_url, svc_instance.extra['status'], svc_instance.extra['task_status'], svc_instance.extra['finished'], source.id)
181
+ # 1) Updating Task
182
+ task.update(values)
183
+
184
+ # 2) Saving to updated records (will be published in Kafka)
185
+ # - see topological_inventory-persister:Workflow.send_task_updates_to_queue!
186
+ tasks_collection.updated_records << values.merge(:id => task.id, :forwardable_headers => task.forwardable_headers)
180
187
  end
181
188
  end
182
189
  end
183
190
  end
184
191
 
185
192
  # This method is bulk updating by raw SQL query
186
- def service_instance_tasks_update_effective(source)
193
+ def service_instance_tasks_update_by_raw_sql(source)
187
194
  # Get running tasks
188
195
  tasks_source_ref = Task.where(:state => 'running', :target_type => 'ServiceInstance', :source_id => source.id)
189
196
  .pluck(:target_source_ref)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: topological_inventory-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Grare
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-22 00:00:00.000000000 Z
11
+ date: 2020-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: acts_as_tenant
@@ -136,20 +136,48 @@ dependencies:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
138
  version: '3.8'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rubocop
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: 0.69.0
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: 0.69.0
153
+ - !ruby/object:Gem::Dependency
154
+ name: rubocop-performance
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '1.3'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '1.3'
139
167
  - !ruby/object:Gem::Dependency
140
168
  name: simplecov
141
169
  requirement: !ruby/object:Gem::Requirement
142
170
  requirements:
143
- - - ">="
171
+ - - "~>"
144
172
  - !ruby/object:Gem::Version
145
- version: '0'
173
+ version: 0.17.1
146
174
  type: :development
147
175
  prerelease: false
148
176
  version_requirements: !ruby/object:Gem::Requirement
149
177
  requirements:
150
- - - ">="
178
+ - - "~>"
151
179
  - !ruby/object:Gem::Version
152
- version: '0'
180
+ version: 0.17.1
153
181
  - !ruby/object:Gem::Dependency
154
182
  name: webmock
155
183
  requirement: !ruby/object:Gem::Requirement
@@ -174,13 +202,6 @@ files:
174
202
  - LICENSE.txt
175
203
  - README.md
176
204
  - Rakefile
177
- - app/assets/config/topological_inventory_manifest.js
178
- - app/assets/javascripts/topological_inventory/application.js
179
- - app/assets/stylesheets/topological_inventory/application.css
180
- - app/controllers/topological_inventory/application_controller.rb
181
- - app/helpers/topological_inventory/application_helper.rb
182
- - app/jobs/topological_inventory/application_job.rb
183
- - app/mailers/topological_inventory/application_mailer.rb
184
205
  - app/models/application_record.rb
185
206
  - app/models/availability.rb
186
207
  - app/models/cluster.rb
@@ -247,7 +268,6 @@ files:
247
268
  - app/models/volume.rb
248
269
  - app/models/volume_attachment.rb
249
270
  - app/models/volume_type.rb
250
- - app/views/layouts/topological_inventory/application.html.erb
251
271
  - config/database.dev.yml
252
272
  - config/database.yml
253
273
  - db/migrate/20180919170553_add_sources_and_endpoints.rb
@@ -354,6 +374,10 @@ files:
354
374
  - db/migrate/20200317082640_add_tracking_timestamps_to_refresh_state.rb
355
375
  - db/migrate/20200403114310_add_target_and_source_to_task.rb
356
376
  - db/migrate/20200414123737_extract_tasks_source_ref_from_context.rb
377
+ - db/migrate/20200421141934_add_source_updated_at.rb
378
+ - db/migrate/20200428090420_add_request_id_to_task.rb
379
+ - db/migrate/20200505101547_add_forwardable_headers_remove_request_id_on_task.rb
380
+ - db/migrate/20200811154716_add_index_to_refresh_state_parts.rb
357
381
  - db/schema.rb
358
382
  - db/seeds.rb
359
383
  - lib/tasks/topological_inventory_tasks.rake
@@ -385,7 +409,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
385
409
  - !ruby/object:Gem::Version
386
410
  version: '0'
387
411
  requirements: []
388
- rubygems_version: 3.1.2
412
+ rubygems_version: 3.0.8
389
413
  signing_key:
390
414
  specification_version: 4
391
415
  summary: Core Models and Schema for the Topological Inventory Service.
@@ -1,2 +0,0 @@
1
- //= link_directory ../javascripts/topological_inventory .js
2
- //= link_directory ../stylesheets/topological_inventory .css
@@ -1,13 +0,0 @@
1
- // This is a manifest file that'll be compiled into application.js, which will include all the files
2
- // listed below.
3
- //
4
- // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
- // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
- //
7
- // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
- // compiled file. JavaScript code in this file should be added after the last require_* statement.
9
- //
10
- // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
- // about supported directives.
12
- //
13
- //= require_tree .
@@ -1,15 +0,0 @@
1
- /*
2
- * This is a manifest file that'll be compiled into application.css, which will include all the files
3
- * listed below.
4
- *
5
- * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
- * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
- *
8
- * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
- * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
- * files in this directory. Styles in this file should be added after the last require_* statement.
11
- * It is generally better to create a new file per style scope.
12
- *
13
- *= require_tree .
14
- *= require_self
15
- */
@@ -1,5 +0,0 @@
1
- module TopologicalInventory
2
- class ApplicationController < ActionController::Base
3
- protect_from_forgery with: :exception
4
- end
5
- end
@@ -1,4 +0,0 @@
1
- module TopologicalInventory
2
- module ApplicationHelper
3
- end
4
- end
@@ -1,4 +0,0 @@
1
- module TopologicalInventory
2
- class ApplicationJob < ActiveJob::Base
3
- end
4
- end
@@ -1,6 +0,0 @@
1
- module TopologicalInventory
2
- class ApplicationMailer < ActionMailer::Base
3
- default from: 'from@example.com'
4
- layout 'mailer'
5
- end
6
- end
@@ -1,14 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Topological inventory</title>
5
- <%= stylesheet_link_tag "topological_inventory/application", media: "all" %>
6
- <%= javascript_include_tag "topological_inventory/application" %>
7
- <%= csrf_meta_tags %>
8
- </head>
9
- <body>
10
-
11
- <%= yield %>
12
-
13
- </body>
14
- </html>