run-os-net-config.sh script fails on IPv6 hostnames

Bug #1830274 reported by Dan Sneddon
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
tripleo
Fix Released
High
Dan Sneddon

Bug Description

When hostnames are used, and those hostnames resolve to an IPv6-only address, the run-os-net-config.sh script calls ping instead of ping6. IPv6 addresses are correctly identified, but since the hostname is not resolved, there is no way to know whether ping or ping6 should be used.

If the script resolved the hostname, it could use ping6 conditionally. For example:

function ping_metadata_ip() {
  local METADATA_IP=$(get_metadata_ip)

  if [ -n "$METADATA_IP" ] && ! is_local_ip $METADATA_IP; then

    echo -n "Trying to ping metadata IP ${METADATA_IP}..."

    _IP="$(getent hosts $METADATA_IP | awk '{ print $1 }')"
    _ping=ping
    if [[ "$_IP" =~ ":" ]] ; then
        _ping=ping6
    fi

    local COUNT=0
    until $_ping -c 1 $METADATA_IP &> /dev/null; do
      COUNT=$(( $COUNT + 1 ))
      if [ $COUNT -eq 10 ]; then
        echo "FAILURE"
        echo "$METADATA_IP is not pingable." >&2
        exit 1
      fi
    done
    echo "SUCCESS"

  else
    echo "No metadata IP found. Skipping."
  fi
}

Dan Sneddon (dsneddon)
Changed in tripleo:
assignee: nobody → Dan Sneddon (dsneddon)
importance: Undecided → High
status: New → Triaged
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to tripleo-heat-templates (master)

Fix proposed to branch: master
Review: https://review.opendev.org/661095

Changed in tripleo:
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to tripleo-heat-templates (master)

Reviewed: https://review.opendev.org/661095
Committed: https://git.openstack.org/cgit/openstack/tripleo-heat-templates/commit/?id=68bfc267286a9523f89a73718a7ed11cdc787a96
Submitter: Zuul
Branch: master

commit 68bfc267286a9523f89a73718a7ed11cdc787a96
Author: Dan Sneddon <email address hidden>
Date: Thu May 23 12:38:00 2019 -0700

    Fix run-os-net-config.sh to use ping6 for IPv6 hostnames

    The run-os-net-config.sh script checks to see if an IP address is
    IPv4 or IPv6, and uses ping or ping6 accordingly. This change also
    resolves hostnames and submits the resolved IP to the same test.
    If the hostname only resolves to an IPv6 address, then ping6 will
    be used.

    Change-Id: I9f37992157935b37cc9beb8a2f3b9d749a62bd1b
    Closes-bug: 1830274

Changed in tripleo:
status: In Progress → Fix Released
Changed in tripleo:
milestone: none → train-1
tags: added: queens-backport-potential
tags: added: rocky-backport-potential stein-backport-potential
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to tripleo-heat-templates (stable/stein)

Fix proposed to branch: stable/stein
Review: https://review.opendev.org/661393

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to tripleo-heat-templates (stable/queens)

Fix proposed to branch: stable/queens
Review: https://review.opendev.org/661587

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to tripleo-heat-templates (stable/rocky)

Fix proposed to branch: stable/rocky
Review: https://review.opendev.org/661588

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to tripleo-heat-templates (stable/stein)

Reviewed: https://review.opendev.org/661393
Committed: https://git.openstack.org/cgit/openstack/tripleo-heat-templates/commit/?id=3fddb7711d3fb8437a5bbe88754818881b2de3db
Submitter: Zuul
Branch: stable/stein

commit 3fddb7711d3fb8437a5bbe88754818881b2de3db
Author: Dan Sneddon <email address hidden>
Date: Thu May 23 12:38:00 2019 -0700

    Fix run-os-net-config.sh to use ping6 for IPv6 hostnames

    The run-os-net-config.sh script checks to see if an IP address is
    IPv4 or IPv6, and uses ping or ping6 accordingly. This change also
    resolves hostnames and submits the resolved IP to the same test.
    If the hostname only resolves to an IPv6 address, then ping6 will
    be used.

    Change-Id: I9f37992157935b37cc9beb8a2f3b9d749a62bd1b
    Closes-bug: 1830274
    (cherry picked from commit 68bfc267286a9523f89a73718a7ed11cdc787a96)

tags: added: in-stable-stein
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to tripleo-heat-templates (stable/queens)

Reviewed: https://review.opendev.org/661587
Committed: https://git.openstack.org/cgit/openstack/tripleo-heat-templates/commit/?id=2d9b9597176e5aa4faeb08e606fe8ea13e0f89ad
Submitter: Zuul
Branch: stable/queens

commit 2d9b9597176e5aa4faeb08e606fe8ea13e0f89ad
Author: Dan Sneddon <email address hidden>
Date: Thu May 23 12:38:00 2019 -0700

    Fix run-os-net-config.sh to use ping6 for IPv6 hostnames

    The run-os-net-config.sh script checks to see if an IP address is
    IPv4 or IPv6, and uses ping or ping6 accordingly. This change also
    resolves hostnames and submits the resolved IP to the same test.
    If the hostname only resolves to an IPv6 address, then ping6 will
    be used.

    Change-Id: I9f37992157935b37cc9beb8a2f3b9d749a62bd1b
    Closes-bug: 1830274
    (cherry picked from commit 68bfc267286a9523f89a73718a7ed11cdc787a96)

tags: added: in-stable-queens
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to tripleo-heat-templates (stable/rocky)

Reviewed: https://review.opendev.org/661588
Committed: https://git.openstack.org/cgit/openstack/tripleo-heat-templates/commit/?id=8e13d5778e5904f78e41d56ac17025f89ef2ad1e
Submitter: Zuul
Branch: stable/rocky

commit 8e13d5778e5904f78e41d56ac17025f89ef2ad1e
Author: Dan Sneddon <email address hidden>
Date: Thu May 23 12:38:00 2019 -0700

    Fix run-os-net-config.sh to use ping6 for IPv6 hostnames

    The run-os-net-config.sh script checks to see if an IP address is
    IPv4 or IPv6, and uses ping or ping6 accordingly. This change also
    resolves hostnames and submits the resolved IP to the same test.
    If the hostname only resolves to an IPv6 address, then ping6 will
    be used.

    Change-Id: I9f37992157935b37cc9beb8a2f3b9d749a62bd1b
    Closes-bug: 1830274
    (cherry picked from commit 68bfc267286a9523f89a73718a7ed11cdc787a96)
    (cherry picked from commit 3fddb7711d3fb8437a5bbe88754818881b2de3db)

tags: added: in-stable-rocky
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/tripleo-heat-templates 11.0.0

This issue was fixed in the openstack/tripleo-heat-templates 11.0.0 release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/tripleo-heat-templates 9.4.0

This issue was fixed in the openstack/tripleo-heat-templates 9.4.0 release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/tripleo-heat-templates 8.4.0

This issue was fixed in the openstack/tripleo-heat-templates 8.4.0 release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/tripleo-heat-templates 10.6.0

This issue was fixed in the openstack/tripleo-heat-templates 10.6.0 release.

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.