Skip to content

Commit

Permalink
Enhance readability of healthcheck prompt messages
Browse files Browse the repository at this point in the history
highlight healthcheck prompt using ANSI colors in error messages

Updated return values

Updates for the return messages

Updated the prompt message to make it bold and add empty lines
  • Loading branch information
xiaoyu74 committed Aug 29, 2024
1 parent 1491234 commit 6cc1c52
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
9 changes: 6 additions & 3 deletions cmd/ocm-backplane/cloud/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,17 @@ func runConsole(cmd *cobra.Command, argv []string) (err error) {

// ======== Get cloud console from backplane API ============
consoleResponse, err := queryConfig.GetCloudConsole()

// Declare helperMsg
helperMsg := "\n\033[1mNOTE: To troubleshoot the connectivity issues, please run `ocm-backplane health-check`\033[0m\n\n"

if err != nil {
// Check API connection with configured proxy
if connErr := backplaneConfiguration.CheckAPIConnection(); connErr != nil {
logger.Error("Cannot connect to backplane API URL, check if you need to use a proxy/VPN to access backplane:")
logger.Errorf("Error: %v", connErr)
logger.Info("To troubleshoot connectivity issues, please run the following command:")
logger.Info("ocm-backplane health-check")
logger.Errorf("Error: %v.\n%s", connErr, helperMsg)
}

return fmt.Errorf("failed to get cloud console for cluster %v: %w", clusterID, err)
}

Expand Down
10 changes: 5 additions & 5 deletions cmd/ocm-backplane/login/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,15 +306,15 @@ func runLogin(cmd *cobra.Command, argv []string) (err error) {
return fmt.Errorf("cluster %s is hibernating, login failed", clusterKey)
}

// Declare helperMsg
helperMsg := "\n\033[1mNOTE: To troubleshoot the connectivity issues, please run `ocm-backplane health-check`\033[0m\n\n"

// Check API connection with configured proxy
if connErr := bpConfig.CheckAPIConnection(); connErr != nil {
logger.Errorf("Cannot connect to backplane API URL, check if you need to use a proxy/VPN to access backplane: %v. To troubleshoot connectivity issues, please run the following command: ocm-backplane health-check", connErr)
return fmt.Errorf("cannot connect to backplane API URL: %v", connErr)
return fmt.Errorf("cannot connect to Backplane API URL: %v.\n%s", connErr, helperMsg)
}

// Log suggestion to run connectivity health check if login fails
logger.Errorf("Login failed: %v. To troubleshoot connectivity issues, please run the following command: ocm-backplane health-check", err)
return fmt.Errorf("login failed: %v", err)
return fmt.Errorf("login Attempt Failed: %v.\n%s", err, helperMsg)
}

logger.WithField("URL", bpAPIClusterURL).Debugln("Proxy")
Expand Down

0 comments on commit 6cc1c52

Please sign in to comment.