Skip to content

Commit

Permalink
Addressing comment on PR/78
Browse files Browse the repository at this point in the history
  • Loading branch information
madmeignanam committed Oct 7, 2019
1 parent 5541d3e commit 49aab2f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion plugin/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ type PodStatusHook interface {
// Execute is invoked when the pod.taskStatusCh channel has a new status. It returns an error on failure,
// and also a flag "failExec" indicating if the error needs to fail the execution when a series of hooks are executed
// This is to support cases where a few hooks can be executed in a best effort manner and need not fail the executor
Execute(podStatus string, data interface{}) (err error, failExec bool)
Execute(podStatus string, data interface{}) (failExec bool, err error)
}
2 changes: 1 addition & 1 deletion utils/pod/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -1295,7 +1295,7 @@ func execPodStatusHooks(status string, taskInfo *mesos.TaskInfo) error {
logger.Errorf("Hook %s is nil, not initialized? still continuing with available hooks", name)
continue
}
if pherr, failExec := hook.Execute(status, taskInfo); pherr != nil {
if failExec, pherr := hook.Execute(status, taskInfo); pherr != nil {
logger.Errorf(
"PodStatusHook %s failed with %v and is not best effort, so stopping further execution ",
name, pherr)
Expand Down
12 changes: 6 additions & 6 deletions utils/pod/pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,15 +243,15 @@ type happyHook struct{}
type mandatoryHook struct{}
type panicHook struct{}

func (p *happyHook) Execute(podStatus string, data interface{}) (err error, bestEffort bool) {
return nil, true
func (p *happyHook) Execute(podStatus string, data interface{}) (failExec bool, err error) {
return true, nil
}

func (p *mandatoryHook) Execute(status string, data interface{}) (err error, bestEffort bool) {
return errors.New("failure test case"), true
func (p *mandatoryHook) Execute(status string, data interface{}) (failExec bool, err error) {
return true, errors.New("failure test case")
}

func (p *panicHook) Execute(status string, data interface{}) (err error, bestEffort bool) {
func (p *panicHook) Execute(status string, data interface{}) (failExec bool, err error) {
panic("unit test panic")
return errors.New("panic test case"), false
return false, errors.New("panic test case")
}

0 comments on commit 49aab2f

Please sign in to comment.