Bug 984216 - yum-config-manager can not configure local repositories in an isolated network
Summary: yum-config-manager can not configure local repositories in an isolated network
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: yum-utils
Version: 19
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Packaging Maintenance Team
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-07-13 17:11 UTC by Dean Hunter
Modified: 2013-09-29 01:46 UTC (History)
4 users (show)

Fixed In Version: yum-utils-1.1.31-18.fc19
Clone Of:
Environment:
Last Closed: 2013-09-29 01:46:19 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Dean Hunter 2013-07-13 17:11:57 UTC
Description of problem:

I am building VMs for testing Fedora 19 in an isolated network so that I can control when updates are available.  See http://libvirt.org/formatnetwork.html#examplesPrivate for the definition of isolated network in this case.  I have built replicas of the fedora and fedora-updates repositories on the VM host and made them accessible via http.  I have written an Anaconda Kickstart script that references the local repository replicas.  The VM creation successfully uses the local repository replicas and completes in significantly less time than when using Internet mirrored repositories.

However, I am unable to configure the new VM to use the local repository replicas using yum-config-manager.  If  I try to add one of the local repository replicas then yum-config-manager fails because it can not retrieve metalink data for the default Internet repository mirrors.  If I first disable the default Internet repository mirrors and then try to add one of the local repository replicas then yum-config-manager fails with a list index out of range error.

I can work around the problem by copying the .repo files for the local repository replicas to /etc/yum.repos.d and then disabling the Internet repository mirrors, but I do not think this is a viable long term solution.


Version-Release number of selected component (if applicable):

yum-utils-1.1.31-15.fc19.noarch


How reproducible: Consistent


Steps to Reproduce:

1. Build local repository replicas

# Create local replicas of the fedora repositories

  yum install --assumeyes yum-utils

  mkdir /srv/http/repos
  ln -s /srv/http/repos /var/www/html/repos

  for r in 18 19
  do
    cp -p  /etc/yum.conf    /etc/fedora$r.conf
    cp -pr /etc/yum.repos.d /etc/fedora$r.repos.d

    echo "reposdir=/etc/fedora\$releasever.repos.d" >>/etc/fedora$r.conf
    sed -i s/\$releasever/$r/g /etc/fedora$r.conf
    sed -i s/\$releasever/$r/g /etc/fedora$r.repos.d/fedora.repo
    sed -i s/\$releasever/$r/g /etc/fedora$r.repos.d/fedora-updates.repo
    sed -i s/\$releasever/$r/g /etc/fedora$r.repos.d/fedora-updates-testing.repo

    wget --output-document /srv/nfs/ISO/Fedora-$r-x86_64-netinst.iso \
      http://download.fedoraproject.org/pub/fedora/linux/releases/$r/Fedora/x86_64/iso/Fedora-$r-x86_64-netinst.iso

    mkdir /mnt/iso
    mount \
      --options loop \
      --source /srv/nfs/ISO/Fedora-$r-x86_64-netinst.iso \
      --target /mnt/iso

    cp -r /mnt/iso /srv/http/repos/fedora$r

    umount /mnt/iso
    rmdir  /mnt/iso

    reposync \
      --config /etc/fedora$r.conf \
      --download_path /srv/http/repos/fedora$r \
      --downloadcomps \
      --repoid fedora

    createrepo \
      --update /srv/http/repos/fedora$r/fedora

    reposync \
      --config /etc/fedora$r.conf \
      --download_path /srv/http/repos/fedora$r \
      --downloadcomps \
      --repoid updates

    createrepo \
      --update /srv/http/repos/fedora$r/updates
  done

  cat >/srv/http/repos/local-fedora.repo <<EOD
[local-fedora]
name=Fedora \$releasever - \$basearch - Local
baseurl=http://host.hunter.org/repos/fedora\$releasever/fedora
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-\$basearch
EOD

  cat >/srv/http/repos/local-updates.repo <<EOD
[local-updates]
name=Fedora \$releasever - \$basearch - Local Updates
baseurl=http://host.hunter.org/repos/fedora\$releasever/updates
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-\$basearch
EOD

2. Build a new VM using the local repository replicas

#!/usr/bin/bash

  log() {
    echo $(date "+%H:%M:%S") $2 | tee --append $1
  }

  case "$1" in
  "--help") echo "Create      Create a domain";;
  "--vars")
    echo "Create requires the following variables to be set:"
    echo "  backgroundPicture: URI of the graphic to use as the Gnome desktop background"
    echo "  backgroundPrimary: color code of the primary background color, depends on the picture"
    echo "  backgroundSecondary: color code of the secondary background color, depends on the picture"
    echo "  capacity: size of the logical volume in the Guests pool for the virtual machine"
    echo "  disk: name of the disk device created on the logical volume"
    echo "  domain: libvirt name of the virtual machine"
    echo "  host: DNS name of the virtual machine"
    echo "  ip: 4th octet of the internet protocol v4 address of the virtual machine"
    echo "  releasever: release number of Fedora repository to be installed"
    echo "  subnet: 3rd octet of the internet protocol v4 address of the virtual machine"
    ;;
  *)
    state=$(virsh domstate $domain 2>/dev/null)

    case $? in 
    0) log $1 "Domain $domain must be destroyed before it can be created";;
    *)
      kickstart="$(dirname $1)/$domain-ks.cfg"
      cat >$kickstart <<EOF
auth       --enableshadow --passalgo sha512
autopart   --type lvm
bootloader --location mbr --boot-drive $disk
#cdrom
clearpart  --all --initlabel --drives $disk
firewall   --enable --service mdns,ssh
firstboot  --disable
ignoredisk --only-use $disk
keyboard   --vckeymap us --xlayouts us
lang         en_US.UTF-8
network    --activate --bootproto static --device eth0 --gateway 192.168.$subnet.254 --hostname $host.hunter.org --ip 192.168.$subnet.$ip --nameserver 192.168.$subnet.11 --netmask 255.255.255.0 --noipv6
repo       --name local-fedora  --baseurl http://192.168.$subnet.10/repos/fedora$releasever/fedora
repo       --name local-updates --baseurl http://192.168.$subnet.10/repos/fedora$releasever/updates
reboot
rootpw     --iscrypted \$6\$6YuUd3dm5L5ALg25\$mOot78r5I7kNFPhNRcOuFmHHS3FO.vfetR.z7K6LfGEmIk6mMlWh72coTpbiPna5puEDDPvNYngGnFL3KCvGo.
text
timezone     America/Chicago --isUtc
url        --url http://192.168.$subnet.10/repos/fedora$releasever/iso
user       --gecos "Local Administrator" --groups wheel --iscrypted --name local --password \$6\$6YuUd3dm5L5ALg25\$mOot78r5I7kNFPhNRcOuFmHHS3FO.vfetR.z7K6LfGEmIk6mMlWh72coTpbiPna5puEDDPvNYngGnFL3KCvGo.
xconfig    --startxonboot

%packages
@base-x
@core
@dial-up
@firefox
@fonts
@gnome-desktop
@hardware-support
@input-methods
@multimedia
@printing
@standard

qemu-guest-agent
%end

%post
  set -v

# Configure the debug shell

  systemctl enable debug-shell.service

# Configure e-mail forwarding

  echo "root.org" >/root/.forward

# Configure the Gnome desktop

  cat >/usr/share/glib-2.0/schemas/hunter.gschema.override <<EOD
[org.gnome.desktop.background]
picture-uri='$backgroundPicture'
primary-color='$backgroundPrimary'
secondary-color='$backgroundSecondary'

[org.gnome.desktop.interface]
clock-show-date=true

[org.gnome.desktop.screensaver]
lock-enabled=false

[org.gnome.desktop.sound]
event-sounds=false

[org.gnome.gedit.preferences.editor]
create-backup-copy=false
wrap-mode='none'

[org.gnome.nautilus.preferences]
default-folder-viewer='list-view'
sort-directories-first=true

[org.gnome.shell]
always-show-log-out=true
favorite-apps=['gnome-terminal.desktop', 'nautilus.desktop', 'gedit.desktop', 'firefox.desktop']

EOD

  chcon --user system_u /usr/share/glib-2.0/schemas/hunter.gschema.override
  chcon --type usr_t    /usr/share/glib-2.0/schemas/hunter.gschema.override

  glib-compile-schemas  /usr/share/glib-2.0/schemas

# Skip the Gnome Initial Setup

  mkdir /home/local/.config
  echo yes >/home/local/.config/gnome-initial-setup-done
  chown -R local:local /home/local/.config

# Configure the hosts file

cat >/etc/hosts <<EOD
127.0.0.1        localhost.localdomain  localhost
192.168.$subnet.10     host.hunter.org        host
EOD

# Configure the SSH directory for root

  mkdir /root/.ssh
  chcon --type ssh_home_t /root/.ssh
  chcon --user system_u   /root/.ssh

%end
EOF
      chmod 644 $kickstart

      message=$(virsh vol-create-as --name $domain --pool Guests --capacity $capacity 2>&1)
      log $1 "$message"

      log $1 "Domain $domain is being created"
      virt-install \
        --autostart \
        --channel unix,path=/var/lib/libvirt/qemu/guest.agent,mode=bind,target_type=virtio,name=org.qemu.guest_agent.0 \
        --connect qemu:///system \
        --disk vol=Guests/$domain \
        --extra-args "inst.ks=file:/$(basename $kickstart)" \
        --graphics spice \
        --initrd-inject $kickstart \
        --location http://192.168.$subnet.10/repos/fedora$releasever/iso \
        --name $domain \
        --network network=Subnet$subnet \
        --os-type linux \
        --os-variant fedora18 \
        --ram 2048 \
        --vcpus 2
#       --noautoconsole \
      echo
      ;;
    esac
    ;;
  esac

3. Add local repository replicas to yum configuration

  yum-config-manager --add-repo http://host.hunter.org/repos/local-fedora.repo
  yum-config-manager --add-repo http://host.hunter.org/repos/local-updates.repo

  yum-config-manager --disable fedora
  yum-config-manager --disable updates


Actual results:

[root@host ~]# ssh root@test19
Last login: Sat Jul 13 12:02:32 2013 from host.hunter.org

[root@test19 ~]# yum-config-manager --add-repo http://host.hunter.org/repos/local-fedora.repo
Loaded plugins: langpacks, refresh-packagekit
adding repo from: http://host.hunter.org/repos/local-fedora.repo
Traceback (most recent call last):
  File "/usr/bin/yum-config-manager", line 202, in <module>
    grabber = yb.repos.listEnabled()[0].grabfunc            
  File "/usr/lib/python2.7/site-packages/yum/yumRepo.py", line 692, in <lambda>
    grabfunc = property(lambda self: self._getgrabfunc())
  File "/usr/lib/python2.7/site-packages/yum/yumRepo.py", line 682, in _getgrabfunc
    self._setupGrab()
  File "/usr/lib/python2.7/site-packages/yum/yumRepo.py", line 627, in _setupGrab
    urls = self.urls
  File "/usr/lib/python2.7/site-packages/yum/yumRepo.py", line 873, in <lambda>
    urls = property(fget=lambda self: self._geturls(),
  File "/usr/lib/python2.7/site-packages/yum/yumRepo.py", line 870, in _geturls
    self._baseurlSetup()
  File "/usr/lib/python2.7/site-packages/yum/yumRepo.py", line 816, in _baseurlSetup
    mirrorurls.extend(list(self.metalink_data.urls()))
  File "/usr/lib/python2.7/site-packages/yum/yumRepo.py", line 913, in <lambda>
    metalink_data = property(fget=lambda self: self._getMetalink(),
  File "/usr/lib/python2.7/site-packages/yum/yumRepo.py", line 892, in _getMetalink
    raise Errors.RepoError, msg
yum.Errors.RepoError: Cannot retrieve metalink for repository: fedora/19/x86_64. Please verify its path and try again

[root@test19 ~]# yum-config-manager --disable fedora
Loaded plugins: langpacks, refresh-packagekit
================================= repo: fedora =================================
[fedora]
async = True
...
ui_repoid_vars = releasever,
   basearch
username = 

[root@test19 ~]# yum-config-manager --disable updates
Loaded plugins: langpacks, refresh-packagekit
================================ repo: updates =================================
[updates]
async = True
...
ui_repoid_vars = releasever,
   basearch
username = 

[root@test19 ~]# yum-config-manager --add-repo http://host.hunter.org/repos/local-fedora.repo
Loaded plugins: langpacks, refresh-packagekit
adding repo from: http://host.hunter.org/repos/local-fedora.repo
Traceback (most recent call last):
  File "/usr/bin/yum-config-manager", line 202, in <module>
    grabber = yb.repos.listEnabled()[0].grabfunc            
IndexError: list index out of range

[root@test19 ~]# 


Expected results:

[root@test19 ~]# yum-config-manager --add-repo http://host.hunter.org/repos/local-fedora.repo
Loaded plugins: langpacks, refresh-packagekit
adding repo from: http://host.hunter.org/repos/local-fedora.repo
grabbing file http://host.hunter.org/repos/local-fedora.repo to /etc/yum.repos.d/local-fedora.repo
local-fedora.repo                                        |  202 B     00:00     
repo saved to /etc/yum.repos.d/local-fedora.repo

[root@test19 ~]# 


Additional info:

Comment 1 Dean Hunter 2013-09-19 15:26:39 UTC
Running reposync with "--download-metadata" instead of "--downloadcomps" resolved the problem on Fedora 19, but the problem persists on Fedora 18.

Comment 2 Dean Hunter 2013-09-25 11:10:57 UTC
(In reply to Dean Hunter from comment #1)
> Running reposync with "--download-metadata" instead of "--downloadcomps"
> resolved the problem on Fedora 19, but the problem persists on Fedora 18.

Please ignore comment #1.

The actual results have changed:

[root@developer ~]# rpm -q yum-utils
yum-utils-1.1.31-17.fc19.noarch

[root@developer ~]# curl http://host.hunter.org/repos/local-updates.repo >/etc/yum.repos.d/local-updates.repo
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   212  100   212    0     0   1392      0 --:--:-- --:--:-- --:--:--  1394

[root@developer ~]# yum-config-manager --add-repo http://host.hunter.org/repos/local-updates.repo
Loaded plugins: langpacks, refresh-packagekit
adding repo from: http://host.hunter.org/repos/local-updates.repo
grabbing file http://host.hunter.org/repos/local-updates.repo to /etc/yum.repos.d/local-updates.repo
http://host.hunter.org/repos/local-updates.repo: [Errno 14] HTTP Error 416 - Requested Range Not Satisfiable
Trying other mirror.
Could not fetch/save url http://host.hunter.org/repos/local-updates.repo to file /etc/yum.repos.d/local-updates.repo: [Errno 14] HTTP Error 416 - Requested Range Not Satisfiable

[root@developer ~]#

Comment 3 Zdeněk Pavlas 2013-09-25 14:00:53 UTC
Ok, i see the bug.. actually there are at least two:

1) --add-repo needs at least one enabled repository, because it steals it's urlgrabber config.  This could be worked around by creating a dummy repo (or just the grabfunc, if it's not too difficult) instead.

2) reget is allowed, this results in failures when the length of existing file is >= length of remote file.  Could be fixed by explicitly disabling reget..

I'll try to reproduce this and come with a fix.

Comment 4 Dean Hunter 2013-09-25 20:29:06 UTC
(In reply to Zdeněk Pavlas from comment #3)
> Ok, i see the bug.. actually there are at least two:

Thank you for your response.
 
> 1) --add-repo needs at least one enabled repository, because it steals it's
> urlgrabber config.  This could be worked around by creating a dummy repo (or
> just the grabfunc, if it's not too difficult) instead.

I had noticed behavior like your suggested work around, but I could not reproduce it.  Please elaborate on your idea.

Comment 5 Fedora Update System 2013-09-27 12:26:28 UTC
yum-utils-1.1.31-18.fc19 has been submitted as an update for Fedora 19.
https://admin.fedoraproject.org/updates/yum-utils-1.1.31-18.fc19

Comment 6 Fedora Update System 2013-09-28 00:22:19 UTC
Package yum-utils-1.1.31-18.fc19:
* should fix your issue,
* was pushed to the Fedora 19 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing yum-utils-1.1.31-18.fc19'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2013-17856/yum-utils-1.1.31-18.fc19
then log in and leave karma (feedback).

Comment 7 Fedora Update System 2013-09-29 01:46:19 UTC
yum-utils-1.1.31-18.fc19 has been pushed to the Fedora 19 stable repository.  If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.