diff --git a/command/connect/envoy/pipe-bootstrap/connect_envoy_pipe-bootstrap.go b/command/connect/envoy/pipe-bootstrap/connect_envoy_pipe-bootstrap.go index 71d0969f1f..d9b816f69f 100644 --- a/command/connect/envoy/pipe-bootstrap/connect_envoy_pipe-bootstrap.go +++ b/command/connect/envoy/pipe-bootstrap/connect_envoy_pipe-bootstrap.go @@ -6,8 +6,9 @@ import ( "os" "time" - "github.com/hashicorp/consul/command/flags" "github.com/mitchellh/cli" + + "github.com/hashicorp/consul/command/flags" ) func New(ui cli.Ui) *cmd { @@ -27,23 +28,21 @@ func (c *cmd) init() { } func (c *cmd) Run(args []string) int { - // This should never be alive for very long. In case bad things happen and - // Envoy never starts limit how long we live before just exiting so we can't - // accumulate tons of these zombie children. - time.AfterFunc(10*time.Second, func() { - // Force cleanup - if len(args) > 0 { - os.RemoveAll(args[0]) - } - os.Exit(99) - }) - // Read from STDIN, write to the named pipe provided in the only positional arg if len(args) != 1 { c.UI.Error("Expecting named pipe path as argument") return 1 } + // This should never be alive for very long. In case bad things happen and + // Envoy never starts limit how long we live before just exiting so we can't + // accumulate tons of these zombie children. + time.AfterFunc(10*time.Second, func() { + // Force cleanup + os.RemoveAll(args[0]) + os.Exit(99) + }) + // WRONLY is very important here - the open() call will block until there is a // reader (Envoy) if we open it with RDWR though that counts as an opener and // we will just send the data to ourselves as the first opener and so only @@ -60,8 +59,7 @@ func (c *cmd) Run(args []string) int { return 1 } - err = f.Close() - if err != nil { + if err = f.Close(); err != nil { c.UI.Error(err.Error()) return 1 } diff --git a/command/connect/envoy/pipe-bootstrap/connect_envoy_pipe-bootstrap_test.go b/command/connect/envoy/pipe-bootstrap/connect_envoy_pipe-bootstrap_test.go index 8f6ee44516..76ed3157c9 100644 --- a/command/connect/envoy/pipe-bootstrap/connect_envoy_pipe-bootstrap_test.go +++ b/command/connect/envoy/pipe-bootstrap/connect_envoy_pipe-bootstrap_test.go @@ -8,7 +8,6 @@ import ( ) func TestConnectEnvoyPipeBootstrapCommand_noTabs(t *testing.T) { - t.Parallel() if strings.ContainsRune(New(cli.NewMockUi()).Help(), '\t') { t.Fatal("help has tabs") }