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_proxy/https_proxy/octokit_proxy environment not used? #955

Open
BennX opened this issue Jul 2, 2019 · 6 comments

Comments

@BennX
Copy link

commented Jul 2, 2019

Bug Report

So i just deployed a probot stale in a Cloud Foundry and added the environment as needed for probot:

{
    "APP_ID": "Iv1.id",
    "GHE_HOST": "githubenterprise.mycompany",
    "LOGGING_LEVEL": "trace",
    "NEW_RELIC_ENABLED": "false",
    "NODE_ENV": "production",
    "PRIVATE_KEY": "privkey",
    "WEBHOOK_SECRET": "secret",
    "HTTP_PROXY": "http://proxy:8080",
    "HTTPS_PROXY": "https://proxy:8080",
    "OCTOKIT_PROXY": "http://proxy:8080"
}

I'm simply starting it with the command npm config set https-proxy http://proxy:8080 && npm config set http-proxy http://proxy:8080 && npm start and `128mb of RAM after uploading the project to the cloud foundry.

The bot is starting properly with little warnings and then runs into a connection timeout since it isn't using the proxy.

[CELL/0] [OUT] Starting health monitoring of container
[APP/PROC/WEB/0] [OUT] > probot-stale@1.1.0 start /home/vcap/app
[APP/PROC/WEB/0] [OUT] > probot run ./index.js
[APP/PROC/WEB/0] [ERR] [before-after-hook]: "Hook()" repurposing warning, use "Hook.Collection()". Read more: https://git.io/upgrade-before-after-hook-to-1.4
[APP/PROC/WEB/0] [OUT] 08:03:12.993Z INFO probot: Listening on http://localhost:8080
[APP/PROC/WEB/0] [ERR] DEPRECATED (@octokit/rest): `apps.getInstallations()` is deprecated, use `apps.listInstallations()`
[CELL/0] [OUT] Container became healthy
[CELL/0] [OUT] Cell c3bcd636-0dc6-425a-a191-fbe0092c685f destroying container for instance 5d8de719-7cf7-47d0-607a-2e39
[CELL/0] [OUT] Cell c3bcd636-0dc6-425a-a191-fbe0092c685f successfully destroyed container for instance 5d8de719-7cf7-47d0-607a-2e39
[APP/PROC/WEB/0] [OUT] 08:05:22.329Z ERROR probot: request to https://githubetnerprise.mycompany/api/v3/app/installations?per_page=100 failed, reason: connect ETIMEDOUT xxx:443
[APP/PROC/WEB/0] [OUT] HttpError: request to https://githubetnerprise.mycompany/api/v3/app/installations?per_page=100 failed, reason: connect ETIMEDOUT xxx:443
[APP/PROC/WEB/0] [OUT] at fetch.then.then.catch.error (/home/vcap/app/node_modules/@octokit/rest/lib/request/request.js:105:13)
[APP/PROC/WEB/0] [OUT] at <anonymous>
[APP/PROC/WEB/0] [OUT] at process._tickDomainCallback (internal/process/next_tick.js:229:7)
[APP/PROC/WEB/0] [OUT] 08:05:22.330Z ERROR probot: request to https://githubetnerprise.mycompany/api/v3/app/installations?per_page=100 failed, reason: connect ETIMEDOUT 194.127.88.183:443
[APP/PROC/WEB/0] [OUT] HttpError: request to https://githubetnerprise.mycompany/api/v3/app/installations?per_page=100 failed, reason: connect ETIMEDOUT xxx:443
[APP/PROC/WEB/0] [OUT] at fetch.then.then.catch.error (/home/vcap/app/node_modules/@octokit/rest/lib/request/request.js:105:13)
[APP/PROC/WEB/0] [OUT] at <anonymous>
[APP/PROC/WEB/0] [OUT] at process._tickDomainCallback (internal/process/next_tick.js:229:7)

Since i have at least one other application which is using the github enterprise api with the same route and the proxy, i'm confident that the underlaying http of probot is not picking the proxy of the environment.

How do i properly setup the proxy so that probot is using it to connect to github enterprise?
It looks like Probot is not using the Octokit proxy option and Octokit itself is not picking up OCTOKIT_PROXY. Can we add it in addition?

@issue-label-bot issue-label-bot bot added the bug 🐞 label Jul 2, 2019

@welcome

This comment has been minimized.

Copy link

commented Jul 2, 2019

Thanks for opening this issue. A contributor should be by to give feedback soon. In the meantime, please check out the contributing guidelines and explore other ways you can get involved.

@issue-label-bot

This comment has been minimized.

Copy link

commented Jul 2, 2019

Issue-Label Bot is automatically applying the label bug 🐞 to this issue, with a confidence of 0.85. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

@BennX

This comment has been minimized.

Copy link
Author

commented Aug 21, 2019

Any news or information how to inject a proxy into the probot?

@gr2m

This comment has been minimized.

Copy link
Contributor

commented Aug 23, 2019

I don't think this is possible today by configuring an environment variable alone.

@octokit/rest accepts a request.agent option which is an http/https agent:

Here is a proxy test that showcases how it works:
https://github.com/octokit/rest.js/blob/6b4a5d77d8f960fa727c65f2e91a01f38b3aa3fc/test/integration/agent-proxy/agent-proxy-test.js#L44

There is a workaround where you can pass your own Octokit instance to Probot, but we could also implement a new environment variable.

This would require

  • A test
  • Documentation update
  • Implementation update

You can look through the code to find where we initialize the @octokit/rest constructor, that's where the option would be passed in. But I think you can start with a pull request that includes the documentation update and the new test, and we take it from there?

GitHub
GitHub REST API client for JavaScript. Contribute to octokit/rest.js development by creating an account on GitHub.
@BennX

This comment has been minimized.

Copy link
Author

commented Aug 24, 2019

I've tried if i can globaly overload the agent with a proxy agent (http.globalAgent and https.globalAgent) which failed.

@gr2m Thank you for your reply. I'd really appreciate that since it would enable it for all bots build with probot, as long as they update the probot dependency.

@gr2m

This comment has been minimized.

Copy link
Contributor

commented Aug 26, 2019

I won't be able to implement this myself, but I can help you with a pull request if want to implement it yourself

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.