From 0e63d43d0bb64890144768240a700f696f792c77 Mon Sep 17 00:00:00 2001 From: "Crank, Daniel (dc6350)" Date: Wed, 7 Apr 2021 10:33:52 -0500 Subject: [PATCH] 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 --- vino-builder/assets/entrypoint.sh | 25 +++++++++++++++++++ .../roles/libvirt/tasks/create-domain.yaml | 14 +++++------ 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/vino-builder/assets/entrypoint.sh b/vino-builder/assets/entrypoint.sh index 7707c97..d4ddc70 100644 --- a/vino-builder/assets/entrypoint.sh +++ b/vino-builder/assets/entrypoint.sh @@ -14,6 +14,7 @@ set -ex +# wait for libvirt socket to be ready TIMEOUT=300 while [[ ! -e /var/run/libvirt/libvirt-sock ]]; do if [[ ${TIMEOUT} -gt 0 ]]; then @@ -26,10 +27,34 @@ while [[ ! -e /var/run/libvirt/libvirt-sock ]]; do fi 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 \ -e @/vino/spec \ -e @/var/lib/vino-builder/flavors/flavors.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/storage-templates/storage-templates.yaml \ + -e @$DYNAMIC_DATA_FILE \ /playbooks/vino-builder.yaml \ No newline at end of file diff --git a/vino-builder/assets/playbooks/roles/libvirt/tasks/create-domain.yaml b/vino-builder/assets/playbooks/roles/libvirt/tasks/create-domain.yaml index a81f90e..f6768f5 100644 --- a/vino-builder/assets/playbooks/roles/libvirt/tasks/create-domain.yaml +++ b/vino-builder/assets/playbooks/roles/libvirt/tasks/create-domain.yaml @@ -43,10 +43,10 @@ virsh define /tmp/domain-{{item}}.xml loop: "{{ range(0,node.count)|list }}" -- name: set vm to running - virt: - name: "{{ node.name + '-' + item|string}}" - state: running - autostart: yes - loop: "{{ range(0,node.count)|list }}" - ignore_errors: true +#- name: set vm to running +# virt: +# name: "{{ node.name + '-' + item|string}}" +# state: running +# autostart: yes +# loop: "{{ range(0,node.count)|list }}" +# ignore_errors: true