smart_proxy_dynflow 0.8.2 → 0.9.0

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: 6444ef5fcad649ae35d106b149f2832ea50c4cbbf9d6a1be7575332e9585fe8b
4
- data.tar.gz: 587ed9c21c9c0dd3e320e29c28eb3cf76904aa3222c901979fc8e29023630f16
3
+ metadata.gz: 86c46197119a24e70fc65afe7698d99473b5aaaae0eb2b32aed48523a03de021
4
+ data.tar.gz: ea987bf5d6797680a8c37c9e03d4872ad714254624a98195749594febdaddb06
5
5
  SHA512:
6
- metadata.gz: 4b27f6de4ae4353b6fdb45334b920b66bea2de0dce26af6c4f52855e9e28641acd9ec917e8d313b8aafb9c70f7077fa9223417d943e9ac2a30d6c05995d66e0a
7
- data.tar.gz: e0877874c73541ab78d2957693202959bbffce5771ff71c9f1bee0664c5f78bf180addece3668206662e70cf08481d3586ff88f82eef3fc293d9a837ccfca75d
6
+ metadata.gz: b1fdc2770779b35094098506a8178696708a8c207e083fd1c3cd1d148fc63eca35cefdad3698e86f2915919a935ae2c560f7c250251fb1eddf91dd27ebf7e339
7
+ data.tar.gz: fb649ed0bf1c2d7a56f30ff29c5cc718b93832700d109a92740fd43813c0fa73be424eaa0b9d363696e9e4faae45f9bb4d1a5aa2efa5c43ca35032332f13f3eb
@@ -60,6 +60,16 @@ module Proxy
60
60
  tasks_count(params['state']).to_json
61
61
  end
62
62
 
63
+ post "/tasks/statuses" do
64
+ params = MultiJson.load(request.body.read)
65
+ ids = params.fetch('task_ids', [])
66
+ if ids.empty?
67
+ status 422
68
+ return { error: "'task_ids' needs to be provided and be a non-empty array of task UUIDs" }
69
+ end
70
+ tasks_statuses(params['task_ids']).to_json
71
+ end
72
+
63
73
  # capturing post "/tasks/:task_id/(update|done)"
64
74
  post TASK_UPDATE_REGEXP_PATH do |task_id, _action|
65
75
  data = MultiJson.load(request.body.read)
@@ -1,3 +1,6 @@
1
+ require 'smart_proxy_dynflow/action/external_polling'
2
+ require 'smart_proxy_dynflow/action/runner'
3
+
1
4
  module Proxy
2
5
  module Dynflow
3
6
  module Helpers
@@ -35,16 +38,19 @@ module Proxy
35
38
 
36
39
  def task_status(task_id)
37
40
  ep = world.persistence.load_execution_plan(task_id)
38
- actions = ep.actions.map do |action|
39
- refresh_output(ep, action)
40
- expand_output(action)
41
- end
42
- ep.to_hash.merge(:actions => actions)
41
+ execution_plan_status(ep)
43
42
  rescue KeyError => _e
44
43
  status 404
45
44
  {}
46
45
  end
47
46
 
47
+ def tasks_statuses(task_ids)
48
+ eps = world.persistence.find_execution_plans(filters: { uuid: task_ids })
49
+ eps.reduce({}) do |acc, ep|
50
+ acc.update(ep.id => execution_plan_status(ep))
51
+ end
52
+ end
53
+
48
54
  def tasks_count(state)
49
55
  state ||= 'all'
50
56
  filter = state != 'all' ? { :filters => { :state => [state] } } : {}
@@ -69,6 +75,14 @@ module Proxy
69
75
  hash[:output][:result] = action.output_result if action.is_a?(Proxy::Dynflow::Action::Runner)
70
76
  hash
71
77
  end
78
+
79
+ def execution_plan_status(plan)
80
+ actions = plan.actions.map do |action|
81
+ refresh_output(plan, action)
82
+ expand_output(action)
83
+ end
84
+ plan.to_hash.merge(:actions => actions)
85
+ end
72
86
  end
73
87
  end
74
88
  end
@@ -125,9 +125,15 @@ module Proxy
125
125
  return
126
126
  end
127
127
 
128
+ # Even though the FDs are still open, the child might have exited already
129
+ pid, status = Process.waitpid2(@pid, Process::WNOHANG)
130
+ timeout = 1 if pid
131
+
128
132
  ready_readers, ready_writers = IO.select(readers, writers, nil, timeout)
129
133
  (ready_readers || []).each(&:read_available!)
130
134
  (ready_writers || []).each(&:write_available!)
135
+
136
+ finish(status) if pid
131
137
  end
132
138
 
133
139
  # Sets block to be executed each time data is read from child process' standard output
@@ -156,11 +162,13 @@ module Proxy
156
162
  # Makes the process manager finish its run, closing opened FDs and reaping the child process
157
163
  #
158
164
  # @return [void]
159
- def finish
165
+ def finish(status = nil)
160
166
  close
161
- unless @pid == -1
167
+ if status.nil? && @pid != -1 && !done?
162
168
  _pid, status = Process.wait2(@pid)
163
169
  @status = status.exitstatus
170
+ elsif status
171
+ @status = status.exitstatus
164
172
  end
165
173
  end
166
174
  end
@@ -1,5 +1,5 @@
1
1
  module Proxy
2
2
  module Dynflow
3
- VERSION = '0.8.2'.freeze
3
+ VERSION = '0.9.0'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_proxy_dynflow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.2
4
+ version: 0.9.0
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: 2022-09-27 00:00:00.000000000 Z
11
+ date: 2022-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dynflow