From cf435e6c2a8f8b0be479fbe16a1cc3fa1f752d69 Mon Sep 17 00:00:00 2001 From: Scott Little Date: Wed, 6 Mar 2019 16:47:22 -0500 Subject: [PATCH] download_mirror.sh fails with 404 errors The 'yum makecache' step is failing. The issue is seen when the fast mirror plugin for yum is in use (default). The metadata for a yum repo as scattered across several files. The master file is repomd.xml, and it may list several supporting files, e.g. filelists.xml.gz primary.xml.gz filelists.sqlite.bz2 other.sqlite.bz2 other.xml.gz primary.sqlite.bz2 When fast mirror plugin is in use, each file might download from a separate source. This opens the door for a race condition when a repo update is rolling out across the mirrors. The error suggests we have already downloaded a repomd.xml, but it is obsolete and references a supporting file that no longer exists. A second possible source of inconsistent data is caching proxies. Solution: 1) Disabling the yum fast cache plugin is undesirable, and there is no option forcing metadata iof a given repo to be single sourced. So this update adds a limited number of retries for the 'yum makecache' command. So far we've never seen 'yum makecache' fail twice in a row... largely because the 'fastest mirror' plugin rarely downloaded from the same source twice. 2) Add 'http_caching=packages' to yum.conf, which asks upstream proxies to not cache repodata. Change-Id: I3fa3f61e38d868fb14f4175b87c0d323abb57def Closes-bug: 1818911 Signed-off-by: Scott Little --- Dockerfile | 2 ++ centos-mirror-tools/dl_rpms.sh | 19 ++++++++++++++++++- centos-mirror-tools/yum.conf.sample | 1 + 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 6462ca79..74ed7247 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,6 +21,8 @@ FROM centos:7.4.1708 # echo -e "export http_proxy=$http_proxy\nexport https_proxy=$https_proxy\n\ #export ftp_proxy=$ftp_proxy" >> /root/.bashrc +RUN echo "http_caching=packages" >> /etc/yum.conf + # username you will docker exec into the container as. # It should NOT be your host username so you can easily tell # if you are in our out of the container. diff --git a/centos-mirror-tools/dl_rpms.sh b/centos-mirror-tools/dl_rpms.sh index 54ff6281..15f1f717 100755 --- a/centos-mirror-tools/dl_rpms.sh +++ b/centos-mirror-tools/dl_rpms.sh @@ -251,7 +251,24 @@ download () { # Prime the cache -${SUDOCMD} yum ${YUMCONFOPT} ${RELEASEVER} makecache +loop_count=0 +max_loop_count=5 +echo "${SUDOCMD} yum ${YUMCONFOPT} ${RELEASEVER} makecache" +while ! ${SUDOCMD} yum ${YUMCONFOPT} ${RELEASEVER} makecache ; do + # To protect against intermittent 404 errors, we'll retry + # a few times. The suspected issue is pulling repodata + # from multiple source that are temporarily inconsistent. + loop_count=$((loop_count + 1)) + if [ $loop_count -gt $max_loop_count ]; then + break + fi + echo "makecache retry: $loop_count" + + # Wipe the inconsistent data from the last try + echo "yum ${YUMCONFOPT} ${RELEASEVER} clean all" + yum ${YUMCONFOPT} ${RELEASEVER} clean all +done + # Download files if [ -s "$rpms_list" ];then diff --git a/centos-mirror-tools/yum.conf.sample b/centos-mirror-tools/yum.conf.sample index 11a6ce72..b968a8ae 100644 --- a/centos-mirror-tools/yum.conf.sample +++ b/centos-mirror-tools/yum.conf.sample @@ -13,6 +13,7 @@ bugtracker_url=http://bugs.centos.org/set_project.php?project_id=23&ref=http://b distroverpkg=centos-release override_install_langs=en_US.utf8 tsflags=nodocs +http_caching=packages reposdir=yum.repos.d