From 89fc4fa2792ef256ff7624559a8ea8e2ee2f13fc Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Wed, 24 May 2023 14:44:55 +0100 Subject: [PATCH] dev: Improve error checking for config check functions Various functions in the development/testing scripts rely on 'kayobe configuration dump' to extract the value of flags. If this command fails for any reason, we should exit the script. Currently, some places we continue and return 1, since we check the output against the string 'true'. The to_bool helper function handles failure by checking for a valid boolean output, so let's use that everywhere. Change-Id: I3a5a43fef9c3d68d0db02be12b9f892c437e513d --- dev/functions | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/dev/functions b/dev/functions index 3eda21475..5839cb38a 100644 --- a/dev/functions +++ b/dev/functions @@ -233,17 +233,22 @@ function upgrade_kayobe_venv { function is_deploy_image_built_locally { ipa_build_images=$(kayobe configuration dump --host controllers[0] --var-name ipa_build_images) - [[ $ipa_build_images =~ ^true$ ]] + to_bool "$ipa_build_images" } function is_ironic_enabled { ironic_enabled=$(kayobe configuration dump --host controllers[0] --var-name kolla_enable_ironic) - [[ $ironic_enabled =~ ^true$ ]] + to_bool "$ironic_enabled" } function is_overcloud_host_image_built_by_dib { overcloud_dib_build_host_images=$(kayobe configuration dump --host controllers[0] --var-name overcloud_dib_build_host_images) - [[ $overcloud_dib_build_host_images =~ ^true$ ]] + to_bool "$overcloud_dib_build_host_images" +} + +function is_cinder_enabled { + flag="$(run_kayobe configuration dump --host controllers[0] --var-name kolla_enable_cinder)" + to_bool "$flag" } function environment_setup { @@ -854,11 +859,6 @@ function to_bool { fi } -function is_cinder_enabled { - flag="$(run_kayobe configuration dump --host controllers[0] --var-name kolla_enable_cinder)" - to_bool "$flag" -} - function configure_iptables { # NOTE(wszumski): adapted from the ironic devstack plugin, see: # https://github.com/openstack/ironic/blob/36e87dc5b472d79470b783fbba9ce396e3cbb96e/devstack/lib/ironic#L2132