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

chore(install): Improve network error detection and messaging #1438

Merged
merged 1 commit into from
Mar 22, 2023
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
5 changes: 5 additions & 0 deletions internal/install/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ var Command = &cobra.Command{
logLevel := configAPI.GetLogLevel()
config.InitFileLogger(logLevel)

if err := checkNetwork(client.NRClient); err != nil {
log.Fatal(err)
return nil
}

err := assertProfileIsValid()
if err != nil {
log.Fatal(err)
Expand Down
19 changes: 14 additions & 5 deletions internal/install/recipe_installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ type RecipeInstall struct {
type RecipeInstallFunc func(ctx context.Context, i *RecipeInstall, m *types.DiscoveryManifest, r *types.OpenInstallationRecipe, recipes []types.OpenInstallationRecipe) error

func NewRecipeInstaller(ic types.InstallerContext, nrClient *newrelic.NewRelic) *RecipeInstall {
checkNetwork(nrClient)

var recipeFetcher recipes.RecipeFetcher

if ic.LocalRecipes != "" {
Expand Down Expand Up @@ -718,17 +716,28 @@ func (i *RecipeInstall) finishHandlingFailure(recipeName string) {
}
}

func checkNetwork(nrClient *newrelic.NewRelic) {
func checkNetwork(nrClient *newrelic.NewRelic) error {
err := nrClient.TestEndpoints()
if err != nil {

proxyConfig := httpproxy.FromEnvironment()

log.Debugf("proxyConfig: %+v", proxyConfig)
if proxyConfig.HTTPProxy != "" || proxyConfig.HTTPSProxy != "" || proxyConfig.NoProxy != "" {
log.Warn("Proxy settings have been configured but we are still unable to connect to the New Relic platform. You may need to adjust your proxy environment variables. https://github.com/newrelic/newrelic-cli/blob/main/docs/GETTING_STARTED.md#using-an-http-proxy")
log.Warn("Proxy settings have been configured, but we are still unable to connect to the New Relic platform.")
rthorn-nr marked this conversation as resolved.
Show resolved Hide resolved
log.Warn("You may need to adjust your proxy environment variables or configure your proxy to allow the specified domain.")
log.Warn("Current proxy config:")
log.Warnf(" HTTPS_PROXY=%s", proxyConfig.HTTPSProxy)
log.Warnf(" HTTP_PROXY=%s", proxyConfig.HTTPProxy)
log.Warnf(" NO_PROXY=%s", proxyConfig.NoProxy)
} else {
log.Warn("Failed to connect to the New Relic platform.")
log.Warn("If you need to use a proxy, consider setting the HTTPS_PROXY environment variable, then try again.")
}
log.Warn("More information about proxy configuration: https://github.com/newrelic/newrelic-cli/blob/main/docs/GETTING_STARTED.md#using-an-http-proxy")
log.Warn("More information about network requirements: https://docs.newrelic.com/docs/new-relic-solutions/get-started/networks/")

log.Error(err)
}

return err
}