From 0ffcdbe6c347c97a4c9e435c66e5f01e289a7dd2 Mon Sep 17 00:00:00 2001 From: Tom McSweeney Date: Mon, 1 Aug 2016 12:57:10 -0700 Subject: [PATCH] Fixes #1113: removes fixed max-failure value from task creation --- cmd/snapctl/flags.go | 7 +++++-- core/task.go | 7 ++++++- scheduler/task.go | 5 +++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/cmd/snapctl/flags.go b/cmd/snapctl/flags.go index 3f1c9b33b..b5b346f53 100644 --- a/cmd/snapctl/flags.go +++ b/cmd/snapctl/flags.go @@ -19,10 +19,13 @@ limitations under the License. package main -import "github.com/codegangsta/cli" +import ( + "github.com/codegangsta/cli" + "github.com/intelsdi-x/snap/mgmt/rest" +) const ( - DefaultMaxFailures = 10 + DefaultMaxFailures = rest.DefaultMaxFailures ) var ( diff --git a/core/task.go b/core/task.go index b5a1d212b..bdc7d9dbb 100644 --- a/core/task.go +++ b/core/task.go @@ -197,7 +197,12 @@ func CreateTaskFromContent(body io.ReadCloser, if tr.Name != "" { opts = append(opts, SetTaskName(tr.Name)) } - opts = append(opts, OptionStopOnFailure(10)) + + // if a MaxFailures value is included as part of the task creation request + if tr.MaxFailures > 0 { + // then set the appropriate value in the opts + opts = append(opts, OptionStopOnFailure(tr.MaxFailures)) + } if mode == nil { mode = &tr.Start diff --git a/scheduler/task.go b/scheduler/task.go index dbe8a33af..9cda03cd5 100644 --- a/scheduler/task.go +++ b/scheduler/task.go @@ -34,6 +34,7 @@ import ( "github.com/intelsdi-x/snap/core" "github.com/intelsdi-x/snap/core/scheduler_event" "github.com/intelsdi-x/snap/grpc/controlproxy" + "github.com/intelsdi-x/snap/mgmt/rest" "github.com/intelsdi-x/snap/pkg/schedule" "github.com/intelsdi-x/snap/scheduler/wmap" ) @@ -41,8 +42,8 @@ import ( const ( // DefaultDeadlineDuration - The default timeout is 5 second DefaultDeadlineDuration = time.Second * 5 - // DefaultStopOnFailure - The default stopping a failure is after three tries - DefaultStopOnFailure = 3 + // DefaultStopOnFailure - The default stopping a failure is after ten tries + DefaultStopOnFailure = rest.DefaultMaxFailures ) var (