str_replace params can't be from parameters

Bug #1539737 reported by Steven Hardy
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Heat
Fix Released
Medium
Steven Hardy
Liberty
Fix Released
Undecided
Steven Hardy

Bug Description

I'd like to use get_param as an input to the params mapping of str_replace, but our validation prevents it:

"ERROR: "str_replace" parameters must be a mapping"

heat_template_version: 2016-04-08

parameters:
  HostnameMap:
    type: json
    default:
      overcloud-controller-0: stevespecial-xyz-123-controller-0

  Hostname:
    type: string
    default: overcloud-controller-0

outputs:
  the_output:
    value:
      str_replace:
        template: {get_param: Hostname}
        params: {get_param: HostnameMap}

It works fine when you disable the validation, so I think we need to relax the validation such that referencing another function is considered valid, or we validate later such that the function has been resolved.

Steven Hardy (shardy)
Changed in heat:
assignee: nobody → Steven Hardy (shardy)
status: New → Triaged
importance: Undecided → Medium
milestone: none → mitaka-3
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to heat (master)

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

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

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

commit 0d109b75d9a0d6e043bd8f513943d3d107050483
Author: Steven Hardy <email address hidden>
Date: Wed Feb 3 10:02:30 2016 +0000

    Allow str_replace to reference parameters/attributes

    Currently a validation error occurs if you attempt to reference
    via get_param or get_attr when using str_replace, however if
    we avoid the explicit validation in the constructor it actually
    works fine, and we already have a validation to handle any
    invalid input elsewhere in the function definition.

    Change-Id: Ib934f443a8b8e4f75335a9d8b992e7f86791aa45
    Closes-Bug: #1539737

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

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

Steven Hardy (shardy)
tags: added: liberty-backport-potential
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/282403

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to heat (master)

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

commit 0b8d03a840c3070f3ffecd093adff6a7f1a02c33
Author: Steven Hardy <email address hidden>
Date: Fri Feb 19 15:30:53 2016 +0000

    Re-add str_replace parameter validation, and fix test

    This partially reverts https://review.openstack.org/#/c/275602/, which
    removed the validation of the parameters argument completely, but a
    comment added post-merge rightly points out that we can just check for
    a map or function and still fix the bug.

    Also, it seems that we had an existing test which failed to catch the
    fact that this didn't work, so fix that to prove the expected
    behavior works in the context of a stack, not just when resolving a
    function snippet, and add a test which proves the reinstated
    constructor validation works as expected.

    Change-Id: I21c1868061e37760e1cb27f44ebb7c4ee97fefef
    Partial-Bug: #1539737

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

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

commit 6b8d8ba2f9a9a117581840194cb8c6ce8d117f7a
Author: Steven Hardy <email address hidden>
Date: Wed Feb 3 10:02:30 2016 +0000

    Allow str_replace to reference parameters/attributes

    Currently a validation error occurs if you attempt to reference
    via get_param or get_attr when using str_replace, however if
    we avoid the explicit validation in the constructor it actually
    works fine, and we already have a validation to handle any
    invalid input elsewhere in the function definition.

    This is a combination of two commits,
    0d109b75d9a0d6e043bd8f513943d3d107050483 and
    0b8d03a840c3070f3ffecd093adff6a7f1a02c33 - the latter fixed
    some issues with the initial patch and test.

    Closes-Bug: #1539737
    (cherry picked from commit 0d109b75d9a0d6e043bd8f513943d3d107050483
    and commit 0b8d03a840c3070f3ffecd093adff6a7f1a02c33)
    Change-Id: Ib934f443a8b8e4f75335a9d8b992e7f86791aa45

Revision history for this message
Thierry Carrez (ttx) wrote : Fix included in openstack/heat 6.0.0.0b3

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

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.

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.