Removed the hardcoded wait logic

* Removed the hardcoded wait condition ( 30s delay )
  for docker and libvirtd service
* Added logic to wait until docker is available for artifact-setup.
* Added logic to wait until libvritd is available for infra-builder.
* Added "imagePullPolicy: IfNotPresent" to make use of local changes.

Closes: #629
Change-Id: I8956cf5927be6142fcc0a3b1a112ea82511fd9bb
changes/91/808991/5
Siraj Yasin 1 year ago
parent 885187f37c
commit c7be426de3
  1. 25
      tools/airship-in-a-pod/artifact-setup/assets/entrypoint.sh
  2. 7
      tools/airship-in-a-pod/examples/base/airship-in-a-pod.yaml
  3. 26
      tools/airship-in-a-pod/infra-builder/assets/entrypoint.sh

@ -39,13 +39,34 @@ function cloneRepo() {
git checkout FETCH_HEAD
}
function check_docker_readiness() {
timeout=300
#add wait condition
end=$(($(date +%s) + $timeout))
echo "Waiting $timeout seconds for docker to be ready."
while true; do
if ( docker version | grep 'Version' ); then
echo "docker is now ready"
break
else
echo "docker is not ready"
fi
now=$(date +%s)
if [ $now -gt $end ]; then
echo -e "\n Docker failed to become ready within a reasonable timeframe."
exit 1
fi
sleep 10
done
}
if [[ "$USE_CACHED_AIRSHIPCTL" = "true" ]]
then
printf "Using cached airshipctl\n"
cp -r "$CACHE_DIR/*" "$ARTIFACTS_DIR"
else
printf "Waiting 30 seconds for the libvirt and docker services to be ready\n"
sleep 30
check_docker_readiness
repo_dir="$ARTIFACTS_DIR/airshipctl"
cloneRepo "$repo_dir" "$AIRSHIPCTL_REPO_URL" "$AIRSHIPCTL_REPO_REF"

@ -31,6 +31,7 @@ spec:
- name: libvirt
image: quay.io/airshipit/libvirt:aiap-v1
imagePullPolicy: IfNotPresent
securityContext:
privileged: true
#SYS_ADMIN required for systemd, need to work out reqs for libvirt
@ -80,6 +81,7 @@ spec:
- name: sushy
image: quay.io/metal3-io/sushy-tools
imagePullPolicy: IfNotPresent
command:
- bash
- -cex
@ -130,6 +132,7 @@ spec:
- name: nginx
image: nginx:latest
imagePullPolicy: IfNotPresent
command:
- bash
- -cex
@ -177,6 +180,7 @@ spec:
- name: dind
image: docker:stable-dind
imagePullPolicy: IfNotPresent
securityContext:
privileged: true
volumeMounts:
@ -195,6 +199,7 @@ spec:
- name: artifact-setup
image: quay.io/airshipit/aiap-artifact-setup:latest
imagePullPolicy: IfNotPresent
command:
- bash
- -cex
@ -248,6 +253,7 @@ spec:
- name: infra-builder
image: quay.io/airshipit/aiap-infra-builder:latest
imagePullPolicy: IfNotPresent
securityContext:
privileged: true
command:
@ -305,6 +311,7 @@ spec:
- name: runner
image: quay.io/airshipit/aiap-runner:latest
imagePullPolicy: IfNotPresent
command:
- bash
- -cex

@ -24,10 +24,32 @@ function cleanup() {
rm /tmp/healthy/infra-builder
fi
}
function check_libvirt_readiness() {
timeout=300
#add wait condition
end=$(($(date +%s) + $timeout))
echo "Waiting $timeout seconds for libvirt to be ready."
while true; do
if ( virsh version | grep 'library' ); then
echo "libvrit is now ready"
break
else
echo "libvirt is not ready"
fi
now=$(date +%s)
if [ $now -gt $end ]; then
echo -e "\n Libvirt failed to become ready within a reasonable timeframe."
exit 1
fi
sleep 10
done
}
trap cleanup EXIT
printf "Waiting 30 seconds for the libvirt and docker services to be ready\n"
sleep 30
check_libvirt_readiness
ansible-playbook -v /opt/ansible/playbooks/build-infra.yaml \
-e local_src_dir="$(pwd)"

Loading…
Cancel
Save