make package install safer
The following makes apt-get install quite a bit safer by retrying the apt-get update should it fail using a common pattern copied from devstack. It also keeps track of whether or not we've run the apt-get update during this run, which means we don't it more than once for no reason. For the specific case of the python yaml module we also check to see if it's installed first (which it often is) to avoid doing network actions when not needed. This should make the Related-Bug: #1400905 show up less often Change-Id: I77159da4e33f4255bd8a5d7d8cd3eaae3a8a59a4
This commit is contained in:
@@ -78,10 +78,13 @@ function setup_localrc {
|
||||
else
|
||||
# Install PyYaml for test-matrix.py
|
||||
if uses_debs; then
|
||||
sudo apt-get update
|
||||
sudo apt-get --assume-yes install python-yaml
|
||||
if ! dpkg -s python-yaml > /dev/null; then
|
||||
apt_get_install python-yaml
|
||||
fi
|
||||
elif is_fedora; then
|
||||
sudo yum install -y PyYAML
|
||||
if ! rpm --quiet -q "PyYAML"; then
|
||||
sudo yum install -y PyYAML
|
||||
fi
|
||||
fi
|
||||
MY_ENABLED_SERVICES=`cd $BASE/new/devstack-gate && ./test-matrix.py -b $localrc_branch -f $DEVSTACK_GATE_FEATURE_MATRIX`
|
||||
local original_enabled_services=$MY_ENABLED_SERVICES
|
||||
|
||||
15
functions.sh
15
functions.sh
@@ -43,6 +43,21 @@ function function_exists {
|
||||
type $1 2>/dev/null | grep -q 'is a function'
|
||||
}
|
||||
|
||||
function apt_get_install {
|
||||
# fetch the updates in a loop to ensure that we're update to
|
||||
# date. Only do this once per run. Give up to 5 minutes to succeed
|
||||
# here.
|
||||
if [[ -z "$APT_UPDATED" ]]; then
|
||||
if ! timeout 300 sh -c "while ! sudo apt-get update; do sleep 30; done"; then
|
||||
echo "Failed to update apt repos, we're dead now"
|
||||
exit 1
|
||||
fi
|
||||
APT_UPDATED=1
|
||||
fi
|
||||
|
||||
sudo apt-get --assume-yes install $@
|
||||
}
|
||||
|
||||
function call_hook_if_defined {
|
||||
local hook_name=$1
|
||||
local filename=${2-$WORKSPACE/devstack-gate-$hook_name.txt}
|
||||
|
||||
Reference in New Issue
Block a user