Fix an error while getting Pod's nodeName when setting up VMs with vbmc

Currently, in the script which sets up VMs with vmbc instead of BM for ironic
practice,

There is an IF command checking if OVS_VSWITCHD pod is located in master
node or not.

To get the info about Pod's nodeName, command below has been used.

$ kubectl --namespace openstack get pod "${OVS_VSWITCHD_POD}" -o wide --no-headers | awk '{ print $NF }'

But this command sometimes cannot parse Pod's nodeName correctly becuase
new headers such as "NOMINATED NODE" and "READINESS GATE" are printed in the end "-o wide" option.
(in some version of k8s)

To avoid this problem and give more readability,
I suggest changing commands to use "-o json" option.

Change-Id: Ib81ae505ac8d04dae9af6326880e1fa17664ac0b
This commit is contained in:
jlego229-kim 2019-07-12 14:13:15 +09:00
parent 48dcc644f7
commit 62b12e3af5

View File

@ -94,7 +94,7 @@ OVS_VSWITCHD_PODS=$(kubectl get --namespace openstack pods \
for OVS_VSWITCHD_POD in ${OVS_VSWITCHD_PODS}; do
kubectl exec --namespace openstack "${OVS_VSWITCHD_POD}" \
-- ovs-vsctl add-br "${OSH_IRONIC_PXE_DEV}"
if [ "x$(kubectl --namespace openstack get pod "${OVS_VSWITCHD_POD}" -o wide --no-headers | awk '{ print $NF }')" == "x$(hostname -f)" ] ; then
if [ "x$(kubectl --namespace openstack get pod "${OVS_VSWITCHD_POD}" -o json | jq -r '.spec.nodeName')" == "x$(hostname -f)" ] ; then
COUNTER=0
for NODE_IP in ${NODE_IPS}; do
if ! [ "x${MASTER_IP}" == "x${NODE_IP}" ]; then