Skip to content

Commit

Permalink
Log validateConfig, PrepareWebooks and doInstall errors
Browse files Browse the repository at this point in the history
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: harvester/harvester#6214

Signed-off-by: Tim Serong <[email protected]>
  • Loading branch information
tserong committed Jul 24, 2024
1 parent 36ea2bf commit 5ffebed
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions pkg/console/install_panels.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand All @@ -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, "")
Expand Down

0 comments on commit 5ffebed

Please sign in to comment.