Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix crash when executor parent nomad process dies #5598

Merged
merged 1 commit into from
Apr 23, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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