vino-builder wait for dynamic data

This patchset adds a wait loop in the entrypoint.sh for
vino-builder to wait for dynamic data to be available before
continuing with its processing. Since dynamic data will be
specific to a node (e.g., mac addresses), VINO will pass
these values via Kubernetes node annotations.

This patchset also comments out the playbook step to set
libivirt domains to running. In practice that will be done
in a later stage by VINO.

Change-Id: Ic6ec82b4aecf527ce329b4cb620418821efc0246
This commit is contained in:
Crank, Daniel (dc6350) 2021-04-07 10:33:52 -05:00
parent 7a99dea948
commit 0e63d43d0b
2 changed files with 32 additions and 7 deletions

View File

@ -14,6 +14,7 @@
set -ex set -ex
# wait for libvirt socket to be ready
TIMEOUT=300 TIMEOUT=300
while [[ ! -e /var/run/libvirt/libvirt-sock ]]; do while [[ ! -e /var/run/libvirt/libvirt-sock ]]; do
if [[ ${TIMEOUT} -gt 0 ]]; then if [[ ${TIMEOUT} -gt 0 ]]; then
@ -26,10 +27,34 @@ while [[ ! -e /var/run/libvirt/libvirt-sock ]]; do
fi fi
done done
# wait for dynamic data to be ready
# data is node-specific, so it will be passed as a node annotations
# of the form
# metadata:
# annotations:
# airshipit.org/vino.network-values: |
# bunch-of-yaml
DYNAMIC_DATA_FILE=/var/lib/vino-builder/dynamic.yaml
TIMEOUT=300
while [[ ${TIMEOUT} -gt 0 ]]; do
let TIMEOUT-=10
if [[ ${TIMEOUT} -le 0 ]]; then
echo "ERROR: vino-builder dynamic data was not ready in time"
exit 1
fi
kubectl get node $HOSTNAME -o=jsonpath="{.metadata.annotations.airshipit\.org/vino\.network-values}" > $DYNAMIC_DATA_FILE
if [[ -s $DYNAMIC_DATA_FILE ]]; then
break
fi
echo "vino-builder dynamic data not ready yet - sleeping for 10 seconds..."
sleep 10
done
ansible-playbook -v \ ansible-playbook -v \
-e @/vino/spec \ -e @/vino/spec \
-e @/var/lib/vino-builder/flavors/flavors.yaml \ -e @/var/lib/vino-builder/flavors/flavors.yaml \
-e @/var/lib/vino-builder/flavor-templates/flavor-templates.yaml \ -e @/var/lib/vino-builder/flavor-templates/flavor-templates.yaml \
-e @/var/lib/vino-builder/network-templates/network-templates.yaml \ -e @/var/lib/vino-builder/network-templates/network-templates.yaml \
-e @/var/lib/vino-builder/storage-templates/storage-templates.yaml \ -e @/var/lib/vino-builder/storage-templates/storage-templates.yaml \
-e @$DYNAMIC_DATA_FILE \
/playbooks/vino-builder.yaml /playbooks/vino-builder.yaml

View File

@ -43,10 +43,10 @@
virsh define /tmp/domain-{{item}}.xml virsh define /tmp/domain-{{item}}.xml
loop: "{{ range(0,node.count)|list }}" loop: "{{ range(0,node.count)|list }}"
- name: set vm to running #- name: set vm to running
virt: # virt:
name: "{{ node.name + '-' + item|string}}" # name: "{{ node.name + '-' + item|string}}"
state: running # state: running
autostart: yes # autostart: yes
loop: "{{ range(0,node.count)|list }}" # loop: "{{ range(0,node.count)|list }}"
ignore_errors: true # ignore_errors: true