Skip to content

Commit b38179c

Browse files
authoredAug 30, 2024··
Merge pull request #498 from xiaoyu74/healthcheck_logging_enhancement
[OSD-25177] Enhance readability of healthcheck prompt messages
2 parents 1491234 + 6cc1c52 commit b38179c

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed
 

‎cmd/ocm-backplane/cloud/console.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,17 @@ func runConsole(cmd *cobra.Command, argv []string) (err error) {
140140

141141
// ======== Get cloud console from backplane API ============
142142
consoleResponse, err := queryConfig.GetCloudConsole()
143+
144+
// Declare helperMsg
145+
helperMsg := "\n\033[1mNOTE: To troubleshoot the connectivity issues, please run `ocm-backplane health-check`\033[0m\n\n"
146+
143147
if err != nil {
144148
// Check API connection with configured proxy
145149
if connErr := backplaneConfiguration.CheckAPIConnection(); connErr != nil {
146150
logger.Error("Cannot connect to backplane API URL, check if you need to use a proxy/VPN to access backplane:")
147-
logger.Errorf("Error: %v", connErr)
148-
logger.Info("To troubleshoot connectivity issues, please run the following command:")
149-
logger.Info("ocm-backplane health-check")
151+
logger.Errorf("Error: %v.\n%s", connErr, helperMsg)
150152
}
153+
151154
return fmt.Errorf("failed to get cloud console for cluster %v: %w", clusterID, err)
152155
}
153156

‎cmd/ocm-backplane/login/login.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -306,15 +306,15 @@ func runLogin(cmd *cobra.Command, argv []string) (err error) {
306306
return fmt.Errorf("cluster %s is hibernating, login failed", clusterKey)
307307
}
308308

309+
// Declare helperMsg
310+
helperMsg := "\n\033[1mNOTE: To troubleshoot the connectivity issues, please run `ocm-backplane health-check`\033[0m\n\n"
311+
309312
// Check API connection with configured proxy
310313
if connErr := bpConfig.CheckAPIConnection(); connErr != nil {
311-
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)
312-
return fmt.Errorf("cannot connect to backplane API URL: %v", connErr)
314+
return fmt.Errorf("cannot connect to Backplane API URL: %v.\n%s", connErr, helperMsg)
313315
}
314316

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

320320
logger.WithField("URL", bpAPIClusterURL).Debugln("Proxy")

0 commit comments

Comments
 (0)
Please sign in to comment.