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

skopeo not inheriting outgoing proxy configuration #1509

Closed
antifob opened this issue Dec 13, 2024 · 6 comments · Fixed by #1525
Closed

skopeo not inheriting outgoing proxy configuration #1509

antifob opened this issue Dec 13, 2024 · 6 comments · Fixed by #1525
Assignees
Labels
Easy Good for new contributors
Milestone

Comments

@antifob
Copy link

antifob commented Dec 13, 2024

Required information

  • Distribution: Debian
  • Distribution version: bookworm
  • The output of "incus info" or if that fails:
    • Kernel version:
    • LXC version:
    • Incus version: 6.8
    • Storage backend in use:

Issue description

skopeo does not inherit the outgoing proxy settings of core.proxy_http and core.proxy_https.
In some configurations, this results in an Image not found error due to skopeo not being able to reach the Internet.

Steps to reproduce

The below demonstrate that skopeo does not contact the configured proxy server.

# listen on a tcp port
nc -lnvp 1080

# point incusd to the "proxy"
incus config set core.proxy_https=http://127.0.0.1:1080

incus remote add docker https://docker.io --protocol=oci
incus launch --console docker:hello-world --ephemeral

# expected: the proxy/netcat is poked by incusd

Information to attach

Underlying error as seen from incus monitor.

metadata:
  context:
    name: hello-world
    stderr: 'Failed to run: skopeo inspect docker://docker.io/hello-world: exit status
      1 (time="2024-12-13T14:23:16Z" level=fatal msg="Error parsing image name \"docker://docker.io/hello-world\":
      pinging container registry registry-1.docker.io: Get \"https://registry-1.docker.io/v2/\":
      dial tcp: lookup registry-1.docker.io on 9.9.9.9:53: dial udp 9.9.9.9:53: connect:
      network is unreachable")'
    stdout: ""
  level: debug
  message: Error getting image alias

Workaround

For the Zabbly-provided package...

cat>>/etc/default/incus<<__EOF__
http_proxy=http://proxyhost:port
https_proxy=http://proxyhost:port
__EOF__
systemctl restart incus.service
@antifob antifob changed the title skopeo not inheriting proxy configuration skopeo not inheriting outgoing proxy configuration Dec 13, 2024
@stgraber stgraber added Bug Easy Good for new contributors labels Dec 14, 2024
@stgraber stgraber added this to the incus-6.9 milestone Dec 14, 2024
@winiciusallan
Copy link
Contributor

winiciusallan commented Dec 16, 2024

Should we override the HTTPS_PROXY environment variable if core.proxy_http or core.proxy_https exists? Something like HTTPS_PROXY skopeo inspect ...

here

stdout, err := subprocess.RunCommand("skopeo", "inspect", fmt.Sprintf("%s/%s", strings.Replace(r.httpHost, "https://", "docker://", -1), name))

I tested it in my environment

$ nc -lnvp 1080

$ HTTPS_PROXY=http://127.0.0.1:1080 skopeo inspect docker://docker.io/hello-world

# netcat received the connection
$ nc -lnvp 1080
Listening on 0.0.0.0 1080
Connection received on 127.0.0.1 47912
CONNECT registry-1.docker.io:443 HTTP/1.1
Host: registry-1.docker.io:443
User-Agent: Go-http-client/1.1

@stgraber
Copy link
Member

We already pass proxy information from the server config to the client logic.

So from within oci_images.go, we should be able to get the proxy by calling r.http.Transport.(*http.Transport).Proxy with a fake http.Request roughly matching what we want to access (scheme and host must be correct at least).

@winiciusallan
Copy link
Contributor

Hi @stgraber. Could you assign this issue to me? I was doing some tests, and I made certain progress. Thanks!

@winiciusallan
Copy link
Contributor

Now, I'm able to get the proxy with what you said.

req, err := http.NewRequest("GET", r.httpHost, nil)
proxy, err := r.http.Transport.(*http.Transport).Proxy(req)

So, do I need to pass it to the skopeo command as I suggested in the previous comment or set it to ProtocolOCI.http?

@stgraber
Copy link
Member

Right, you'd want to use subprocess.RunCommandSplit instead so you can pass it the environment.

winiciusallan added a commit to winiciusallan/incus that referenced this issue Dec 17, 2024
The proxy host address was not inherit to skopoe and as a consequence, it is
not possible to connect to proxy to inspect OCI image.

Closes: lxc#1509

Signed-off-by: Winicius Silva <winiciusab12@gmail.com>
@winiciusallan
Copy link
Contributor

Hi @stgraber, I tested the changes that I made. Now, it is possible to connect to the proxy, but with the example of the issue, the image can not be inspected, even if the netcat connects to the docker registry. I don't know if it is a firewall issue in my VM or another thing. If you could give me some feedback, I'd appreciate it.

MadnessASAP pushed a commit to MadnessASAP/incus that referenced this issue Dec 18, 2024
The proxy host address was not passed to skopoe and as a consequence, it is
not possible to connect to proxy to inspect OCI image.

Closes: lxc#1509

Signed-off-by: Winicius Silva <winiciusab12@gmail.com>
bketelsen pushed a commit to bketelsen/incus that referenced this issue Feb 4, 2025
The proxy host address was not passed to skopoe and as a consequence, it is
not possible to connect to proxy to inspect OCI image.

Closes: lxc#1509

Signed-off-by: Winicius Silva <winiciusab12@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Easy Good for new contributors
Development

Successfully merging a pull request may close this issue.

3 participants