From: Andrew Grimberg Date: Fri, 8 Nov 2019 18:33:48 +0000 (-0800) Subject: Fix OpenStack image validation for multi-cloud X-Git-Tag: v0.48.0~1 X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F06%2F62206%2F2;p=releng%2Fglobal-jjb.git Fix OpenStack image validation for multi-cloud While working on getting FDio setup to use the OpenStack cloud configuration we found that the validation script does not operate properly against a multi-OS cloud configuration Change-Id: Idfe5ca2a060bc0f696cc1479e1ec3d40318e3c29 Signed-off-by: Andrew Grimberg --- diff --git a/jjb/lf-ci-jobs.yaml b/jjb/lf-ci-jobs.yaml index 5be402cf..9f12231f 100644 --- a/jjb/lf-ci-jobs.yaml +++ b/jjb/lf-ci-jobs.yaml @@ -408,7 +408,6 @@ disable-job: false git-url: "$GIT_URL/$GERRIT_PROJECT" github-url: "https://github.com" - openstack-cloud: vex submodule-timeout: 10 submodule-disable: false @@ -466,8 +465,6 @@ builders: - lf-infra-pre-build - - inject: - properties-content: OS_CLOUD={openstack-cloud} - shell: !include-raw-escape: ../shell/jenkins-verify-images.sh publishers: diff --git a/releasenotes/notes/fix-multi-cloud-validator-d6edcb309e5f02e0.yaml b/releasenotes/notes/fix-multi-cloud-validator-d6edcb309e5f02e0.yaml new file mode 100644 index 00000000..b41e9571 --- /dev/null +++ b/releasenotes/notes/fix-multi-cloud-validator-d6edcb309e5f02e0.yaml @@ -0,0 +1,13 @@ +--- +fixes: + - | + Multi-cloud image validation was not properly working as we force set the + OS_CLOUD environment variable before validation of images. This has been + rectified to dynamicaly modify the OS_CLOUD variable based upon the + cloud.cfg that will be used to define the cloud in Jenkins. + - | + We now validate that a cloud.cfg file exists for any defined OpenStack + cloud. + - | + Removes undocumented, and now unneeded, openstack-cloud variable from the + jenkins-cfg-verify job definition diff --git a/shell/jenkins-verify-images.sh b/shell/jenkins-verify-images.sh index 75453232..f05e3c35 100755 --- a/shell/jenkins-verify-images.sh +++ b/shell/jenkins-verify-images.sh @@ -16,21 +16,40 @@ set -eux -o pipefail error=false -for file in jenkins-config/clouds/openstack/*/*; do - # Set the $IMAGE_NAME variable to the the file's IMAGE_NAME value - export "$(grep ^IMAGE_NAME= "$file")" - # The image should be listed as active +verify_images() +{ + echo "Verifying images on $1" + for file in "$1"/*; do + # Set the $IMAGE_NAME variable to the the file's IMAGE_NAME value + export "$(grep ^IMAGE_NAME= "$file")" + # The image should be listed as active - if ! openstack image list --property name="$IMAGE_NAME" | grep "active"; then - echo "ERROR: No matching image found for $IMAGE_NAME" - error=true - fi - # Set the $HARDWARE_ID variable to the the file's HARDWARE_ID value - export "$(grep ^HARDWARE_ID= "$file")" - # The flavor should be listed. Spaces in grep string ensure complete match. + if ! openstack image list --property name="$IMAGE_NAME" | grep "active"; then + echo "ERROR: No matching image found for $IMAGE_NAME" + error=true + fi + # Set the $HARDWARE_ID variable to the the file's HARDWARE_ID value + export "$(grep ^HARDWARE_ID= "$file")" + # The flavor should be listed. Spaces in grep string ensure complete match. + + if ! openstack flavor list | grep " $HARDWARE_ID "; then + echo "ERROR: No matching flavor found for $HARDWARE_ID" + error=true + fi + done +} + +for cloud in jenkins-config/clouds/openstack/*; do + echo "Verifying that cloud has a master configuration file" + # Verify that we have a cloud config file + if [ -f "$cloud/cloud.cfg" ]; then + # Get the OS_CLOUD variable from cloud config and export it + OS_CLOUD=$(grep ^CLOUD_CREDENTIAL_ID= "$cloud/cloud.cfg" | cut -d'=' -f2) + export OS_CLOUD - if ! openstack flavor list | grep " $HARDWARE_ID "; then - echo "ERROR: No matching flavor found for $HARDWARE_ID" + verify_images "$cloud" + else + echo "ERROR: No cloud.cfg for $cloud" error=true fi done