Bug 293081

Summary: redirector KDE:KDE3 -> KDE:/KDE3 does not work anymore
Product: [openSUSE] openSUSE.org Reporter: Adrian Schröter <adrian.schroeter>
Component: BuildServiceAssignee: Peter Poeml <poeml>
Status: RESOLVED FIXED QA Contact: Adrian Schröter <adrian.schroeter>
Severity: Normal    
Priority: P5 - None CC: ms
Version: unspecified   
Target Milestone: ---   
Hardware: Other   
OS: Other   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Adrian Schröter 2007-07-19 14:46:55 UTC
The old redirector expanded project names to the real pathes. It would be good to get this funcationality back.

For example

http://download.opensuse.org/repositories/KDE:KDE3/openSUSE_10.2/

should get expanded to 

http://download.opensuse.org/repositories/KDE:/KDE3/openSUSE_10.2/

The evil trick here is only to expand the project name, but nothing else. For example

http://download.opensuse.org/repositories/KDE:KDE3/openSUSE_10.2/KDE:KDE3.repo

must not get expanded the .repo filename.

This still works with base repos like openSUSE:Factory (on software, not yet on download.o.o), but this comes from the special rules, since they redirect to external repos.

kiwi can adapt it's "opensuse://<project>" syntax when this is fixed.
Comment 1 Peter Poeml 2007-07-24 11:19:15 UTC
I thought about implementing this in the redirector, but came to the conclusion that this is not a feature related to the redirector at all. 

It is best implemented with mod_rewrite (unless there are more specific needs, but I don't know of any). I'll figure something out.
Comment 2 Peter Poeml 2007-07-24 14:45:29 UTC
I fixed it like this:

    # rewriting of ':' to ':/' in buildservice project names
    # https://bugzilla.novell.com/show_bug.cgi?id=293081
    RedirectMatch permanent ^/repositories/([^/]+):([^/]+)/(.*) http://download.opensuse.org/repositories/$1:/$2/$3

This yields a recursive rule by returning 301 (permanent redirect) to the client, and make it come back for the next replacement. Not the most efficient procedure, but works, and I have the feeling that the recursion would be difficult to express in mod_rewrite (although it can probably be done through rewriting subrequests). If required, this can be revisited later.

I added testcases to https://svn.suse.de/svn/opensuse/trunk/urltests
Comment 3 Adrian Schröter 2007-07-24 15:55:40 UTC
This rule will fail for devel:languages:something , because it is not recursive, right ?

Comment 4 Peter Poeml 2007-07-24 20:49:57 UTC
No, it will not fail, that's what I tried to explain above ;)
I have put a respective testcase in here:
http://svn.suse.de/viewcvs/opensuse/trunk/urltests/ftpoo-tests?r1=671&r2=675
The point is that the first redirect goes to an URL with one colon replaced, and if there is another one in the next request which the client issues, it will be redirected with another replacement, and so on. 

This seems sufficient to me atm. I find only a few (5) project names with more than two colons.

It could probably be done as RewriteRule more efficiently. I have looked in the configuration svn of ftp.o.o, but I haven't found anything in the old revisions. Maybe it wasn't implemented in apache configuration but in the old redirector.

The last 100.000 accesses didn't really contain such requests, so it doesn't look important to be more efficient here:

root@ftp:/usr/local/testapache # tail -n 100000 /var/log/apache2/software.opensuse.org/access_log | awk '{print $7}' | grep ':[^/]' | grep -v ':/' | grep -v "\(Factory\|Fedora\)"
/download/server%3a/monitoring/openSUSE_10.2/server:monitoring.repo
/download/home%3a/sax2/10.2/home:sax2.repo
/KDE%3A/KDE3/openSUSE_10.2/KDE:KDE3.repo

(I excluded Factory and Fedora because they are handled by other RewriteRules anyway)