Skip to content

chore(api): more verbosity in logs #2382

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions api/controllers/linux/install/hostpreflight.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion api/controllers/linux/install/infra.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
}
Expand Down
12 changes: 11 additions & 1 deletion api/controllers/linux/install/installation.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package install
import (
"context"
"fmt"
"runtime/debug"
"time"

"github.com/replicatedhq/embedded-cluster/api/types"
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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(),
Expand All @@ -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")
}
}()

Expand Down
4 changes: 2 additions & 2 deletions api/internal/managers/infra/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading