Merge lp:~caio1982/ubuntu-system-image/sis-skip404 into lp:ubuntu-system-image/server

Proposed by Caio Begotti
Status: Superseded
Proposed branch: lp:~caio1982/ubuntu-system-image/sis-skip404
Merge into: lp:ubuntu-system-image/server
Diff against target: 16 lines (+6/-0)
1 file modified
lib/systemimage/generators.py (+6/-0)
To merge this branch: bzr merge lp:~caio1982/ubuntu-system-image/sis-skip404
Reviewer Review Type Date Requested Status
Registry Administrators Pending
Review via email: mp+252579@code.launchpad.net

This proposal has been superseded by a proposal from 2015-03-11.

Description of the change

Image server goes crazy if the configured image is not there at the time of importing. What happens is that it fetches an Apache error page (HTML) and try to import it, which surprisingly works. Then when the image is finally there it tries to generate a delta, and that obviously fails because one of the files (the source one) is not an image.

The only way to recover from this state is to manually intervene and remove the first processed files, json, images etc. This is very problematic for us in PES.

Although this MR is kind of hackish it does the job for running image server on Prodstack. I understand a more robust solution would be needed to handle corner cases (perhaps using Requests instead of urllib, to start with).

To post a comment you must log in.
262. By Caio Begotti

catch all http errors above 400 instead and make the logging message more generic to reflect it

263. By Caio Begotti

transform all calls to urlopen and urlretrieve in wrapper calls so we catch all timeouts and >= 400 http errors better

264. By Caio Begotti

fix flake errors due to leftovers from previous commit

265. By Caio Begotti

add more debug logging to the methods we are wrapping around

Unmerged revisions

265. By Caio Begotti

add more debug logging to the methods we are wrapping around

264. By Caio Begotti

fix flake errors due to leftovers from previous commit

263. By Caio Begotti

transform all calls to urlopen and urlretrieve in wrapper calls so we catch all timeouts and >= 400 http errors better

262. By Caio Begotti

catch all http errors above 400 instead and make the logging message more generic to reflect it

261. By Caio Begotti

make s-i-s a bit smarted by returning none if the actual file was not found, otherwise it will process a dummy html page with a 404 error message inside it... this is more like a hack because using urllib these days seems already wrong and i dont have the time to fully fix how all files are urlopened or urlretrieved in its code

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/systemimage/generators.py'
2--- lib/systemimage/generators.py 2015-02-24 22:24:16 +0000
3+++ lib/systemimage/generators.py 2015-03-11 13:28:58 +0000
4@@ -890,6 +890,12 @@
5 environment['version_detail'].append(version_detail)
6 return path
7
8+ # Make sure it's there before retrieval
9+ http_code = urlopen(url).getcode()
10+ if http_code == 404:
11+ logger.debug('Not found on the server, skipping %s' % url)
12+ return None
13+
14 # Grab the real thing
15 tempdir = tempfile.mkdtemp()
16 old_timeout = socket.getdefaulttimeout()

Subscribers

People subscribed via source and target branches

to all changes: