Overcloud deploy failing due to "Invalid input for dns_nameservers" when passing overcloud_dns_servers parameter

Bug #1737555 reported by Jose Luis Franco
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
tripleo
Invalid
Medium
Jose Luis Franco

Bug Description

Description
===========

After this patch got merged https://github.com/openstack/tripleo-quickstart-extras/commit/793a5dcdf41c802d6348dbbbfea1a50b436206fa overcloud deploy using #oooq is failing when passing the overcloud_dns_servers.

The content of the parameters is as follows:

overcloud_dns_servers: '10.16.36.29'

After running quickstart.sh passing also the parameter, we get the following error:

Monday 11 December 2017 07:17:22 -0500 (0:00:18.130) 1:30:42.002 *******
fatal: [undercloud]: FAILED! => {"changed": true, "cmd": "set -o pipefail && /home/stack/overcloud-prep-network.sh 2>&1 | awk '{ print strftime(\"%Y-%m-%d %H:%M:%S |\"), $0; fflush(); }' > /home/stack/overcloud_prep_network.log", "delta": "0:00:20.134238", "end": "2017-12-11 12:17:52.096923", "failed": true, "msg": "non-zero return code", "rc": 1, "start": "2017-12-11 12:17:31.962685", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}

If we go to check the script content, we can see that the whole IP has been split per character and passed as a --dns-nameserver option:

## * Set the DNS server in the control plane network
## ::

    CTLPLANE_SUBNET=$(openstack subnet show ctlplane-subnet -f value -c id)
    neutron subnet-update $CTLPLANE_SUBNET \
         --dns-nameserver "1" --dns-nameserver "0" --dns-nameserver "." --dns-nameserver "1" --dns-nameserver "6" --dns-nameserver "." --dns-nameserver "3" --dns-nameserver "6" --dns-nameserver "." --dns-nameserver "2" --dns-nameserver "9"

Steps to reproduce
==================

git clone https://github.com/openstack/tripleo-quickstart
chmod u+x ./tripleo-quickstart/quickstart.sh
printf "\n\nSee:\n./tripleo-quickstart/quickstart.sh --help for a full list of options\n\n"
bash ./tripleo-quickstart/quickstart.sh --install-deps

export VIRTHOST=127.0.0.2
export CONFIG=~/deploy-config.yaml

cat > $CONFIG << EOF

# undercloud_undercloud_hostname: undercloud.ratata-domain

# control_memory: 8192
# compute_memory: 6120

# undercloud_memory: 10240
# undercloud_vcpu: 4
# undercloud_workers: 3

# default_vcpu: 1

custom_nameserver: '10.16.36.29'
undercloud_undercloud_nameservers: '10.16.36.29'
overcloud_dns_servers: '10.16.36.29'

# node_count: 4

# overcloud_nodes:
# - name: control_0
# flavor: control
# virtualbmc_port: 6230
# - name: control_1
# flavor: control
# virtualbmc_port: 6231
# - name: control_2
# flavor: control
# virtualbmc_port: 6232
# - name: compute_0
# flavor: compute
# virtualbmc_port: 6233

# topology: >-
# --control-scale 3
# --compute-scale 1

extra_args: >-
  --libvirt-type qemu
  --ntp-server pool.ntp.org
# -e /usr/share/openstack-tripleo-heat-templates/environments/puppet-pacemaker.yaml

run_tempest: false
EOF

bash ./tripleo-quickstart/quickstart.sh \
                --clean \
                --release master \
                --teardown all \
                --tags all \
                -e @$CONFIG \
                $VIRTHOST

Tags: quickstart
Changed in tripleo:
milestone: none → queens-3
status: New → Triaged
importance: Undecided → Medium
tags: added: quickstart
Revision history for this message
Jose Luis Franco (jfrancoa) wrote :

Testing it locally in a python virtual environment I get the same result:

>>> tmpl = '''
... CTLPLANE_SUBNET=$(openstack subnet show ctlplane-subnet -f value -c id)
... neutron subnet-update $CTLPLANE_SUBNET \
... {% for nameserver in overcloud_dns_servers %} --dns-nameserver "{{ nameserver }}" {% endfor %}'''
>>> from jinja2 import Template
>>> template = Template(tmpl)
>>> print template.render({'overcloud_dns_servers': '10.16.36.29'})

    CTLPLANE_SUBNET=$(openstack subnet show ctlplane-subnet -f value -c id)
    neutron subnet-update $CTLPLANE_SUBNET --dns-nameserver "1" --dns-nameserver "0" --dns-nameserver "." --dns-nameserver "1" --dns-nameserver "6" --dns-nameserver "." --dns-nameserver "3" --dns-nameserver "6" --dns-nameserver "." --dns-nameserver "2" --dns-nameserver "9"

In the documentation is stated that the "overcloud_dns_servers" is a list, but it can easily happen that the user will add the dns server as a single string. So either we warn of the error, or we protect the code by cheking if the input is iterable and it's not string, in any other case add only one --dns-nameserver parameter:

>>> tmpl = '''
... CTLPLANE_SUBNET=$(openstack subnet show ctlplane-subnet -f value -c id)
... {% if overcloud_dns_servers is iterable and overcloud_dns_servers is not string %}{% for nameserver in overcloud_dns_servers %} --dns-nameserver "{{ nameserver|e }}" {% endfor %}{% else %} --dns-nameserver "{{ overcloud_dns_servers }}" {% endif %}'''
>>>
>>> template = Template(tmpl)
>>> print template.render({'overcloud_dns_servers': "10.16.36.29"})

    CTLPLANE_SUBNET=$(openstack subnet show ctlplane-subnet -f value -c id)
         --dns-nameserver "10.16.36.29"
>>> print template.render({'overcloud_dns_servers': ["10.16.36.29", "10.15.14.34"]})

    CTLPLANE_SUBNET=$(openstack subnet show ctlplane-subnet -f value -c id)
         --dns-nameserver "10.16.36.29" --dns-nameserver "10.15.14.34"

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to tripleo-quickstart-extras (master)

Fix proposed to branch: master
Review: https://review.openstack.org/527334

Changed in tripleo:
assignee: nobody → Jose Luis Franco (jfrancoa)
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on tripleo-quickstart-extras (master)

Change abandoned by Jose Luis Franco (<email address hidden>) on branch: master
Review: https://review.openstack.org/527334

Revision history for this message
Jose Luis Franco (jfrancoa) wrote :

It's clearly stated in the documentation that the parameter should be a list. Another point is the need of some variable type verification, but in this case there is not a real bug.

Changed in tripleo:
status: In Progress → Invalid
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix proposed to tripleo-quickstart-extras (master)

Related fix proposed to branch: master
Review: https://review.openstack.org/555227

Revision history for this message
Bogdan Dobrelya (bogdando) wrote :

Submitted a related fix for custom_namserver must be a list as well. We have a few places defaulting like that: overcloud_dns_servers: "{{ custom_nameserver }}"

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix merged to tripleo-quickstart-extras (master)

Reviewed: https://review.openstack.org/555227
Committed: https://git.openstack.org/cgit/openstack/tripleo-quickstart-extras/commit/?id=fd0d70e44f4b44a49c7744161f98028a0240fe33
Submitter: Zuul
Branch: master

commit fd0d70e44f4b44a49c7744161f98028a0240fe33
Author: Bogdan Dobrelya <email address hidden>
Date: Thu Mar 22 10:54:06 2018 +0100

    Fix custom_nameserver must be a list

    Fix undercloud-setup docs and defaults for custom_nameserver.
    When it is not a list,
    undercloud-setup/templates/ovb-undercloud-connectivity.sh.j2#n59
    produces bad values treating each symbol of a string as a nameserver.

    Related-bug: #1737555

    Change-Id: I413ab6cbfbeb99fff5e6eb9f98077b18fa8bfab8
    Signed-off-by: Bogdan Dobrelya <email address hidden>

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.