From 4524f9cd9a5e0dbf079cc2bd1c174609bf58884c Mon Sep 17 00:00:00 2001 From: irenarindos Date: Wed, 11 Sep 2024 10:40:59 -0400 Subject: [PATCH] (cmd): unhide client agent commands --- internal/cmd/commands/clientagentcmd/addtoken.go | 6 ++---- internal/cmd/commands/clientagentcmd/status.go | 1 + .../commands/clientagentcmd/wrapper_register.go | 15 ++++++++++++--- internal/cmd/main.go | 2 +- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/internal/cmd/commands/clientagentcmd/addtoken.go b/internal/cmd/commands/clientagentcmd/addtoken.go index 71201b5308..2328740491 100644 --- a/internal/cmd/commands/clientagentcmd/addtoken.go +++ b/internal/cmd/commands/clientagentcmd/addtoken.go @@ -48,10 +48,8 @@ func addToken(ctx context.Context, apiClient *api.Client, port uint) (*api.Respo client.RetryWaitMin = 100 * time.Millisecond client.RetryWaitMax = 1500 * time.Millisecond - // TODO (ICU-13140): Until we release the client agent, do not retry attempts - // to connect to the client agent since it adds a noticeably long delay to - // the command. - client.RetryMax = 0 + // Explicitly setting this to 1, since this runs after every command and we don't want any delays + client.RetryMax = 1 req, err := retryablehttp.NewRequestWithContext(ctx, "POST", clientAgentUrl(port, "v1/tokens"), retryablehttp.ReaderFunc(func() (io.Reader, error) { diff --git a/internal/cmd/commands/clientagentcmd/status.go b/internal/cmd/commands/clientagentcmd/status.go index 23130c01c2..480b179802 100644 --- a/internal/cmd/commands/clientagentcmd/status.go +++ b/internal/cmd/commands/clientagentcmd/status.go @@ -118,6 +118,7 @@ func (c *StatusCommand) Status(ctx context.Context) (*api.Response, *GetStatusRe client.Logger = nil client.RetryWaitMin = 100 * time.Millisecond client.RetryWaitMax = 1500 * time.Millisecond + client.RetryMax = 1 req, err := retryablehttp.NewRequestWithContext(ctx, "GET", clientAgentUrl(c.FlagClientAgentPort, "v1/status"), nil) if err != nil { diff --git a/internal/cmd/commands/clientagentcmd/wrapper_register.go b/internal/cmd/commands/clientagentcmd/wrapper_register.go index 76d8fe4a36..4106b5f99a 100644 --- a/internal/cmd/commands/clientagentcmd/wrapper_register.go +++ b/internal/cmd/commands/clientagentcmd/wrapper_register.go @@ -5,14 +5,23 @@ package clientagentcmd import ( "context" + "os" + "strings" "github.com/hashicorp/boundary/internal/cmd/base" "github.com/hashicorp/boundary/internal/cmd/wrapper" ) -// TODO (ICU-13140): Remove this and re-enable error output for background -// client agent token sending. -const allowErrorOutput = false +var allowErrorOutput = false + +const EnvBoundaryClientAgentCliErrorOutput = "BOUNDARY_CLIENT_AGENT_CLI_ERROR_OUTPUT" + +func init() { + errOutput := os.Getenv(EnvBoundaryClientAgentCliErrorOutput) + if strings.ToLower(errOutput) == "true" { + allowErrorOutput = true + } +} func init() { if err := wrapper.RegisterSuccessfulCommandCallback("client-agent", hook); err != nil { diff --git a/internal/cmd/main.go b/internal/cmd/main.go index 26899aa9e0..4319264bc1 100644 --- a/internal/cmd/main.go +++ b/internal/cmd/main.go @@ -241,7 +241,7 @@ func RunCustom(args []string, runOpts *RunOptions) (exitCode int) { initCommands(ui, serverCmdUi, runOpts) - hiddenCommands := []string{"version", "client-agent", "client-agent status", "client-agent pause", "client-agent resume", "client-agent sessions"} + hiddenCommands := []string{"version"} cli := &cli.CLI{ Name: "boundary",