Skip to content

Commit

Permalink
chore(install): Check network ASAP, add err msgs
Browse files Browse the repository at this point in the history
  • Loading branch information
rthorn-nr committed Mar 22, 2023
1 parent 33e8e38 commit 6dbda89
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
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
15 changes: 10 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,24 @@ 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.")
log.Warn("You may need to adjust your proxy environment variables or configure your proxy to allow the specified domain.")
} 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 network issues: https://docs.newrelic.com/docs/new-relic-solutions/get-started/networks/")
log.Warn("More information about proxy configuration: https://github.com/newrelic/newrelic-cli/blob/main/docs/GETTING_STARTED.md#using-an-http-proxy")

log.Error(err)
}

return err
}

0 comments on commit 6dbda89

Please sign in to comment.