From 5ffebedd1facd9d62b7938888bf04cddd678e529 Mon Sep 17 00:00:00 2001 From: Tim Serong Date: Tue, 23 Jul 2024 20:09:56 +1000 Subject: [PATCH] Log validateConfig, PrepareWebooks and doInstall errors Prior to this commit, errors returned from the above functions would be printed to the console, but not logged. This meant that if you weren't able to access the console for whatever reason, but _could_ access the log file, you would have no idea what went wrong if one of those function calls failed. Related issue: https://github.com/harvester/harvester/issues/6214 Signed-off-by: Tim Serong --- pkg/console/install_panels.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pkg/console/install_panels.go b/pkg/console/install_panels.go index 1fdcc19af..7035daa10 100644 --- a/pkg/console/install_panels.go +++ b/pkg/console/install_panels.go @@ -2132,6 +2132,7 @@ func addInstallPanel(c *Console) error { for _, warning := range preflightWarnings { logrus.Warning(warning) } + logrus.Info("Installation will proceed (harvester.install.skipchecks = true)") } else { // Checks were not explicitly skipped, fail the install // (this will happen when PXE booted if checks fail and @@ -2166,13 +2167,17 @@ func addInstallPanel(c *Console) error { } if err := validateConfig(ConfigValidator{}, c.config); err != nil { - printToPanel(c.Gui, err.Error(), installPanel) + msg := fmt.Sprintf("Invalid configuration: %s", err) + logrus.Error(msg) + printToPanel(c.Gui, msg, installPanel) return } webhooks, err := PrepareWebhooks(c.config.Webhooks, getWebhookContext(c.config)) if err != nil { - printToPanel(c.Gui, fmt.Sprintf("invalid webhook: %s", err), installPanel) + msg := fmt.Sprintf("Invalid webhook: %s", err) + logrus.Error(msg) + printToPanel(c.Gui, msg, installPanel) } if alreadyInstalled { @@ -2181,7 +2186,9 @@ func addInstallPanel(c *Console) error { err = doInstall(c.Gui, c.config, webhooks) } if err != nil { - printToPanel(c.Gui, fmt.Sprintf("install failed: %s", err), installPanel) + msg := fmt.Sprintf("Install failed: %s", err) + logrus.Error(msg) + printToPanel(c.Gui, msg, installPanel) } }() return c.setContentByName(footerPanel, "")