From 8258ff637e1e44ca521ff8f51416447f247c8ebb Mon Sep 17 00:00:00 2001 From: Ethan Mosbaugh Date: Fri, 27 Jun 2025 06:48:39 -0700 Subject: [PATCH] chore(api): more verbosity in logs --- api/controllers/linux/install/hostpreflight.go | 3 +++ api/controllers/linux/install/infra.go | 4 +++- api/controllers/linux/install/installation.go | 12 +++++++++++- api/internal/managers/infra/install.go | 4 ++-- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/api/controllers/linux/install/hostpreflight.go b/api/controllers/linux/install/hostpreflight.go index 33f7eb741..2460f96c2 100644 --- a/api/controllers/linux/install/hostpreflight.go +++ b/api/controllers/linux/install/hostpreflight.go @@ -21,6 +21,7 @@ func (c *InstallController) RunHostPreflights(ctx context.Context, opts RunHostP defer func() { if r := recover(); r != nil { finalErr = fmt.Errorf("panic: %v: %s", r, string(debug.Stack())) + c.logger.Error(finalErr) } if finalErr != nil { lock.Release() @@ -70,6 +71,8 @@ func (c *InstallController) RunHostPreflights(ctx context.Context, opts RunHostP c.logger.Errorf("failed to transition states: %w", err) } return + } else { + c.logger.Infof("host preflights completed") } // Get the state from the preflights output diff --git a/api/controllers/linux/install/infra.go b/api/controllers/linux/install/infra.go index cf7adeb2f..537224c28 100644 --- a/api/controllers/linux/install/infra.go +++ b/api/controllers/linux/install/infra.go @@ -52,7 +52,7 @@ func (c *InstallController) SetupInfra(ctx context.Context, ignoreHostPreflights defer func() { if r := recover(); r != nil { - finalErr = fmt.Errorf("panic: %v: %s", r, string(debug.Stack())) + finalErr = fmt.Errorf("panic installing infrastructure: %v: %s", r, string(debug.Stack())) } if finalErr != nil { c.logger.Error(finalErr) @@ -61,6 +61,8 @@ func (c *InstallController) SetupInfra(ctx context.Context, ignoreHostPreflights c.logger.Errorf("failed to transition states: %w", err) } } else { + c.logger.Infof("infrastructure installed") + if err := c.stateMachine.Transition(lock, StateSucceeded); err != nil { c.logger.Errorf("failed to transition states: %w", err) } diff --git a/api/controllers/linux/install/installation.go b/api/controllers/linux/install/installation.go index 037e1665d..3241b16db 100644 --- a/api/controllers/linux/install/installation.go +++ b/api/controllers/linux/install/installation.go @@ -3,6 +3,7 @@ package install import ( "context" "fmt" + "runtime/debug" "time" "github.com/replicatedhq/embedded-cluster/api/types" @@ -54,6 +55,7 @@ func (c *InstallController) ConfigureInstallation(ctx context.Context, config ty c.logger.Error("failed to transition states", "error", err) } } else { + c.logger.Infof("host configured") err = c.stateMachine.Transition(lock, StateHostConfigured) if err != nil { c.logger.Error("failed to transition states", "error", err) @@ -64,7 +66,7 @@ func (c *InstallController) ConfigureInstallation(ctx context.Context, config ty return nil } -func (c *InstallController) configureInstallation(ctx context.Context, config types.InstallationConfig) (finalErr error) { +func (c *InstallController) configureInstallation(_ context.Context, config types.InstallationConfig) (finalErr error) { lock, err := c.stateMachine.AcquireLock() if err != nil { return types.NewConflictError(err) @@ -76,7 +78,13 @@ func (c *InstallController) configureInstallation(ctx context.Context, config ty } defer func() { + if r := recover(); r != nil { + finalErr = fmt.Errorf("panic configuring installation: %v: %s", r, string(debug.Stack())) + } + if finalErr != nil { + c.logger.Error(finalErr) + failureStatus := types.Status{ State: types.StateFailed, Description: finalErr.Error(), @@ -90,6 +98,8 @@ func (c *InstallController) configureInstallation(ctx context.Context, config ty if err := c.stateMachine.Transition(lock, StateInstallationConfigurationFailed); err != nil { c.logger.Errorf("failed to transition states: %w", err) } + } else { + c.logger.Infof("installation configured") } }() diff --git a/api/internal/managers/infra/install.go b/api/internal/managers/infra/install.go index 17aae15e6..746e0f7e3 100644 --- a/api/internal/managers/infra/install.go +++ b/api/internal/managers/infra/install.go @@ -251,11 +251,11 @@ func (m *infraManager) installAddOns(ctx context.Context, kcli client.Client, mc go func() { for progress := range progressChan { // capture progress in debug logs - m.logger.WithFields(logrus.Fields{"addon": progress.Name, "state": progress.Status.State, "description": progress.Status.Description}).Debugf("addon progress") + m.logger.WithFields(logrus.Fields{"addon": progress.Name, "state": progress.Status.State, "description": progress.Status.Description}).Debug("addon progress") // if in progress, update the overall status to reflect the current component if progress.Status.State == types.StateRunning { - m.setStatusDesc(fmt.Sprintf("%s %s", progress.Status.Description, progress.Name)) + _ = m.setStatusDesc(fmt.Sprintf("%s %s", progress.Status.Description, progress.Name)) } // update the status for the current component