Closed Bug 888214 Opened 13 years ago Closed 13 years ago

Webapp to serve Apache compatible directory listings for mozilla-inbound S3 bucket

Categories

(Release Engineering :: General, defect)

x86
All
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: nthomas, Assigned: nthomas)

References

Details

Attachments

(3 files, 1 obsolete file)

This is for existing scripts and scrapers that look at ftp.m.o.
Summary: Webapp to present mozilla-inbound S3 bucket that looks like apache → Webapp to serve Apache compatible directory listings for mozilla-inbound S3 bucket
This requires a virtualenv populated with boto and flask to work, and is currently running at http://ec2-50-112-87-128.us-west-2.compute.amazonaws.com/. Could use a vendor/ dir like Balrog if preferred. WSGI setup info on bug 888215. The code to show mtimes is a little slow. AWS only returns it's own Last Modified when you get a list of keys, which corresponds to when files were uploaded to the bucket. I'm storing the mtime from ftp.m.o as metadata, but you have to do another GET per key to retrieve that. I'm not sure how much value having mtime adds anyway. Comments welcome on if this is a good fit for the cloud-tools repo, or should be somewhere else.
Attachment #768882 - Flags: feedback?(catlee)
Comment on attachment 768882 [details] [diff] [review] [??] Webapp v1.0rc1 Review of attachment 768882 [details] [diff] [review]: ----------------------------------------------------------------- ::: makehtml.py @@ +21,5 @@ > +footer_template = """ > +<tr><th colspan="5"><hr></th></tr> > +</table> > +<pre> > +mozilla-inbound archive, Pacific Time Zone (PST/PDT)</pre> probably want to factor out "mozilla-inbound" here are the leading newlines going to be a problem? You can get around that with """\ text """ @@ +67,5 @@ > + response = line_template % dict(size=size, name=name, icon=icon, alt=alt, mtime=mtime) > + return response > + > +def buildListing(config, path): > + os.environ['TZ'] = 'US/Pacific' what's this for? @@ +83,5 @@ > + if path: > + parent = posixpath.dirname(path.rstrip('/')) > + response += parent_template % dict(parent=parent) > + > + K = bucket_conn.list(prefix=path, delimiter='/') are K and k the best names for these? @@ +93,5 @@ > + continue > + count += 1 > + response += keyLine(k, bucket_conn, config.get('SHOW_MTIME', False)) > + > + response += footer_template bottle probably supports generators for yielding data. You may want to consider using "yield X" instead of "response += X". Either that or use response = []; response.append(X); return "".join(response). (+= can be expensive for creating large python strings) @@ +98,5 @@ > + > + if count: > + return response > + else: > + return 'Directory not found', 404 is this a special return value supported by bottle? ::: serveS3.py @@ +15,5 @@ > + > +@app.route('/<path:path>/<file>') > +def redirectToS3(path, file): > + url = 'https://s3-us-west-2.amazonaws.com/%s/%s/%s' % (bucket, path, file) > + return redirect(url) where does bucket come from?
Attachment #768882 - Flags: feedback?(catlee) → feedback+
Product: mozilla.org → Release Engineering
Apologies if this is late in the game, but couldn't you just write these as static files with appropriately named keys? So "/some/dir/a.txt" and "/some/dir/b.txt" would both be listed in a static index file at "/some/dir" These files could then be updated by the blobber upload scripts, and/or by a crontask in ec2 that lists buckets' contents by modification date and updates the affected indexes. The latter would introduce a small delay, which may be a problem depending on uses. In either case, it would take one moving piece out of serving this content, which can only increase resiliency.
We did consider that. You still need something to generate and store the html, and static files introduce issues around keeping them up to date (there's expiry as well as upload to account for, neither easy to hook). The bucket currently contains 12.5TB of data in 643K keys, which is roughly 3/4 of the final size. If you don't have a hook, then polling the whole bucket for a list of keys takes about 4 minutes, plus processing time to detect changes; if you're smarter and use prefix+delimiter to limit to only one level of depth you'd be looking at about a minute to regenerate all the html. This is from machines located in EC2 close to S3. I'm not expecting there to be massive traffic out of this, and it's not going to be in the critical path, so on-the-fly html generation should be fine. We're looking at Beanstalk for deployment, so there's a load balancer, backend VMs in different availability zones, etc to help with resiliency.
Component: Other → Tools
OS: Mac OS X → All
Attached patch Webapp V1.0rc2 (obsolete) — — Splinter Review
This is running at http://serves3-mozilla-inbound.elasticbeanstalk.com/. The README could still do with some work.
Attachment #809148 - Flags: review?(catlee)
Comment on attachment 809148 [details] [diff] [review] Webapp V1.0rc2 catlee and I walked through this today. We talked about * put the host domain for S3 redirects in the config * adding more docstrings/comments * look into moving existing files into /pub/mozilla.org/.... rather than being out of sync * move timezone setting into application.py * use abort() if can't open bucket connection * try using yield in buildListing() to start returning data asap Another patch coming up with that.
Attachment #809148 - Attachment is obsolete: true
Attachment #809148 - Flags: review?(catlee)
Attached patch Streaming patch — — Splinter Review
This works if you run 'python application.py', the html is sent out as we iterate over the keys (but you don't get any compression, odd). To get it to work through WSGI (which includes BeanStalk) you have to disable Flask-Compress. I haven't dug any further into it, but for now I'd take gzip compression over streaming, as a big dir listing like firefox/tinderbox-builds/mozilla-inbound-linux/ shrinks from 900KB to 35KB, and the page load time is ~1.5 seconds before transferring any data.
Attached patch webapp v1.0 — — Splinter Review
Attachment #810357 - Flags: review?
Comment on attachment 810357 [details] [diff] [review] webapp v1.0 I ran out of time to move the keys into /pub/blah/blah/ and simplify the routing (will track off bug 920884) but everything else we talked about is done here. Plus a decent README and some pep8.
Attachment #810357 - Flags: review? → review?(catlee)
Attachment #810357 - Flags: review?(catlee) → review+
Comment on attachment 810357 [details] [diff] [review] webapp v1.0 http://hg.mozilla.org/build/serveS3/rev/7fc90689f0fb I removed the extra print in one of the routing rules.
Attachment #810357 - Flags: checked-in+
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Component: Tools → General
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: