[lxc-devel] [RFC] lxc-fedora template. Question for original authors (and others).

Michael H. Warfield mhw at WittsEnd.com
Thu May 16 14:25:46 UTC 2013


Ok all...

It took me a while to get my patch in for the Fedora template.  Much
longer than what I desired.  But I ran into two problems that caused me
much confusion and I finally decided to punt them both and ask for
comments on each.  This is one of them that's primarily directed at the
original authors of the Fedora template but open for comments...

-- 
# Authors:
# Daniel Lezcano <daniel.lezcano at free.fr>
# Ramez Hanna <rhanna at informatiq.org>
-- 

I'm interested in heavily plagiarizing the Fedora template to create a
CentOS template and (maybe) one for SL (Scientific Linux) or even RHEL.
I ran into this stumbling block in the template...

In the Fedora template, on or about line 167 begins this loop:

--
    for trynumber in 1 2 3; do
        [ $trynumber != 1 ] && echo "Trying again..."
        MIRROR_URL=$(curl -s -S -f "$MIRRORLIST_URL" | head -n2 | tail -n1)
        if [ $? -ne 0 ] || [ -z "$MIRROR_URL" ]; then
            echo "Failed to get a mirror"
            continue
        fi
-- 

What is the purpose of this loop?  I can conceive of three (only one of
which really works).

1) It's a simple retry in case of network failures.  I can see that and
buy that, certainly based on the error check that follows it.

2) It's a retry based on the release extension (in case it's -2 or -3).
Except that the release extension is hard coded to "-1" later.  If so,
that would be a bug that should be fixed.  But that would conflict with
it being a simple retry attempt.

3) It's an attempt to "rotate" the mirrors, expecting that each return
from a mirror request is going to be different.  In theory, that's a
nice idea.  In practice, it seems that the mirrors cache results (or
generate results base on some obscure algorithm I'm now aware of) and
for several minutes return the same result before rescrambling the repo
list (I've actively tested this and it makes sense for package
retrieval).  So that doesn't really work either.

Down in the loop I see this...

-- 
        if [ $? -ne 0 ]; then
            echo "Failed to download fedora release rpm"
            continue
        fi
-- 

Ok...  That restarts the entire process over on the next try even if we
succeeded in downloading a mirror list.  That is not entirely consistent
with #1 (sub optimal) and would sort of agree with #2 and support #3.
But, #2 and #3 don't really work, if that was the intent.

If it's #1 (the only one that really works) I can see some optimization
in splitting the loop into two loops around each retrieval.  If the
intent was #2 or #3, we need to fix some bugs or rethink that logic (I
would take the list once and scramble it internally).  I'm at a loss
there, not knowing what was intended or what we really want that loop to
do.

Thoughts?

Regards,
Mike
-- 
Michael H. Warfield (AI4NB) | (770) 985-6132 |  mhw at WittsEnd.com
   /\/\|=mhw=|\/\/          | (678) 463-0932 |  http://www.wittsend.com/mhw/
   NIC whois: MHW9          | An optimist believes we live in the best of all
 PGP Key: 0x674627FF        | possible worlds.  A pessimist is sure of it!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 482 bytes
Desc: This is a digitally signed message part
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20130516/d0ddec4c/attachment.pgp>


More information about the lxc-devel mailing list