Skip to content

Commit

Permalink
Merge pull request #5598 from hashicorp/b-dont-forward-logs
Browse files Browse the repository at this point in the history
fix crash when executor parent nomad process dies
  • Loading branch information
notnoop authored Apr 23, 2019
2 parents 04d4d86 + c07c0c8 commit c76130c
Showing 1 changed file with 1 addition and 19 deletions.
20 changes: 1 addition & 19 deletions command/executor_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package command

import (
"encoding/json"
"io"
"os"
"strings"

Expand All @@ -11,17 +10,9 @@ import (
plugin "github.com/hashicorp/go-plugin"

"github.com/hashicorp/nomad/drivers/shared/executor"
"github.com/hashicorp/nomad/lib/circbufwriter"
"github.com/hashicorp/nomad/plugins/base"
)

const (
// circleBufferSize is the size of the in memory ring buffer used for
// go-plugin logging to stderr. When the buffer exceeds this size before
// flushing it will begin overwriting data
circleBufferSize = 64 * 1024
)

type ExecutorPluginCommand struct {
Meta
}
Expand Down Expand Up @@ -55,20 +46,11 @@ func (e *ExecutorPluginCommand) Run(args []string) int {
return 1
}

// If the client detatches from go-plugin it will block on logging to stderr.
// This buffered writer will never block on write, and instead buffer the
// writes to a ring buffer.
bufferedStderrW := circbufwriter.New(os.Stderr, circleBufferSize)

// Tee the logs to stderr and the file so that they are streamed to the
// client
out := io.MultiWriter(f, bufferedStderrW)

// Create the logger
logger := log.New(&log.LoggerOptions{
Level: hclog.LevelFromString(executorConfig.LogLevel),
JSONFormat: true,
Output: out,
Output: f,
})

plugin.Serve(&plugin.ServeConfig{
Expand Down

0 comments on commit c76130c

Please sign in to comment.