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

[http_check] add support for no_proxy environment variable #2448

Merged
merged 1 commit into from
May 12, 2016

Conversation

truthbk
Copy link
Member

@truthbk truthbk commented Apr 26, 2016

Why this PR?

If a no_proxy environment variable is set we should honor it when making requests. This PR addresses the issue by adding the environment variable to the proxies dict used by requests to make the request.

Questions

  • Should we allow overriding of no_proxy in the yaml configuration file?
  • Should we "inherit" http and https system-wide environment variables as well if they're not set in the configuration file?

Answers

  • I have allowed to override any proxy settings with a per instance no_proxy flag.
  • If no datadog.conf proxy is enabled, but environment variables are found for https or http proxies, these will be enforced.

Notes

Unfortunately this is now a little more convoluted then I would've liked. Passing the self.proxies dict with http and/or https and a no_proxy key (or no key requests also takes) will not work, only after popping the relevant entries off the dictionary did I see the expected behavior. This has forced us to enforce the proxy settings explicitly per iteration.

@olivielpeau olivielpeau modified the milestones: 5.9.0, 5.8.0 Apr 29, 2016
@truthbk truthbk force-pushed the jaime/http_proxy branch from a82e0aa to 4964d66 Compare May 4, 2016 21:31
@gmmeyer gmmeyer self-assigned this May 9, 2016
self.proxies['https'] = "https://{uri}".format(uri=uri)
else:
self.proxies['http'] = environ.get('http', None)
self.proxies['https'] = environ.get('https', None)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why http and https as the environment variables? Those seem very prone to unintended overlap.

(The requests library uses HTTP_PROXY and HTTPS_PROXY.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! That was my bad, indeed the env variables on *nix systems have _PROXY appended. Fixing!

…o requests.

[http] allow overriding of no_proxy if set in init_config, otherwise grab from env.

[http_check] 'proxies' looks like it should have http, https, and no keys.

[http] requests not enforcing no_proxy - attempting to disable.

[http] respect environment variables if defined

[http] adding per instance no_proxy feature flag.
@truthbk truthbk force-pushed the jaime/http_proxy branch from 4964d66 to 4f7d382 Compare May 9, 2016 16:20
@gmmeyer
Copy link
Contributor

gmmeyer commented May 9, 2016

I think the apache failure is unrelated, if you're more concerned about it, rerun it.

So, it looks good to me. 👍

@truthbk truthbk merged commit 8a3e77c into master May 12, 2016
@truthbk truthbk deleted the jaime/http_proxy branch May 12, 2016 21:56
@yannmh yannmh modified the milestones: 5.8.0, 5.9.0 May 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants