Project

General

Profile

Bug #7811

Importing a template from a simple web server does not work as expected

Added by Cyril Peponnet over 5 years ago. Updated about 3 years ago.

Status:
Closed: Not To Be Fixed
Priority:
Nice to have
Assignee:
John Hixson
Category:
Middleware
Target version:
Seen in:
Severity:
New
Reason for Closing:
Reason for Blocked:
Needs QA:
Yes
Needs Doc:
Yes
Needs Merging:
Yes
Needs Automation:
No
Support Suite Ticket:
n/a
Hardware Configuration:
ChangeLog Required:
No

Description

Hi,

I have base.tgz (tar gz from an existing jail in order to create a template).

I try to import it from the UI.

I use python -m SimpleHTTPServer in order to create a tiny temporary http server providing my image.

The UI stuck when importing

Under the hood, if I try to use from freenas host:

extract-tarball -u http://10.0.0.10/bsd-template-custom.tgz -d /mnt/test/jails/templates/

This stuck too.

Attaching a truss on it give this output:

read(4,0x7fffffffe06f,1)             ERR#35 'Resource temporarily unavailable'

I made a test with the freenas-virtualbox tar ball provided by this simplehttpserver, same issue.

I also try to improve the server as follow:

#!/usr/bin/env python
import SimpleHTTPServer

class MyHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
    def do_GET(self):
    self.protocol_version="HTTP/1.1" 
    SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)

    def end_headers(self):
        self.send_my_headers()
        SimpleHTTPServer.SimpleHTTPRequestHandler.end_headers(self)

    def send_my_headers(self):
        self.send_header("Accept-Ranges", "bytes")
    self.send_header("Keep-Alive", "timeout=5, max=100")
    self.send_header("Connection", "Keep-Alive")

if __name__ == '__main__':
    m = SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map
    m[".tgz"]="application/x-gzip" 
    SimpleHTTPServer.test(HandlerClass=MyHTTPRequestHandler)

Same issue.

if I use curl or fetch to grab the image from my http server it work's fine from freenas host.

History

#1 Updated by Jordan Hubbard over 5 years ago

  • Status changed from Unscreened to Investigation

BRB: John will investigate.

#2 Updated by John Hixson over 5 years ago

  • Target version set to Unspecified

#3 Updated by John Hixson over 5 years ago

  • Status changed from Investigation to 15

Are you placing the template on an actual server? Or just using the simple python server? I can reproduce your issue using the python code, but putting a template on an apache or nginx server I am unable to reproduce the issue. If it's just the python code, I do not consider this a bug as it is not full featured.

#4 Updated by Cyril Peponnet over 5 years ago

nginx or apache works fine. Only python SimpleHTTPServer fail.

This simple server is really handy when you don't have nginx/apache reachable from the NAS.

I'm fine with the not full featured (but could be great to handle this as it works when using fetch/curl).

#5 Updated by John Hixson over 5 years ago

Cyril Peponnet wrote:

nginx or apache works fine. Only python SimpleHTTPServer fail.

This simple server is really handy when you don't have nginx/apache reachable from the NAS.

I'm fine with the not full featured (but could be great to handle this as it works when using fetch/curl).

Against my better judgement, I actually spent time digging into this ;-). In the extract-tarball program, things hang at the fetchStatURL() function. This function in turn is doing a HEAD request against the web server. After analyzing packet captures and digging through libfetch code, what happens is pythons SimpleHTTPServer sends an extra line feed and carriage return, which libfetch is not expecting. It's silly, but you can verify this using telnet and issuing a HEAD request.

#6 Updated by John Hixson over 5 years ago

  • Status changed from 15 to Closed: Not To Be Fixed

#7 Updated by Cyril Peponnet over 5 years ago

I made a change in my improved simple server but it still failling despite there is no new line/cr.

#!/usr/bin/env python
import SimpleHTTPServer

class MyHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
    def do_GET(self):
    self.protocol_version="HTTP/1.1" 
    SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)

    def end_headers(self):
        self.send_my_headers()
        #SimpleHTTPServer.SimpleHTTPRequestHandler.end_headers(self)

    def send_my_headers(self):
        self.send_header("Accept-Ranges", "bytes")
    self.send_header("Keep-Alive", "timeout=5, max=100")
    self.send_header("Connection", "Keep-Alive")

if __name__ == '__main__':
    m = SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map
    m[".tgz"]="application/x-gzip" 
    SimpleHTTPServer.test(HandlerClass=MyHTTPRequestHandler)

Testing

➜  ~  telnet download.freenas.org 80
Trying 64.62.136.38...
Connected to download.freenas.org.
Escape character is '^]'.
HEAD / HTTP/1.0

HTTP/1.1 200 OK
Date: Sat, 07 Feb 2015 03:06:24 GMT
Server: Apache/2.2.27 (FreeBSD) mod_ssl/2.2.27 OpenSSL/1.0.1i-freebsd DAV/2
Connection: close
Content-Type: text/html;charset=ISO-8859-1

Connection closed by foreign host.

➜  ~  telnet localhost 8000
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
HEAD / HTTP/1.0

HTTP/1.0 200 OK
Server: SimpleHTTP/0.6 Python/2.7.6
Date: Sat, 07 Feb 2015 03:07:17 GMT
Content-type: text/html; charset=utf-8
Content-Length: 1700
Accept-Ranges: bytes
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive

Connection closed by foreign host.

Any hints ?

#8 Avatar?id=14398&size=24x24 Updated by Kris Moore about 3 years ago

  • Target version changed from Unspecified to N/A

Also available in: Atom PDF