Skip to content
This repository has been archived by the owner on Jan 4, 2021. It is now read-only.

Commit

Permalink
(#526) Handle the exitcode of a still running task correctly
Browse files Browse the repository at this point in the history
This sets the exit code to -1 for still running tasks or tasks
that never started, handles -1 in the app to correctly record running
tasks
  • Loading branch information
ripienaar committed Aug 16, 2018
1 parent b3456d8 commit 54eeb09
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/mcollective/application/tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ def request_and_report(action, arguments, taskid=nil) # rubocop:disable Metrics/
if reply[:statuscode] == 3
fail_nodes += 1
task_not_known_nodes += 1
elsif status[:exitcode] == 0
elsif [-1, 0].include?(status[:exitcode])
status[:completed] ? completed_nodes += 1 : running_nodes += 1
runtime += status[:runtime]
reply[:statuscode] == 0 ? success_nodes += 1 : fail_nodes += 1
Expand Down
2 changes: 1 addition & 1 deletion lib/mcollective/util/tasks_support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ def task_status(requestid)
"caller" => nil,
"stdout" => "",
"stderr" => "",
"exitcode" => 127,
"exitcode" => -1,
"runtime" => task_runtime(requestid),
"start_time" => Time.at(0).utc,
"wrapper_spawned" => false,
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/mcollective/util/tasks_support_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ module Util
"spool" => spool,
"stdout" => ts.create_task_stdout("", true, 127, err),
"stderr" => "",
"exitcode" => 127,
"exitcode" => -1,
"runtime" => 0.0,
"wrapper_spawned" => false,
"wrapper_error" => err,
Expand All @@ -215,7 +215,7 @@ module Util
"spool" => spool,
"stdout" => stdout,
"stderr" => "",
"exitcode" => 127,
"exitcode" => -1,
"runtime" => 10,
"wrapper_spawned" => true,
"wrapper_error" => "",
Expand Down

0 comments on commit 54eeb09

Please sign in to comment.