By default, Bugzilla does not search the list of RESOLVED bugs.
You can force it to do so by putting the upper-case word ALL in front of your search query, e.g.: ALL tdelibs
We recommend searching for bugs this way, as you may discover that your bug has already been resolved and fixed in a later release.

Bug 2221

Summary: Mirror redirection corner case - directories
Product: TDE Reporter: mgb-trinity
Component: non-core programsAssignee: Slávek Banko <slavek.banko>
Status: VERIFIED FIXED    
Severity: normal CC: bugwatch, mgb-trinity, michele.calgaro, slavek.banko, wofgdkncxojef
Priority: P5    
Version: R14.0.x [Trinity]   
Hardware: Other   
OS: Linux   
Compiler Version: TDE Version String:
Application Version: Application Name:
Bug Depends on:    
Bug Blocks: 2914    

Description mgb-trinity 2014-11-30 07:47:18 CST
Directory accesses are redirected to mirrors, leading people viewing e.g. http://ppa.quickbuild.pearsoncomputing.net/trinity/ in a web browser to mirrors which may contain partially stale or missing files.
Comment 1 mgb-trinity 2014-11-30 07:52:41 CST
Removed "1/2" from bug title.

(I had originally thought that Packages.gz was permanently redirected leading to a "2/2" bug filing but I was mistaken.)
Comment 2 wofgdkncxojef 2018-05-23 21:39:34 CDT
obsolete
Comment 3 mgb-trinity 2018-05-23 22:19:23 CDT
Not obsolete, just moved to the current TDE URL, e.g.

http://mirror.ppa.trinitydesktop.org/trinity/trinity-r14.0.0/debian
Comment 4 wofgdkncxojef 2018-05-24 00:18:43 CDT
I don't quite get it. Whats the problem?
The closest mirror is chosen for faster downloads.
It's the responsibility of the site owner to have good mirrors.
Comment 5 mgb-trinity 2018-05-24 00:49:02 CDT
Mirrors don't all update at the same rate, particularly during new releases when rollout takes several days.  But even during minor updates it takes several hours for all mirrors to fully sync.  (I know because I operate not Tim's master server but the master mirror which feeds the other mirrors.)

To this end Tim's master server maintains information about which mirrors have each regular file and only redirect regular file requests to mirrors which have the requested file.  This works fine.

However the master server also redirects requests for directories.  This can result in redirecting to an incomplete mirror of a directory, only to find that desired regular files or subdirectories are missing.  I know this happens because that's how I first stumbled over this bug.

The master server redirector should not redirect directory requests, only regular file requests.  Keep users on the master server until they ask for a regular file, and only then redirect them.
Comment 6 wofgdkncxojef 2018-05-24 01:59:09 CDT
so in stupidspeach, you are saying,
the server is missconfigured.

Tim or Slavek know about this?

Bugs here tend to be berried and forgotten.
You posted this 3 years ago.
You should send them an email directly.
Comment 7 mgb-trinity 2018-05-24 02:03:11 CDT
Tim has higher priorities.  Just leave this bug report open and if he finishes dealing with more important bugs this report will remind him about this rare but real problem.  G'nite.  --Mike
Comment 8 wofgdkncxojef 2018-05-24 10:17:19 CDT
Maybe he should delegate the master server to you also?
Since he has no time?
Comment 9 Slávek Banko 2018-07-21 10:48:54 CDT
I will not comment on the speeches wofgdkncxojef.

Mike, your proposal is very helpful. Regardless of the mirror synchronization status, if the user is redirected to one of the mirrors for a folder listing, then all subsequent downloads use URL to that mirror, instead of using the redirector. Because of this, the redirector can not be helpful with redirection for files that are missing for a specific mirror.

Because I'm administrator of the current main redirector on mirror.ppa.trinitydesktop.org, I tried to solve the problem.

Here are two major pitfalls:

1) Redirector is not the primary server == does not have the primary server content.

2) The redirector does not have its own complete mirror.

Because of this, on the redirector cannot be verified against the local file system whether the URL refers to a folder or a file. At the same time, it is not possible to make a folder listing locally on the redirector. However, I have prepared a solution that could be good.

When the redirector verifies the availability of a specific file on a specific mirror, the http head is fetched. Folder listings returns in http head content-type text/html. Therefore, for content-type text/html I have added special behavior to the redirector. Instead of a redirection, the best content available for that url is loaded and then served directly from the redirector.

Source selection is as follows:

1) If the URL refers to a specific html file or a folder containing the index.html file that is available in the local cache on the redirector, this is served. This is useful, for example, for http://mirror.ppa.trinitydesktop.org/trinity/trinity/rpm/

2) If the primary server is available, content from the primary server is loaded and served. Primary server unavailability may be caused by either a network problem or a ban on firewall that is sometimes inappropriately active - see bug 2938.

3) The content is loaded and served from the primary mirror.

4) The content is loaded and served from a mirror selected according to the user's location.

In all cases, the content is served directly from the redirector, so references from these folder listings will again refer to the redirector. And that was the primary purpose of this solution.

Please try to see if it works as expected.
Comment 10 Michele Calgaro 2018-08-02 09:40:05 CDT
Mike, Slavek, 
what is the status of this bug now? Still valid?
Comment 11 mgb-trinity 2018-08-02 10:17:19 CDT
This issue seems to be partially fixed.

For example, this link works as desired.

http://mirror.ppa.trinitydesktop.org/trinity/trinity-r14.0.0/debian

However clicking on dists in the resulting page yields a blank page but should yield a page on the redirector with content similar to this:

http://tde-mirror.yosemite.net/trinity/trinity-r14.0.0/debian/dists/

The problem appears to be that the redirector handles URLs ending "dists" different from URLs ending "dists/".
Comment 12 Michele Calgaro 2018-08-02 10:35:10 CDT
Thanks Mike
Comment 13 Slávek Banko 2018-08-02 10:41:18 CDT
(In reply to mgb-trinity from comment #11)
> This issue seems to be partially fixed.
> 
> For example, this link works as desired.
> 
> http://mirror.ppa.trinitydesktop.org/trinity/trinity-r14.0.0/debian
> 
> However clicking on dists in the resulting page yields a blank page but
> should yield a page on the redirector with content similar to this:
> 
> http://tde-mirror.yosemite.net/trinity/trinity-r14.0.0/debian/dists/
> 
> The problem appears to be that the redirector handles URLs ending "dists"
> different from URLs ending "dists/".

A moment ago, I found that issue with links in the folder listing (are relative) occurs if the url does not contain the final slash.

For this address does not work:
http://mirror.ppa.trinitydesktop.org/trinity/trinity-r14.0.0/debian

For this address works:
http://mirror.ppa.trinitydesktop.org/trinity/trinity-r14.0.0/debian/

I will prepare a solution to this problem.
Comment 14 Slávek Banko 2018-08-02 12:22:23 CDT
I edited the redirector code, the problem with the missing final slash for the folders now should be resolved!

Please verify that everything works as expected.
Comment 15 mgb-trinity 2018-08-02 17:13:13 CDT
Successfully tested on directories with and without trailing slashes, regular files, and symlinks to each of the above.

(Not tested on dangling symlinks as there are none in the archive at this time but I don't think this is a significant case.)

However for missing files it gives a blank page instead of a 404.  This might confuse diagnosis of user problems e.g. failure to apt-get update before upgrade.
Comment 16 Slávek Banko 2018-08-02 19:09:22 CDT
(In reply to mgb-trinity from comment #15)
> Successfully tested on directories with and without trailing slashes,
> regular files, and symlinks to each of the above.
> 
> (Not tested on dangling symlinks as there are none in the archive at this
> time but I don't think this is a significant case.)
> 
> However for missing files it gives a blank page instead of a 404.  This
> might confuse diagnosis of user problems e.g. failure to apt-get update
> before upgrade.

Yes, you are right - although the status code 404 is returned correctly, no page content is returned, which could be confusing to users. Fixed - now a simple html page is returned.
Comment 17 mgb-trinity 2018-08-02 22:40:41 CDT
Looks good.
Comment 18 Michele Calgaro 2018-08-03 00:28:58 CDT
So it is ok to close now? OR something else remains to be fixed?
Comment 19 mgb-trinity 2018-08-03 00:45:49 CDT
IMHO you can mark this bug fixed.
Comment 20 Slávek Banko 2018-08-03 01:42:35 CDT
(In reply to mgb-trinity from comment #19)
> IMHO you can mark this bug fixed.

Mike, thank you for your initial idea and comments during testing!