Global HTTP proxy does not work in bootdisk

Problem:
Creating a boot disk for a debian System fails. The CLI Interface (and also the Webfrontend) respond
Failed to download host disk image:
Failed to open TCP connection to ftp.de.debian.org:80 (No route to host - connect(2) for "ftp.de.debian.org" port 80)

Expected outcome:

Create a boot image

Foreman and Proxy versions:
1.22

Foreman and Proxy plugin versions:
bootdisk: 15.0.0

Other relevant data:

logs

I set the Proxy under Administer->Settings->General->HTTP Proxy to http://proxyadress:port
Had no effect. When trying it from commandline i set http_proxy and https_proxy to http://proxyadress:port
Trying wget works fine, i can see the request in the squid log now.
When i try to create a boot disk with
hammer bootdisk host --host deb-test2.domain.de --full true
It tells me
Failed to download host disk image:
Failed to open TCP connection to ftp.de.debian.org:80 (No route to host - connect(2) for “ftp.de.debian.org” port 80)

and i can’t see a request in the squid log. Any idea?

I see that we have a HTTP Net Ruby extension which reads proxy from Administer - Settings and should transparently work:

Any ideas why this would not work with bootdisk code:

It should work. @core

To me it looks like it does not try to use the proxy:

from the log:

2019-06-17T06:55:23 [I|app|bb21360b] Started GET “/api/hosts?search=name+%3D+%22deb-test2.domain.de%22” for 10.0.0.24 at 2019-06-17 06:55:23 +0200
2019-06-17T06:55:23 [I|app|bb21360b] Processing by Api::V2::HostsController#index as JSON
2019-06-17T06:55:23 [I|app|bb21360b] Parameters: {“search”=>“name = “deb-test2.domain.de””, “apiv”=>“v2”, “host”=>{}}
2019-06-17T06:55:24 [I|app|bb21360b] Authorized user admin(Admin User)
2019-06-17T06:55:24 [I|app|bb21360b] Current user set to admin (admin)
2019-06-17T06:55:24 [I|app|bb21360b] Rendering api/v2/hosts/index.json.rabl within api/v2/layouts/index_layout
2019-06-17T06:55:24 [I|app|bb21360b] Rendered api/v2/hosts/index.json.rabl within api/v2/layouts/index_layout (161.5ms)
2019-06-17T06:55:24 [I|app|bb21360b] Completed 200 OK in 441ms (Views: 152.9ms | ActiveRecord: 78.3ms)
2019-06-17T06:55:24 [I|app|d5371800] Started GET “/bootdisk/api/hosts/5?full=true” for 10.0.0.24 at 2019-06-17 06:55:24 +0200
2019-06-17T06:55:24 [I|app|d5371800] Processing by ForemanBootdisk::Api::V2::DisksController#host as JSON
2019-06-17T06:55:24 [I|app|d5371800] Parameters: {“full”=>“true”, “apiv”=>“v2”, “id”=>“5”, “disk”=>{}}
2019-06-17T06:55:24 [I|app|d5371800] Authorized user admin(Admin User)
2019-06-17T06:55:24 [I|app|d5371800] Current user set to admin (admin)
2019-06-17T06:55:24 [I|for|d5371800] Fetching http://ftp.de.debian.org/debian/dists/stretch/main/installer-amd64/current/images/netboot/debian-insta
ller/amd64/linux
2019-06-17T06:55:24 [W|app|d5371800] Action failed
Errno::EHOSTUNREACH: Failed to open TCP connection to ftp.de.debian.org:80 (No route to host - connect(2) for “ftp.de.debian.org” port 80)
/usr/lib/ruby/2.3.0/net/http.rb:882:in rescue in block in connect' /usr/lib/ruby/2.3.0/net/http.rb:879:inblock in connect’
/usr/lib/ruby/2.3.0/timeout.rb:91:in block in timeout' /usr/lib/ruby/2.3.0/timeout.rb:101:intimeout’
/usr/lib/ruby/2.3.0/net/http.rb:878:in connect' /usr/lib/ruby/2.3.0/net/http.rb:863:indo_start’
/usr/lib/ruby/2.3.0/net/http.rb:852:in start' /usr/lib/ruby/2.3.0/net/http.rb:584:instart’
/usr/share/foreman/vendor/ruby/2.3.0/gems/foreman_bootdisk-15.0.0/app/services/foreman_bootdisk/iso_generator.rb:140:in block in fetch' /usr/share/foreman/vendor/ruby/2.3.0/gems/foreman_bootdisk-15.0.0/app/services/foreman_bootdisk/iso_generator.rb:130:inopen’
/usr/share/foreman/vendor/ruby/2.3.0/gems/foreman_bootdisk-15.0.0/app/services/foreman_bootdisk/iso_generator.rb:130:in fetch' /usr/share/foreman/vendor/ruby/2.3.0/gems/foreman_bootdisk-15.0.0/app/services/foreman_bootdisk/iso_generator.rb:85:inblock (2 levels) in generate

Looks like this is a bug and not only in bootdisk but everywhere in Foreman where we use Net::HTTP. Filed it:

https://projects.theforeman.org/issues/27065

I don’t have an easy workaround, looking at @bastilian maybe he has an idea for a quick fix.

I created a PR, which will fix this locally: https://github.com/theforeman/foreman_bootdisk/pull/96

I’d prefer a generic solution within foreman, but the only one I can think of is to set the http_proxy and https_proxy environment variables for the foreman process.

1 Like