Skip to content

Commit

Permalink
put yum actions in retry loop with timeout (#332)
Browse files Browse the repository at this point in the history
Put yum actions in retry loop with timeout
  • Loading branch information
padthaitofuhot committed Aug 7, 2017
1 parent 5c2f105 commit 57a1437
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 22 deletions.
16 changes: 6 additions & 10 deletions bootstrap_plugins/centos72.plugin.sh
Expand Up @@ -17,7 +17,7 @@ os_supported=true
docker_binary='/bin/docker'

# packages to clean up during preflight
list_preflight_packages="git nfs-client rsync wget curl epel-release yum-utils ntp docker vim rsync pigz gdisk aria2 htop iotop iftop multitail dstat jq python-docker-py dkms qemu-guest-agent open-vm-tools docker"
list_preflight_packages="git nfs-client rsync wget curl epel-release ntp docker vim rsync pigz gdisk aria2 htop iotop iftop multitail dstat jq python-docker-py dkms qemu-guest-agent open-vm-tools docker"
#nfs-tools"

# Do any OS-specific tasks that must be done prior to bootstrap
Expand Down Expand Up @@ -72,28 +72,24 @@ in_vm_packages() {

# command to install one or more os package manager package
in_repo_pkg() {
while ! sudo yum -y install $*; do
sleep 5
done
retry_with_timeout 10 300 sudo yum -y install $*
}

rm_repo_pkg() {
sudo yum -y autoremove $*
retry_with_timeout 10 300 yum -y autoremove $*
}

# command to update all packages in the os package manager
up_repo_pkg_all() {
sudo yum -y update
retry_with_timeout 10 300 sudo yum -y update
}

# command to rebuild the os package manager's database
up_repo_db() {
while ! sudo yum -y makecache; do
sleep 10
# retry
done
retry_with_timeout 10 300 yum -y makecache
}


# command to set os package manager proxy
set_repo_proxy_conf() {
sudo sed -i -e '/^proxy=/d' /etc/yum.conf
Expand Down
17 changes: 5 additions & 12 deletions bootstrap_plugins/centos73.plugin.sh
Expand Up @@ -17,7 +17,7 @@ os_supported=true
docker_binary='/bin/docker'

# packages to clean up during preflight
list_preflight_packages="git nfs-client rsync wget curl epel-release yum-utils ntp docker vim rsync pigz gdisk aria2 htop iotop iftop multitail dstat jq python-docker-py dkms qemu-guest-agent open-vm-tools docker"
list_preflight_packages="git nfs-client rsync wget curl epel-release ntp docker vim rsync pigz gdisk aria2 htop iotop iftop multitail dstat jq python-docker-py dkms qemu-guest-agent open-vm-tools docker"

# Do any OS-specific tasks that must be done prior to bootstrap
do_preflight() {
Expand Down Expand Up @@ -71,28 +71,21 @@ in_vm_packages() {

# command to install one or more os package manager package
in_repo_pkg() {
while ! sudo yum -y install $*; do
sleep 1
done
retry_with_timeout 10 300 sudo yum -y install $*
}

rm_repo_pkg() {
while ! sudo yum -y autoremove $*; do
sleep 1
done
retry_with_timeout 10 300 yum -y autoremove $*
}

# command to update all packages in the os package manager
up_repo_pkg_all() {
sudo yum -y update
retry_with_timeout 10 300 sudo yum -y update
}

# command to rebuild the os package manager's database
up_repo_db() {
while ! sudo yum -y makecache; do
sleep 1
# retry
done
retry_with_timeout 10 300 yum -y makecache
}

# command to set os package manager proxy
Expand Down

0 comments on commit 57a1437

Please sign in to comment.