Skip to content

Commit

Permalink
Fixes intelsdi-x#1113: removes fixed max-failure value from task crea…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
Tom McSweeney committed Aug 1, 2016
1 parent 8f40854 commit 0ffcdbe
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
7 changes: 5 additions & 2 deletions cmd/snapctl/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
7 changes: 6 additions & 1 deletion core/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions scheduler/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,16 @@ 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"
)

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 (
Expand Down

0 comments on commit 0ffcdbe

Please sign in to comment.