Skip to content
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

fix: Updated fall back error message #1622

Merged
merged 1 commit into from
Jun 27, 2024
Merged
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
2 changes: 1 addition & 1 deletion internal/install/execution/recipe_log_forwarder.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (lf *RecipeLogForwarder) SendLogsToNewRelic(recipeName string, data []strin
func (lf *RecipeLogForwarder) buildLogEntryBatch(recipeName string, data []string) {
now := time.Now().UnixMilli()
for _, line := range data {
now++ //using timestamp to retain log sequence
now++ // using timestamp to retain log sequence
lf.LogEntries = append(lf.LogEntries, LogEntry{map[string]interface{}{"nr-install-recipe": recipeName, "timestamp": now}, "cli-output", line})
}
}
Expand Down
22 changes: 22 additions & 0 deletions internal/install/recipe_installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"github.com/fatih/color"
"os"
"regexp"
"strconv"
Expand Down Expand Up @@ -582,6 +583,9 @@ func (i *RecipeInstall) executeAndValidate(ctx context.Context, m *types.Discove
// opts in/out of sending cli logs, and this must occur before we build the RecipeStatusEvent to post to NR
msg := fmt.Sprintf("execution failed for %s: %s", r.Name, err)
i.optInToSendLogsAndUpdateRecipeMetadata(r.Name)
// FIX: This should rerun the executed command
i.askToReRunInDebugMode()

se := execution.RecipeStatusEvent{
Recipe: *r,
Msg: msg,
Expand Down Expand Up @@ -665,6 +669,24 @@ func (i *RecipeInstall) optInToSendLogsAndUpdateRecipeMetadata(recipeName string
}
}

func (i *RecipeInstall) askToReRunInDebugMode() {
recipeOutput := i.recipeExecutor.GetRecipeOutput()
logCaptureEnabledForRecipe := i.recipeExecutor.GetOutput().IsCapturedCliOutput()
if len(recipeOutput) > 0 && logCaptureEnabledForRecipe {
i.promptUserToReRun()
}
}

func (i *RecipeInstall) promptUserToReRun() {
fmt.Printf("\n%s Installation failed. To help identify the issue, you can re-run the installation command with the --debug flag. This will enable verbose logging and provide more detailed information about each step of the installation process. Use the command newrelic install --debug to start the installation with debug mode enabled.", color.YellowString("\u0021"))

// NOTE: This is only after Infra is installed on the host. If no infra agent is present then root/.newrelic wouldn't be created
if i.processEvaluator.FindProcess(types.InfraAgentProcessName) {
fmt.Printf("\n%s For viewing the logs, please navigate to /root/.newrelic/newrelic-cli.log. ", color.YellowString("\u0021"))
}

}

type validationFunc func() (string, error)

// Post install validation
Expand Down
1 change: 1 addition & 0 deletions internal/install/types/recipe.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const (
GoldenRecipeName = "alerts-golden-signal"
SuperAgentRecipeName = "super-agent"
SuperAgentProcessName = "newrelic-super-agent"
InfraAgentProcessName = "newrelic-infra"
)

var RecipeVariables = map[string]string{}
Expand Down
Loading