Skip to content

Commit

Permalink
chore(install): Check network ASAP, add err msgs
Browse files Browse the repository at this point in the history
chore(install): Log proxy config
  • Loading branch information
rthorn-nr committed Mar 22, 2023
1 parent 33e8e38 commit 5dfd621
Show file tree
Hide file tree
Showing 2 changed files with 19 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
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.")
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
}

0 comments on commit 5dfd621

Please sign in to comment.