From 6cc1c5240d1a9e4576a353a45ca3905541413e36 Mon Sep 17 00:00:00 2001 From: Shawn Bai Date: Thu, 8 Aug 2024 10:55:43 +1200 Subject: [PATCH] Enhance readability of healthcheck prompt messages 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 --- cmd/ocm-backplane/cloud/console.go | 9 ++++++--- cmd/ocm-backplane/login/login.go | 10 +++++----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/cmd/ocm-backplane/cloud/console.go b/cmd/ocm-backplane/cloud/console.go index 454bcf91..3aa210d7 100644 --- a/cmd/ocm-backplane/cloud/console.go +++ b/cmd/ocm-backplane/cloud/console.go @@ -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) } diff --git a/cmd/ocm-backplane/login/login.go b/cmd/ocm-backplane/login/login.go index ce9ef47c..298ffe0c 100644 --- a/cmd/ocm-backplane/login/login.go +++ b/cmd/ocm-backplane/login/login.go @@ -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")