Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Commit

Permalink
Show server connect humanize error in retry UI
Browse files Browse the repository at this point in the history
Give a hint as to why the CLI is failing to connect to the server
directly in the retry ui stepgroup
  • Loading branch information
briancain committed Nov 1, 2021
1 parent 2fa7845 commit 89d9a7b
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions internal/cli/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,24 +116,25 @@ func (c *InstallCommand) Run(args []string) int {
s := sg.Add("Connecting to: %s", contextConfig.Server.Address)
defer func() { s.Abort() }()

// Connect and retry
// Connect and retry for a full minute
var conn *grpc.ClientConn
retries := 0
maxRetries := 12 // attempts to retry for a full minute
sr := sg.Add("Attempting to make connection to server...")
maxRetries := 12
sr := sg.Add("Attempting to make connection to server...") // stepgroup for retry ui

for {
log.Info("connecting to the server so we can set the server config", "addr", contextConfig.Server.Address)
conn, err = serverclient.Connect(ctx,
serverclient.FromContextConfig(contextConfig),
serverclient.Timeout(5*time.Second),
)
if err != nil {
c.ui.Output(
sr.Update(
"Error connecting to server: %s\n\n%s",
clierrors.Humanize(err),
errInstallRunning,
terminal.WithWarningStyle(),
)
sr.Status(terminal.StatusError)
// dont return the error yet
} else {
sr.Update("Successfully connected to Waypoint server in Nomad!")
Expand All @@ -149,7 +150,7 @@ func (c *InstallCommand) Run(args []string) int {
}

// add ui output for iteration loop retry number
sr.Update("Retry connecting to server ... %d/%d retries", retries, maxRetries)
sr.Update("Retry connecting to server ... %d/%d retries: %s", retries, maxRetries, clierrors.Humanize(err))
sr.Status(terminal.StatusWarn)
time.Sleep(5 * time.Second)
retries++
Expand Down

0 comments on commit 89d9a7b

Please sign in to comment.