From a4503a28acd30ca640821ec884100c614cab8cb4 Mon Sep 17 00:00:00 2001 From: Mingyuan Qi Date: Thu, 12 Dec 2019 02:41:34 +0000 Subject: [PATCH] Check return value of get subnets before iterate for ironic With the update of openstack clients within heat image: openstack client >= 4.0.0 neutron client >= 6.14.0 neturon lib >= 1.29.1 The command 'openstack network show ${network} -f value -c subnets' returns '[]' instead of null string if no subnets found in the specific network. This commit adds a check logic to avoid subsequent command returns error by using '[]' as subnet input. Change-Id: I695e504518e1c884c7d66ecc94c9fa8787ce9752 Closes-Bug: 1855319 Signed-off-by: Mingyuan Qi --- openstack-helm/centos/openstack-helm.spec | 2 + ...ue-of-get-subnets-before-iterate-for.patch | 52 +++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 openstack-helm/files/0008-Check-return-value-of-get-subnets-before-iterate-for.patch diff --git a/openstack-helm/centos/openstack-helm.spec b/openstack-helm/centos/openstack-helm.spec index 1b149be2..6c11db0c 100644 --- a/openstack-helm/centos/openstack-helm.spec +++ b/openstack-helm/centos/openstack-helm.spec @@ -26,6 +26,7 @@ Patch04: 0004-Nova-chart-Support-ephemeral-pool-creation.patch Patch05: 0005-Nova-Add-support-for-disabling-Readiness-Liveness-pr.patch Patch06: 0006-Add-Placement-Chart.patch Patch07: 0007-Support-ingress-creation-for-keystone-admin-endpoint.patch +Patch08: 0008-Check-return-value-of-get-subnets-before-iterate-for.patch BuildRequires: helm BuildRequires: openstack-helm-infra @@ -43,6 +44,7 @@ Openstack Helm charts %patch05 -p1 %patch06 -p1 %patch07 -p1 +%patch08 -p1 %build # initialize helm and build the toolkit diff --git a/openstack-helm/files/0008-Check-return-value-of-get-subnets-before-iterate-for.patch b/openstack-helm/files/0008-Check-return-value-of-get-subnets-before-iterate-for.patch new file mode 100644 index 00000000..fe372870 --- /dev/null +++ b/openstack-helm/files/0008-Check-return-value-of-get-subnets-before-iterate-for.patch @@ -0,0 +1,52 @@ +From 29a7eea2465284bc5ed5a8f95bc14d6c6c9f0e5e Mon Sep 17 00:00:00 2001 +From: Mingyuan Qi +Date: Wed, 11 Dec 2019 08:48:09 +0000 +Subject: [PATCH] Check return value of get subnets before iterate for ironic + +With the update of openstack clients: +openstack client >= 4.0.0 +neutron client >= 6.14.0 +neturon lib >= 1.29.1 + +The command 'openstack network show ${network} -f value -c subnets' +returns '[]' instead of null string if no subnets found in the +specific network. This commit adds a check logic to avoid subsequent +command returns error by using '[]' as subnet input. + +Change-Id: I7e7d5209227b0e34131b7715dbd3faa6066a94b7 +Signed-off-by: Mingyuan Qi +--- + ironic/templates/bin/_manage-cleaning-network.sh.tpl | 17 ++++++++++------- + 1 file changed, 10 insertions(+), 7 deletions(-) + +diff --git a/ironic/templates/bin/_manage-cleaning-network.sh.tpl b/ironic/templates/bin/_manage-cleaning-network.sh.tpl +index 47381a1..2a2af3a 100644 +--- a/ironic/templates/bin/_manage-cleaning-network.sh.tpl ++++ b/ironic/templates/bin/_manage-cleaning-network.sh.tpl +@@ -28,13 +28,16 @@ else + IRONIC_NEUTRON_CLEANING_NET_ID=$(openstack network show ${neutron_network_name} -f value -c id) + fi + +-for SUBNET in $(openstack network show $IRONIC_NEUTRON_CLEANING_NET_ID -f value -c subnets); do +- CURRENT_SUBNET=$(openstack subnet show $SUBNET -f value -c name) +- if [ "x${CURRENT_SUBNET}" == "x${neutron_subnet_name}" ]; then +- openstack subnet show ${neutron_subnet_name} +- SUBNET_EXISTS=true +- fi +-done ++SUBNETS=$(openstack network show $IRONIC_NEUTRON_CLEANING_NET_ID -f value -c subnets) ++if [ "x${SUBNETS}" != "x[]" ]; then ++ for SUBNET in ${SUBNETS}; do ++ CURRENT_SUBNET=$(openstack subnet show $SUBNET -f value -c name) ++ if [ "x${CURRENT_SUBNET}" == "x${neutron_subnet_name}" ]; then ++ openstack subnet show ${neutron_subnet_name} ++ SUBNET_EXISTS=true ++ fi ++ done ++fi + + if [ "x${SUBNET_EXISTS}" != "xtrue" ]; then + openstack subnet create \ +-- +1.8.3.1 +