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

When docker registry redirects to S3, "got" doesn't clear the port in the redirect #4593

Closed
fullstackzach opened this issue Oct 6, 2019 · 3 comments · Fixed by #4733
Closed
Assignees

Comments

@fullstackzach
Copy link
Contributor

fullstackzach commented Oct 6, 2019

What Renovate type are you using?
Self-hosted Gitlab

Describe the bug
While developing in renovate locally I found that our private docker registry redirects to Amazon S3 to download blobs. Our private registry private-registry.com:5000 is using the 5000 port and then tries to redirect to S3. I noticed that got tries to use the same port when making a request to the redirected url. But, the S3 resource doesn't use port 5000 and the request times out.

This looks like an issue already identified in got and is planned to be fixed in v10.
sindresorhus/got#719

Following the suggestion there, adding delete options.port; to this got beforeRedirect hook fixes the issue for me, and I'm thinking of opening a PR to add it. Thoughts?

Did you see anything helpful in debug logs?

Notice: The "port": "5000" gotOption below

DEBUG: Timeout awaiting 'request' for 60000ms (repository=user/repo)
       "err": {
         "name": "TimeoutError",
         "code": "ETIMEDOUT",
         "host": "private-registry.com:5000",
         "hostname": "<<redacted>>.s3.amazonaws.com",
         "method": "GET",
         "path": "<<redacted>>",
         "protocol": "https:",
         "url": "https://<<redacted>>.s3.amazonaws.com/<<redacted>>",
         "gotOptions": {
           "path": "<<redacted>>",
           "protocol": "https:",
           "slashes": true,
           "auth": null,
           "host": "private-registry.com:5000",
           "port": "5000",   <<< This is what I noticed
           "hostname": "<<redacted>>.s3.amazonaws.com",
           "hash": "",
           "search": "<<redacted>>",
           "query": null,
           "pathname": "<<redacted>>",
           "href": "https://<<redacted>>.s3.amazonaws.com/<<redacted>>",
           "headers": {
             "user-agent": "https://github.com/renovatebot/renovate",
             "accept-encoding": "gzip, deflate"
           },
           "hooks": {
             "beforeError": [],
             "init": [],
             "beforeRequest": [],
             "beforeRedirect": [null],
             "beforeRetry": [],
             "afterResponse": []
           },
           "retry": {"methods": {}, "statusCodes": {}, "errorCodes": {}},
           "decompress": true,
           "throwHttpErrors": true,
           "followRedirect": true,
           "stream": false,
           "form": false,
           "json": false,
           "cache": false,
           "useElectronNet": false,
           "method": "GET",
           "gotTimeout": {"request": 60000}
         },
         "event": "request",
         "message": "Timeout awaiting 'request' for 60000ms",
         "stack": "TimeoutError: Timeout awaiting 'request' for 60000ms\n    at ClientRequest.request.once.error (/Users/user/oss/renovate/node_modules/got/source/request-as-event-emitter.js:176:14)\n    at Object.onceWrapper (events.js:273:13)\n    at ClientRequest.emit (events.js:187:15)\n    at ClientRequest.EventEmitter.emit (domain.js:441:20)\n    at ClientRequest.origin.emit.args (/Users/user/oss/renovate/node_modules/@szmarczak/http-timer/source/index.js:37:11)\n    at Immediate.timeoutHandler (/Users/user/oss/renovate/node_modules/got/source/utils/timed-out.js:63:11)\n    at runCallback (timers.js:706:11)\n    at tryOnImmediate (timers.js:676:5)\n    at processImmediate (timers.js:658:5)\n    at process.topLevelDomainCallback (domain.js:120:23)"
       }```


**To Reproduce**
Steps to reproduce the behavior:

Renovate a dockerfile using a private registry having a port, but is backed by AWS S3.

**Expected behavior**
It should resolve the S3 resource and not encounter a timeout.
@fullstackzach fullstackzach changed the title When docker registry redirects to S3, it doesn't clear the port in the redirect When docker registry redirects to S3, "got" doesn't clear the port in the redirect Oct 6, 2019
@rarkins
Copy link
Collaborator

rarkins commented Oct 6, 2019

I would like to check that the beforeRedirect hook doesn't break anything scenarios first. e.g. does it work to go from 80 -> 5000, 5000 -> 5000, and 5000 -> 80? If all three of those work, I'm ok with this workaround as a PR until we adopt got v10.

@fullstackzach
Copy link
Contributor Author

Just commenting to mention I haven't forgotten this issue and I'm still interested in it. I'll be working on it soon

@renovate-release
Copy link
Collaborator

🎉 This issue has been resolved in version 19.66.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants