task-orchestrator 0.0.18 → 0.0.19

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,20 @@
1
+ orchestrator:
2
+ statedir: states
3
+ retry_handler:
4
+ description: retry handler test
5
+ save: true
6
+ steps:
7
+ - type: sequential
8
+ retries: 3
9
+ retry_delay: 1
10
+ on_failure: ignore
11
+ scripts:
12
+ - command: "bad bad command"
13
+ retry_handler: "echo Retry Handler"
14
+ - type: parallel
15
+ retries: 3
16
+ retry_delay: 1
17
+ on_failure: ignore
18
+ scripts:
19
+ - command: "bad bad parallel command"
20
+ retry_handler: "echo Retry Parallel Handler"
@@ -172,7 +172,7 @@ module Orchestrator
172
172
  command = { 'command' => interpolate_command(command) }
173
173
  elsif command.is_a?(Hash)
174
174
  invalid(error_prefix + " is missing command attribute") unless command.has_key?('command')
175
- ['command', 'ok_handler', 'failure_handler', 'condition'].each do |attribute|
175
+ ['command', 'ok_handler', 'failure_handler', 'retry_handler', 'condition'].each do |attribute|
176
176
  if command.has_key?(attribute)
177
177
  invalid(error_prefix + " #{attribute} attribute is invalid") unless command[attribute].is_a?(String)
178
178
  command[attribute] = interpolate_command(command[attribute])
@@ -239,6 +239,7 @@ module Orchestrator
239
239
  end
240
240
  end
241
241
  step['failure_handler'] = validate_command(step['failure_handler'], 'task failure handler') if step.has_key?('failure_handler')
242
+ step['retry_handler'] = validate_command(step['retry_handler'], 'task retry handler') if step.has_key?('retry_handler')
242
243
  end
243
244
  end
244
245
 
@@ -382,6 +383,10 @@ EOF
382
383
 
383
384
  failures += 1
384
385
  break if @retries < failures
386
+ if script.has_key?('retry_handler')
387
+ timeout = script.has_key?('timeout') ? script['timeout'].to_i : @timeout
388
+ run_command(script['retry_handler'],timeout)
389
+ end
385
390
  sleep @retry_delay
386
391
  end
387
392
 
@@ -459,6 +464,10 @@ EOF
459
464
  break if @statuses[index]
460
465
  failures += 1
461
466
  break if failures > @retries
467
+ if step['scripts'][index].has_key?('retry_handler')
468
+ timeout = step['scripts'][index].has_key?('timeout') ? step['scripts'][index]['timeout'].to_i : @timeout
469
+ run_command(step['scripts'][index]['retry_handler'],timeout)
470
+ end
462
471
  sleep @retry_delay
463
472
  end
464
473
  run_post_script_handlers(step['scripts'][index],@statuses[index])
@@ -1,3 +1,3 @@
1
1
  module Orchestrator
2
- VERSION ||= '0.0.18'
2
+ VERSION ||= '0.0.19'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: task-orchestrator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.18
4
+ version: 0.0.19
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-06-20 00:00:00.000000000 Z
12
+ date: 2014-10-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: pony
@@ -89,6 +89,7 @@ files:
89
89
  - lib/orchestrator/version.rb
90
90
  - lib/orchestrator/cli.rb
91
91
  - examples/sequential
92
+ - examples/retry_handler
92
93
  - examples/failure_handler
93
94
  - examples/multistep
94
95
  - examples/parallel