Skip to content

Commit

Permalink
Avoid sending empty result
Browse files Browse the repository at this point in the history
This patch is fixing the case where empty results have been sent
when executor failed to execute a command.
  • Loading branch information
paramite committed Jun 18, 2019
1 parent f5ec38f commit a4ae6b8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ func main() {
res, err := sensuExecutor.Execute(req)
if err != nil {
//TODO: log warning
continue
}
results <- res
default:
Expand Down
4 changes: 2 additions & 2 deletions sensu/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ func (self *Executor) Execute(request CheckRequest) (Result, error) {
if _, ok := self.scriptCache[request.Command]; !ok {
scriptFile, err := ioutil.TempFile(self.TmpBaseDir, "check-")
if err != nil {
return Result{}, err
return Result{}, fmt.Errorf("Failed to create temporary file for script: %s", err)
}
_, err = scriptFile.Write([]byte(fmt.Sprintf("#!/usr/bin/env sh\n%s\n", request.Command)))
if err != nil {
return Result{}, err
return Result{}, fmt.Errorf("Failed to write script content to temporary file: %s", err)
}
self.scriptCache[request.Command] = scriptFile.Name()
scriptFile.Close()
Expand Down

0 comments on commit a4ae6b8

Please sign in to comment.