dynflow 1.9.0 → 1.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c1eddd0493e79287abacde548a9237bf6d13c0ec6f5d2e67d802a85de9be29db
4
- data.tar.gz: f0826ba6cc0c8066a70d6c7b2cf5f11e5e7d29e1c96915057b4f099546fd1a16
3
+ metadata.gz: 7b7e50b6a77767c3cae603ef773f86c0ef218572ab37d4cf20eaa39a7baeb788
4
+ data.tar.gz: 3a38fce650541ffc1626a9eab628e0f4e2ccebf8a86ff8e25591ef334805293c
5
5
  SHA512:
6
- metadata.gz: 7f2f82d41dbe9fa17ed1dc184dfaba98fc8e49ced49ec14ba523de6a4965b5ea0d9626d859b9f439647e47c1216a6d2b35a41d0dcb4a4e2d479e83cee736cd91
7
- data.tar.gz: f362ca21ed154a5bd0b4ec5e5814cbb1fd48b78a51390bb17fb259d097fd5f12471c7022b85275ee4af3ee88e5efe2cc6dd199256ac6603bb13464c1ef1fe662
6
+ metadata.gz: aea5e2c7ef158cf395e10b7d487070772e9b3a58f72feaea97c12b90c7ad680f69c039a0f443a938f160feceb3993d58bb9eadc91e0be933d6cee43172a35e40
7
+ data.tar.gz: db00fb0a44f91871d6b0a3b39b6c4d8da7ffe3eaa363ee816e1de95aae576991a83c24a62ecb45212626fdb7de4de3342d84c5ca4fb2c7c766d0c5688301320e
@@ -102,7 +102,7 @@ module Dynflow::Action::V2
102
102
 
103
103
  def increase_counts(planned, failed)
104
104
  output[:planned_count] += planned + failed
105
- output[:failed_count] = output.fetch(:failed_count, 0) + failed
105
+ output[:failed_count] = output.fetch(:failed_count, 0) + failed
106
106
  output[:pending_count] = output.fetch(:pending_count, 0) + planned
107
107
  output[:success_count] ||= 0
108
108
  end
@@ -129,12 +129,20 @@ module Dynflow::Action::V2
129
129
  end
130
130
 
131
131
  def recalculate_counts
132
- total = total_count
133
- failed = sub_plans_count('state' => %w(paused stopped), 'result' => %w(error warning))
132
+ total = total_count
133
+ if output[:cancelled_timestamp]
134
+ cancelled_scheduled_plans = sub_plans_count_after(output[:cancelled_timestamp], { 'state' => %w(paused stopped), 'result' => %w(error warning) })
135
+ cancelled_unscheduled_plans = total_count - output[:planned_count]
136
+ cancelled = cancelled_unscheduled_plans + cancelled_scheduled_plans
137
+ else
138
+ cancelled = cancelled_scheduled_plans = 0
139
+ end
140
+ failed = sub_plans_count('state' => %w(paused stopped), 'result' => %w(error warning)) - cancelled_scheduled_plans
134
141
  success = sub_plans_count('state' => 'stopped', 'result' => 'success')
135
- output.update(:pending_count => total - failed - success,
136
- :failed_count => failed - output.fetch(:resumed_count, 0),
137
- :success_count => success)
142
+ output.update(:pending_count => total - failed - success - cancelled_scheduled_plans,
143
+ :failed_count => failed - output.fetch(:resumed_count, 0),
144
+ :success_count => success,
145
+ :cancelled_count => cancelled)
138
146
  end
139
147
 
140
148
  def counts_set?
@@ -142,7 +150,7 @@ module Dynflow::Action::V2
142
150
  end
143
151
 
144
152
  def check_for_errors!
145
- raise SubtaskFailedException.new("A sub task failed") if output[:failed_count] > 0
153
+ raise SubtaskFailedException.new("A sub task failed") if output[:failed_count] + output[:cancelled_count] > 0
146
154
  end
147
155
 
148
156
  # Helper for creating sub plans
@@ -173,6 +181,7 @@ module Dynflow::Action::V2
173
181
  def cancel!(force = false)
174
182
  # Count the not-yet-planned tasks as cancelled
175
183
  output[:cancelled_count] = total_count - output[:planned_count]
184
+ output[:cancelled_timestamp] ||= Time.now.utc.iso8601 # time in UTC for comparison with UTC times in the database
176
185
  on_planning_finished if output[:cancelled_count].positive?
177
186
  # Pass the cancel event to running sub plans if they can be cancelled
178
187
  sub_plans(:state => 'running').each { |sub_plan| sub_plan.cancel(force) if sub_plan.cancellable? }
@@ -198,7 +207,9 @@ module Dynflow::Action::V2
198
207
  end
199
208
 
200
209
  def remaining_count
201
- total_count - output[:cancelled_count] - output[:planned_count]
210
+ return 0 if output[:cancelled_timestamp]
211
+
212
+ total_count - output[:planned_count]
202
213
  end
203
214
 
204
215
  private
@@ -216,5 +227,9 @@ module Dynflow::Action::V2
216
227
  def sub_plans_count(filter = {})
217
228
  world.persistence.find_execution_plan_counts(filters: sub_plan_filter.merge(filter))
218
229
  end
230
+
231
+ def sub_plans_count_after(timestamp, filter = {})
232
+ world.persistence.find_execution_plan_counts_after(timestamp, { filters: sub_plan_filter.merge(filter) })
233
+ end
219
234
  end
220
235
  end
@@ -73,6 +73,10 @@ module Dynflow
73
73
  adapter.find_execution_plan_counts(options)
74
74
  end
75
75
 
76
+ def find_execution_plan_counts_after(timestamp, options)
77
+ adapter.find_execution_plan_counts_after(timestamp, options)
78
+ end
79
+
76
80
  def delete_execution_plans(filters, batch_size = 1000, enforce_backup_dir = nil)
77
81
  backup_dir = enforce_backup_dir || current_backup_dir
78
82
  adapter.delete_execution_plans(filters, batch_size, backup_dir)
@@ -46,6 +46,10 @@ module Dynflow
46
46
  filter(:execution_plan, options[:filters]).count
47
47
  end
48
48
 
49
+ def find_execution_plan_counts_after(timestamp, options = {})
50
+ raise NotImplementedError
51
+ end
52
+
49
53
  def find_execution_plan_statuses(options)
50
54
  raise NotImplementedError
51
55
  end
@@ -78,6 +78,10 @@ module Dynflow
78
78
  filter(:execution_plan, table(:execution_plan), options[:filters]).count
79
79
  end
80
80
 
81
+ def find_execution_plan_counts_after(timestamp, options = {})
82
+ filter(:execution_plan, table(:execution_plan), options[:filters]).filter(::Sequel.lit('ended_at >= ?', timestamp)).count
83
+ end
84
+
81
85
  def find_execution_plan_statuses(options)
82
86
  plans = filter(:execution_plan, table(:execution_plan), options[:filters])
83
87
  .select(:uuid, :state, :result)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dynflow
4
- VERSION = '1.9.0'
4
+ VERSION = '1.9.1'
5
5
  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.9.0
4
+ version: 1.9.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: 2024-06-11 00:00:00.000000000 Z
12
+ date: 2025-04-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: algebrick
@@ -683,7 +683,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
683
683
  - !ruby/object:Gem::Version
684
684
  version: '0'
685
685
  requirements: []
686
- rubygems_version: 3.1.2
686
+ rubygems_version: 3.3.27
687
687
  signing_key:
688
688
  specification_version: 4
689
689
  summary: DYNamic workFLOW engine