From fe53c4684c2c15425cda6d3d46de973d62230fe6 Mon Sep 17 00:00:00 2001 From: Anton Averchenkov <84287187+averche@users.noreply.github.com> Date: Wed, 31 May 2023 12:04:33 -0400 Subject: [PATCH] agent: Don't render templates to stdout in supervisor mode (#20884) --- command/agent/exec/exec.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/command/agent/exec/exec.go b/command/agent/exec/exec.go index a1ea97addc..1d924f8c97 100644 --- a/command/agent/exec/exec.go +++ b/command/agent/exec/exec.go @@ -122,6 +122,9 @@ func (s *Server) Run(ctx context.Context, incomingVaultToken chan string) error return fmt.Errorf("template server failed to create: %w", err) } + // prevent the templates from being rendered to stdout in "dry" mode + s.runner.SetOutStream(io.Discard) + s.numberOfTemplates = len(s.runner.TemplateConfigMapping()) for { @@ -153,6 +156,10 @@ func (s *Server) Run(ctx context.Context, incomingVaultToken chan string) error s.logger.Error("template server failed with new Vault token", "error", err) continue } + + // prevent the templates from being rendered to stdout in "dry" mode + s.runner.SetOutStream(io.Discard) + go s.runner.Start() }