dynflow 1.0.0 → 1.0.1

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
- SHA256:
3
- metadata.gz: 111e155822b2ec8d00a8f0e249ce1333f6d4e826bb10247e172a523e7212a9d6
4
- data.tar.gz: 4969844384cd6ea8add967e10495cc534bee36dbbe4fe5a9b978ecd8c09d802c
2
+ SHA1:
3
+ metadata.gz: 35bd7c7bd52da4f68946edb03d5d388d09f53cea
4
+ data.tar.gz: 35800095dee5a7edc92ed87d605edc66e8190c34
5
5
  SHA512:
6
- metadata.gz: 65b612808157a76872102e4070bbb0b0ca8e23d9eba4f032a7881d67b884f33be74dc0fc7fbbcd458d15be675e33f10ba00c0fb24e4c3e237a69e7ae27558104
7
- data.tar.gz: 66c6e35276566b7d239a25c5f95e8b52331e70aa32f36a36027c3fbf64d64069f611b8ffaab3caac5a89bf370a4c6fadc3bb5736de8bde9d3b7f50bf7a962149
6
+ metadata.gz: 2415804bf8a2c1a0b502db7bf685915aa7ae90365bd3316db269bdd187fa0d98357e1452181f23cbcf779c495fa4293046336a5ae700926b59566d9f47fe0187
7
+ data.tar.gz: 9fb0b84f75bcc2055d523d61a706393eeb14479ce5939b73ec0d3b242aaf888c3a129a561acea88b598bcf3954b99deae3ea4919eede8b04f729e33b3dc6b528
@@ -46,8 +46,12 @@ module Dynflow
46
46
  def process(delayed_plans, check_time)
47
47
  processed_plan_uuids = []
48
48
  delayed_plans.each do |plan|
49
+ fix_plan_state(plan)
49
50
  with_error_handling do
50
- if !plan.start_before.nil? && plan.start_before < check_time
51
+ if plan.execution_plan.state != :scheduled
52
+ # in case the previous process was terminated after running the plan, but before deleting the delayed plan record.
53
+ @logger.info("Execution plan #{plan.execution_plan_uuid} is expected to be in 'scheduled' state, was '#{plan.execution_plan.state}', skipping")
54
+ elsif !plan.start_before.nil? && plan.start_before < check_time
51
55
  @logger.debug "Failing plan #{plan.execution_plan_uuid}"
52
56
  plan.timeout
53
57
  else
@@ -63,6 +67,16 @@ module Dynflow
63
67
  world.persistence.delete_delayed_plans(:execution_plan_uuid => processed_plan_uuids) unless processed_plan_uuids.empty?
64
68
  end
65
69
 
70
+ private
71
+
72
+ # handle the case, where the process was termintated while planning was in progress before
73
+ def fix_plan_state(plan)
74
+ if plan.execution_plan.state == :planning
75
+ @logger.info("Execution plan #{plan.execution_plan_uuid} is expected to be in 'scheduled' state, was '#{plan.execution_plan.state}', auto-fixing")
76
+ plan.execution_plan.set_state(:scheduled, true)
77
+ plan.execution_plan.save
78
+ end
79
+ end
66
80
  end
67
81
  end
68
82
  end
@@ -8,9 +8,10 @@ module Dynflow
8
8
  # we should wrap it with this method, and we can ensure here to do
9
9
  # necessary cleanup, such as cleaning ActiveRecord connections
10
10
  def self.run_user_code
11
+ clear_connections = defined?(::ActiveRecord) && ActiveRecord::Base.connected? && ActiveRecord::Base.connection.open_transactions.zero?
11
12
  yield
12
13
  ensure
13
- ::ActiveRecord::Base.clear_active_connections! if defined? ::ActiveRecord
14
+ ::ActiveRecord::Base.clear_active_connections! if clear_connections
14
15
  end
15
16
 
16
17
  end
@@ -1,3 +1,3 @@
1
1
  module Dynflow
2
- VERSION = '1.0.0'.freeze
2
+ VERSION = '1.0.1'.freeze
3
3
  end
@@ -25,6 +25,20 @@ module Dynflow
25
25
  end
26
26
  let(:execution_plan) { delayed_plan.execution_plan }
27
27
 
28
+ describe 'abstract executor' do
29
+ let(:abstract_delayed_executor) { DelayedExecutors::AbstractCore.new(world) }
30
+
31
+ it 'handles wrong plan state' do
32
+ delayed_plan.execution_plan.state = :planning
33
+ abstract_delayed_executor.send(:process, [delayed_plan], @start_at)
34
+ delayed_plan.execution_plan.state.must_equal :planned
35
+
36
+ delayed_plan.execution_plan.set_state(:running, true)
37
+ abstract_delayed_executor.send(:process, [delayed_plan], @start_at)
38
+ delayed_plan.execution_plan.state.must_equal :running
39
+ end
40
+ end
41
+
28
42
  it 'returns the progress as 0' do
29
43
  execution_plan.progress.must_equal 0
30
44
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynflow
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Necas
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-03-29 00:00:00.000000000 Z
12
+ date: 2018-04-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json
@@ -602,7 +602,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
602
602
  version: '0'
603
603
  requirements: []
604
604
  rubyforge_project:
605
- rubygems_version: 2.7.3
605
+ rubygems_version: 2.6.12
606
606
  signing_key:
607
607
  specification_version: 4
608
608
  summary: DYNamic workFLOW engine