foreman-tasks 0.15.4 → 0.15.5

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: 1a46a9b83e2940388c697cb6f0d2d4412ab2f324ab35c6996e61e75128f40e9d
4
- data.tar.gz: 39ab0d32e58bbbefd08850f846dcfb845d5a9aa646c4ecf6477b9db19bbd7a5c
3
+ metadata.gz: 2b8139a15057de700208b9ce91c4c69b7314d48f51e6a402b6eb6fce9876e7d0
4
+ data.tar.gz: 637f5a6e7df839f77b036a4bd417946ed7df1c711429bca9b0e9a1fbd3c5fc40
5
5
  SHA512:
6
- metadata.gz: 508b95686e4d405baca1405226482f475bb57933773e349fbd301f0ec84f4a111be1564d34e7b9fff83b4f1d30f1a8bca2da332c349e2d37d9cb5fd252239a1e
7
- data.tar.gz: 595b0e0dec575616dd328c297fd8e7efad94aef1e304f365e4b683a8cf04f53b77a517ee42fb85100b7ca44a2b6e9827350f5f38acec00262fad263b52b42a8a
6
+ metadata.gz: b40833091cd03018255226939b9828b9b6c987e11e5ff2068e98ebeff903870266f1105fb1e8b4742ffd8adbddf62ca5adb4f05b4375f95cf3c40c1b37c8d823
7
+ data.tar.gz: 1a57a601e73f39b98f4db7326ec5547a7efef245a32bcc4df3816462b39ebf98f6463bd7e066eb75c8dd2e53c28eea6b1591d7780fdc0614245b77beb792d22e
@@ -31,9 +31,9 @@ add_files /var/log/foreman/dynflow_executor*.output*
31
31
  # Foreman Tasks fast export (Postgresql only; for HTML version use foreman-rake foreman_tasks:export_tasks)
32
32
 
33
33
  if [ "$FOREMAN_DB_ADAPTER" == "postgresql" ]; then
34
- export_csv "select dynflow_execution_plans.* from foreman_tasks_tasks join dynflow_execution_plans on (foreman_tasks_tasks.external_id = dynflow_execution_plans.uuid) where foreman_tasks_tasks.started_at > 'now'::timestamp - '${DYNFLOW_EXPORT_MONTHS:-1} months'::interval limit ${DYNFLOW_EXPORT_LIMIT:-100000}" "$DIR/dynflow_execution_plans.csv"
35
- export_csv "select dynflow_actions.* from foreman_tasks_tasks join dynflow_actions on (foreman_tasks_tasks.external_id = dynflow_actions.execution_plan_uuid) where foreman_tasks_tasks.started_at > 'now'::timestamp - '${DYNFLOW_EXPORT_MONTHS:-1} months'::interval limit ${DYNFLOW_EXPORT_LIMIT:-100000}" "$DIR/dynflow_actions.csv"
36
- export_csv "select dynflow_steps.* from foreman_tasks_tasks join dynflow_steps on (foreman_tasks_tasks.external_id = dynflow_steps.execution_plan_uuid) where foreman_tasks_tasks.started_at > 'now'::timestamp - '${DYNFLOW_EXPORT_MONTHS:-1} months'::interval limit ${DYNFLOW_EXPORT_LIMIT:-100000}" "$DIR/dynflow_steps.csv"
34
+ export_csv "select dynflow_execution_plans.* from foreman_tasks_tasks join dynflow_execution_plans on (foreman_tasks_tasks.external_id = dynflow_execution_plans.uuid::varchar) where foreman_tasks_tasks.started_at > 'now'::timestamp - '${DYNFLOW_EXPORT_MONTHS:-1} months'::interval limit ${DYNFLOW_EXPORT_LIMIT:-100000}" "$DIR/dynflow_execution_plans.csv"
35
+ export_csv "select dynflow_actions.* from foreman_tasks_tasks join dynflow_actions on (foreman_tasks_tasks.external_id = dynflow_actions.execution_plan_uuid::varchar) where foreman_tasks_tasks.started_at > 'now'::timestamp - '${DYNFLOW_EXPORT_MONTHS:-1} months'::interval limit ${DYNFLOW_EXPORT_LIMIT:-100000}" "$DIR/dynflow_actions.csv"
36
+ export_csv "select dynflow_steps.* from foreman_tasks_tasks join dynflow_steps on (foreman_tasks_tasks.external_id = dynflow_steps.execution_plan_uuid::varchar) where foreman_tasks_tasks.started_at > 'now'::timestamp - '${DYNFLOW_EXPORT_MONTHS:-1} months'::interval limit ${DYNFLOW_EXPORT_LIMIT:-100000}" "$DIR/dynflow_steps.csv"
37
37
  export_csv "select * from dynflow_schema_info" "$DIR/dynflow_schema_info.csv"
38
38
  export_csv "select * from foreman_tasks_tasks limit ${DYNFLOW_EXPORT_LIMIT:-100000}" "$DIR/foreman_tasks_tasks.csv"
39
39
  fi
@@ -192,9 +192,15 @@ module ForemanTasks
192
192
  end
193
193
 
194
194
  def orphaned_dynflow_tasks
195
+ dynflow_plan_uuid_attribute = "dynflow_execution_plans.uuid"
196
+ if ActiveRecord::Base.connection.adapter_name == 'PostgreSQL'
197
+ # typecast the UUID attribute for Postgres
198
+ dynflow_plan_uuid_attribute += "::varchar"
199
+ end
200
+
195
201
  db = ForemanTasks.dynflow.world.persistence.adapter.db
196
202
  db.fetch("select dynflow_execution_plans.uuid from dynflow_execution_plans left join "\
197
- "foreman_tasks_tasks on (dynflow_execution_plans.uuid = foreman_tasks_tasks.external_id) "\
203
+ "foreman_tasks_tasks on (#{dynflow_plan_uuid_attribute} = foreman_tasks_tasks.external_id) "\
198
204
  "where foreman_tasks_tasks.id IS NULL")
199
205
  end
200
206
 
@@ -1,3 +1,3 @@
1
1
  module ForemanTasks
2
- VERSION = '0.15.4'.freeze
2
+ VERSION = '0.15.5'.freeze
3
3
  end
@@ -32,6 +32,27 @@ class TasksTest < ActiveSupport::TestCase
32
32
  .find_execution_plans(filters: { 'uuid' => tasks_to_keep.map(&:external_id) }).size.must_equal tasks_to_keep.size
33
33
  end
34
34
 
35
+ describe "#orphaned_dynflow_tasks" do
36
+ # We can't use transactional tests because we're using Sequel for the cleanup query
37
+ self.use_transactional_tests = false
38
+ before do
39
+ skip "Sqlite is running testing Dynlfow DB in memory" if ActiveRecord::Base.connection.adapter_name == 'SQLite'
40
+ @existing_task = FactoryBot.create(:dynflow_task, :user_create_task)
41
+ @missing_task = FactoryBot.create(:dynflow_task, :user_create_task)
42
+ @cleaner = ForemanTasks::Cleaner.new(filter: "id ^ (#{@existing_task.id}, #{@missing_task.id})")
43
+ @missing_task.destroy
44
+ end
45
+
46
+ after do
47
+ @cleaner.delete if @cleaner
48
+ end
49
+
50
+ it 'is able to find orphaned execution plans (without corresponding task object)' do
51
+ assert(@cleaner.orphaned_dynflow_tasks.any? { |t| t[:uuid] == @missing_task.external_id })
52
+ assert_not(@cleaner.orphaned_dynflow_tasks.any? { |t| t[:uuid] == @existing_task.external_id })
53
+ end
54
+ end
55
+
35
56
  it 'deletes all tasks matching the filter when the time limit is not specified' do
36
57
  cleaner = ForemanTasks::Cleaner.new(:filter => 'label = "Actions::User::Create"')
37
58
  tasks_to_delete = [FactoryBot.create(:dynflow_task, :user_create_task),
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman-tasks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.4
4
+ version: 0.15.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Nečas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-06 00:00:00.000000000 Z
11
+ date: 2019-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: foreman-tasks-core
@@ -232,7 +232,6 @@ files:
232
232
  - db/migrate/20180216092715_use_uuid.rb
233
233
  - db/migrate/20181019135324_add_remote_task_operation.rb
234
234
  - db/migrate/20190318153925_add_task_state_updated_at.foreman_tasks.rb
235
- - db/migrate/20190404132157_add_implicit_varchar_uuid_cast.rb
236
235
  - db/seeds.d/20-foreman_tasks_permissions.rb
237
236
  - db/seeds.d/30-notification_blueprints.rb
238
237
  - db/seeds.d/60-dynflow_proxy_feature.rb
@@ -1,25 +0,0 @@
1
- class AddImplicitVarcharUuidCast < ActiveRecord::Migration[5.2]
2
- def up
3
- if on_postgresql?
4
- ActiveRecord::Base.connection.execute <<~SQL
5
- CREATE CAST (varchar AS uuid)
6
- WITH INOUT
7
- AS IMPLICIT
8
- SQL
9
- end
10
- end
11
-
12
- def down
13
- if on_postgresql?
14
- ActiveRecord::Base.connection.execute <<~SQL
15
- DROP CAST (varchar AS uuid)
16
- SQL
17
- end
18
- end
19
-
20
- private
21
-
22
- def on_postgresql?
23
- ActiveRecord::Base.connection.adapter_name == 'PostgreSQL'
24
- end
25
- end