diff --git a/client/allocrunner/taskrunner/envoy_bootstrap_hook.go b/client/allocrunner/taskrunner/envoy_bootstrap_hook.go index 8848aadda6e0..3e9622b17d6e 100644 --- a/client/allocrunner/taskrunner/envoy_bootstrap_hook.go +++ b/client/allocrunner/taskrunner/envoy_bootstrap_hook.go @@ -1,6 +1,7 @@ package taskrunner import ( + "bytes" "context" "encoding/json" "errors" @@ -23,6 +24,7 @@ import ( "github.com/hashicorp/nomad/helper" "github.com/hashicorp/nomad/nomad/structs" "github.com/hashicorp/nomad/nomad/structs/config" + "github.com/shoenig/netlog" "oss.indeed.com/go/libtime/decay" ) @@ -266,7 +268,7 @@ func (h *envoyBootstrapHook) Prestart(ctx context.Context, req *ifs.TaskPrestart bootstrapFilePath := filepath.Join(req.TaskDir.SecretsDir, "envoy_bootstrap.json") // Write everything related to the command to enable debugging - bootstrapStderrPath := filepath.Join(req.TaskDir.LogDir, "envoy_bootstrap.stderr.0") + // bootstrapStderrPath := filepath.Join(req.TaskDir.LogDir, "envoy_bootstrap.stderr.0") bootstrapEnvPath := filepath.Join(req.TaskDir.SecretsDir, ".envoy_bootstrap.env") bootstrapCmdPath := filepath.Join(req.TaskDir.SecretsDir, ".envoy_bootstrap.cmd") @@ -342,12 +344,14 @@ func (h *envoyBootstrapHook) Prestart(ctx context.Context, req *ifs.TaskPrestart cmd.Stdout = stdout // Redirect stderr into another file for later debugging. - stderr, fileErr := os.OpenFile(bootstrapStderrPath, os.O_RDWR|os.O_CREATE, 0644) - if fileErr != nil { - return false, fmt.Errorf("failed to create alloc/logs/envoy_bootstrap.stderr.0 for envoy: %w", fileErr) - } - defer stderr.Close() - cmd.Stderr = stderr + //stderr, fileErr := os.OpenFile(bootstrapStderrPath, os.O_RDWR|os.O_CREATE, 0644) + //if fileErr != nil { + // return false, fmt.Errorf("failed to create alloc/logs/envoy_bootstrap.stderr.0 for envoy: %w", fileErr) + //} + //defer stderr.Close() + // cmd.Stderr = stderr + buf := new(bytes.Buffer) + cmd.Stderr = buf // Generate bootstrap cmdErr = cmd.Run() @@ -359,6 +363,8 @@ func (h *envoyBootstrapHook) Prestart(ctx context.Context, req *ifs.TaskPrestart return false, nil } + netlog.Red("create envoy", "error", buf.String()) + // Command failed, prepare for retry // // Cleanup the bootstrap file. An errors here is not