Skip to content

Commit

Permalink
Cache images with retries
Browse files Browse the repository at this point in the history
* Install packages with retries
* Cache images with retries

Related-Prod: PRODX-3456
Change-Id: If68ba2d70b27ba56b39464eb85d059c1ec89c6cd
  • Loading branch information
jumpojoy committed Jul 24, 2024
1 parent 7ee4c8d commit 0cd75f1
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions heat-templates/scripts/service_lib
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,17 @@ function retry {
done
return 0
}

function install_required_packages {
function install_retry {
function install_packages {
local packages="$1"
function _install_packages {
apt update && \
export DEBIAN_FRONTEND=noninteractive; apt install -y apt-transport-https ca-certificates curl software-properties-common jq unzip atop iptables-persistent mysql-client
export DEBIAN_FRONTEND=noninteractive; apt install -y apt-transport-https ca-certificates $packages
}
retry 10 "Failed to install required packages" install_retry
retry 10 "Failed to install required packages" _install_packages
}

function install_required_packages {
install_packages "apt-transport-https ca-certificates curl software-properties-common jq unzip atop iptables-persistent mysql-client"
}


Expand Down Expand Up @@ -140,9 +144,18 @@ function mount_drives {
fi
}

function cache_images {
local image="$1"
function _get_image {
docker pull ${image}
}
retry 10 "Failed to pull image" _get_image
}

function install_database {
install_required_packages
install_docker
cache_images $DATABASE_DOCKER_IMAGE
configure_mariadb
start_mariadb
grant_remote_access
Expand All @@ -158,12 +171,12 @@ function install_docker {
]
}
EOF
apt update
apt install -y docker.io
install_packages docker.io
}

function install_app {
install_docker
cache_images $APP_DOCKER_IMAGE
docker run --restart=always -dit -p ${APP_PORT}:8000 --hostname $(hostname) -e OS_REFAPP_DB_URL="mysql+pymysql://${APP_DATABASE_USER}:${APP_DATABASE_PASSWORD}@${DATABASE_VIP}:3306/refapp" $APP_DOCKER_IMAGE
}

Expand Down

0 comments on commit 0cd75f1

Please sign in to comment.