HostnameMap can result in partial replacement

Bug #1600209 reported by Steven Hardy
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Heat
Fix Released
High
Zane Bitter
tripleo
Fix Released
High
Steven Hardy

Bug Description

If you're using HostnameMap it's possible for the results to be wrong, consider:

parameter_defaults:
  HostnameMap:
    overcloud-controller-0: foo-a123-n1
    overcloud-controller-1: foo-a123-n2
...
    overcloud-compute-12: foo-b123-n13

In this situation, the str_replace in puppet/compute.yaml does a partial replacement of "overcloud-compute-12" so it ends up being "foo-a123-n22", which is clearly not what the author of the hostname map intended.

A workaround for this is probably to add a trailing character to the HostnameFormat parameter, e.g:

parameter_defaults:
  ComputeHostnameFormat: '%stackname%-novacompute-%index%X'
  HostnameMap:
    overcloud-controller-0X: foo-a123-n1
    overcloud-controller-1X: foo-a123-n2
...
    overcloud-compute-12X: foo-b123-n13

It'd be better if we could handle this inside the templates though

Steven Hardy (shardy)
Changed in tripleo:
assignee: nobody → Steven Hardy (shardy)
milestone: none → newton-3
status: New → Triaged
importance: Undecided → High
Revision history for this message
Giulio Fidente (gfidente) wrote :

We can't append a char by default in the templates though as it might break on upgrade

affects: tripleo → heat
Changed in heat:
milestone: newton-3 → none
Changed in tripleo:
importance: Undecided → High
status: New → Triaged
status: Triaged → Confirmed
assignee: nobody → Steven Hardy (shardy)
Changed in heat:
assignee: Steven Hardy (shardy) → Giulio Fidente (gfidente)
status: Triaged → In Progress
Changed in heat:
assignee: Giulio Fidente (gfidente) → Zane Bitter (zaneb)
Revision history for this message
Zane Bitter (zaneb) wrote :

Giulio's fix in Heat https://review.openstack.org/#/c/354856/ seems reasonable to me.

Revision history for this message
Steven Hardy (shardy) wrote :

+2 on the heat fix, thanks Giulio!

Changed in tripleo:
milestone: none → newton-3
Changed in heat:
milestone: none → newton-3
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to heat (master)

Reviewed: https://review.openstack.org/354856
Committed: https://git.openstack.org/cgit/openstack/heat/commit/?id=a2f5b5cb9ae74fb3262948b0cf1c23fc04c4b7cb
Submitter: Jenkins
Branch: master

commit a2f5b5cb9ae74fb3262948b0cf1c23fc04c4b7cb
Author: Giulio Fidente <email address hidden>
Date: Fri Aug 12 16:00:03 2016 -0400

    Perform str_replace trying to match longest string first

    Purpose is to avoid str_replace from doing partial replace
    when a shorter instance of a matching key is found.

    Change-Id: I63c13f4eb3b1375cb2df1a34fd4f09561564f400
    Co-Authored-By: Zane Bitter <email address hidden>
    Closes-Bug: 1600209

Changed in heat:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to heat (stable/mitaka)

Fix proposed to branch: stable/mitaka
Review: https://review.openstack.org/355921

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

Fix proposed to branch: stable/liberty
Review: https://review.openstack.org/355950

Revision history for this message
Emilien Macchi (emilienm) wrote :

Moving tripleo bug to released as I don't think there is anything to do in TripleO, since it was fixed in Heat itself.

Changed in tripleo:
status: Confirmed → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to heat (stable/mitaka)

Reviewed: https://review.openstack.org/355921
Committed: https://git.openstack.org/cgit/openstack/heat/commit/?id=a6878eea9b4172081934a2bc49b2a73f6fa36466
Submitter: Jenkins
Branch: stable/mitaka

commit a6878eea9b4172081934a2bc49b2a73f6fa36466
Author: Giulio Fidente <email address hidden>
Date: Fri Aug 12 16:00:03 2016 -0400

    Perform str_replace trying to match longest string first

    Purpose is to avoid str_replace from doing partial replace
    when a shorter instance of a matching key is found.

    Change-Id: I63c13f4eb3b1375cb2df1a34fd4f09561564f400
    Co-Authored-By: Zane Bitter <email address hidden>
    Closes-Bug: 1600209
    (cherry picked from commit a2f5b5cb9ae74fb3262948b0cf1c23fc04c4b7cb)

tags: added: in-stable-mitaka
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to heat (stable/liberty)

Reviewed: https://review.openstack.org/355950
Committed: https://git.openstack.org/cgit/openstack/heat/commit/?id=f32dbe7838c9cf9b935247a145bd55e806ea44b2
Submitter: Jenkins
Branch: stable/liberty

commit f32dbe7838c9cf9b935247a145bd55e806ea44b2
Author: Giulio Fidente <email address hidden>
Date: Fri Aug 12 16:00:03 2016 -0400

    Perform str_replace trying to match longest string first

    Purpose is to avoid str_replace from doing partial replace
    when a shorter instance of a matching key is found.

    Conflicts:
     heat/engine/hot/functions.py

    Change-Id: I63c13f4eb3b1375cb2df1a34fd4f09561564f400
    Co-Authored-By: Zane Bitter <email address hidden>
    Closes-Bug: 1600209
    (cherry picked from commit a2f5b5cb9ae74fb3262948b0cf1c23fc04c4b7cb)

tags: added: in-stable-liberty
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/heat 7.0.0.0b3

This issue was fixed in the openstack/heat 7.0.0.0b3 development milestone.

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

This issue was fixed in the openstack/heat 6.1.0 release.

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

This issue was fixed in the openstack/heat 5.0.2 release.

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

This issue was fixed in the openstack/heat 6.1.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.