Validation fails for RouterInterface resource

Bug #1451819 reported by Oleksii Chuprykov
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Heat
Fix Released
Medium
Oleksii Chuprykov
Kilo
Fix Released
Medium
Angus Salkeld

Bug Description

The following template fails to be validated by heat:

heat_template_version: 2013-05-23

description: HOT template to create Neutron network.

parameters:
  ext_network:
    type: string
    description: External network for getting floating IPs

resources:
  server_port:
    type: OS::Neutron::Port
    properties:
      name: the_port
      network: {get_attr: [internal_network, name]}
      fixed_ips:
        - subnet: {get_attr: [internal_subnet, name] }

  internal_network:
    type: OS::Neutron::Net
    properties:
        name: the_internal_network

  internal_subnet:
    type: OS::Neutron::Subnet
    properties:
      name: the_internal_subnet
      network: {get_attr: [internal_network, name]}
      ip_version: 4
      cidr: 10.0.3.0/24
      allocation_pools:
        - {start: 10.0.3.20, end: 10.0.3.150}

  router:
    type: OS::Neutron::Router
    properties:
      name: the_router
      external_gateway_info:
        network: {get_param: ext_network}

  router_interface:
    type: OS::Neutron::RouterInterface
    properties:
      router: {get_attr: [router, name]}
      subnet: {get_resource: internal_subnet}

  floating_ip:
    type: OS::Neutron::FloatingIP
    properties:
      floating_network: {get_param: ext_network}

  floating_ip_assoc:
    type: OS::Neutron::FloatingIPAssociation
    properties:
      floatingip_id: {get_resource: floating_ip}
      port_id: {get_resource: server_port}

Traceback (most recent call last):
  File "/opt/stack/heat/heat_integrationtests/scenario/test_neutron_net.py", line 42, in test_resource_ref_by_names
  File "/opt/stack/heat/heat_integrationtests/scenario/scenario_base.py", line 55, in launch_stack
    expected_status=expected_status
  File "/opt/stack/heat/heat_integrationtests/common/test.py", line 405, in stack_create
    environment=env
  File "/opt/stack/python-heatclient/heatclient/v1/stacks.py", line 135, in create
    data=kwargs, headers=headers)
  File "/opt/stack/python-heatclient/heatclient/common/http.py", line 265, in json_request
    resp = self._http_request(url, method, **kwargs)
  File "/opt/stack/python-heatclient/heatclient/common/http.py", line 220, in _http_request
    raise exc.from_response(resp)
HTTPBadRequest: ERROR: At least one of the following properties must be specified: router, router_id

Changed in heat:
assignee: nobody → Oleksii Chuprykov (ochuprykov)
Revision history for this message
Thomas Herve (therve) wrote :

That's a poorly described bug. Can you redefine precisely how validation fails? And at least add a description? Thanks.

Revision history for this message
Oleksii Chuprykov (ochuprykov) wrote :

Create the stack with provided template. Stack creation will fail with the message 'At least one of the following properties must be specified: router, router_id'. The problem is in the creation of router_interface: for some reason `get_attr` function doesn't work properly for getting `name` attribute of the router resource.

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/180159

Changed in heat:
status: New → In Progress
Thomas Herve (therve)
summary: - resource validation fails
+ Validation fails for RouterInterface resource
description: updated
Revision history for this message
Steve Baker (steve-stevebaker) wrote :

You shouldn't be using the router name, try this instead:

  router_interface:
    type: OS::Neutron::RouterInterface
    properties:
      router: {get_resource: router}
      subnet: {get_resource: internal_subnet}

Changed in heat:
status: In Progress → Incomplete
Revision history for this message
Rabi Mishra (rabi) wrote :

I agree with stevebaker. We should not use it like the way in the mentioned template. We added usage of the id/name for portability of templates across deployments for existing resources and not for this kind of usage. Please use get_resource when it's possible.

Revision history for this message
Oleksii Chuprykov (ochuprykov) wrote :

I know about getting resource by get_resource. But i see that get_attr logic doesn't work only for router_interface. Would be nice to make it work at least for consistency?

Revision history for this message
Steve Baker (steve-stevebaker) wrote :

No, we really don't want {get_attr: [resource, name]} to become established as an accepted pattern

Revision history for this message
Steve Baker (steve-stevebaker) wrote :

Can I mark this bug as Invalid now?

Revision history for this message
Oleksii Chuprykov (ochuprykov) wrote :

Btw, this patch https://review.openstack.org/#/c/145125/ seems do the same thing. Why such changes are needed there, but do not need here?

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

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

commit 0fbb16e6fc2c0314a183e125b74656730219caa8
Author: Oleksii Chuprykov <email address hidden>
Date: Tue May 5 09:31:16 2015 -0400

    Fix RouterInterface properties validation

    get_attr on a non-created resource returns an empty string
    (rather than None). We should pass validation in this case.

    Change-Id: I5a1d651cc7dc46162140210ebeacaa7519111c91
    Closes-bug: 1451819

Changed in heat:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in heat:
milestone: none → liberty-1
status: Fix Committed → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to heat (stable/kilo)

Fix proposed to branch: stable/kilo
Review: https://review.openstack.org/222086

Angus Salkeld (asalkeld)
Changed in heat:
importance: Undecided → Medium
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to heat (stable/kilo)

Reviewed: https://review.openstack.org/222086
Committed: https://git.openstack.org/cgit/openstack/heat/commit/?id=92d2ac9b84cacda3f00e3b3d4d544a4d450683bd
Submitter: Jenkins
Branch: stable/kilo

commit 92d2ac9b84cacda3f00e3b3d4d544a4d450683bd
Author: Oleksii Chuprykov <email address hidden>
Date: Tue May 5 09:31:16 2015 -0400

    Fix RouterInterface properties validation

    get_attr on a non-created resource returns an empty string
    (rather than None). We should pass validation in this case.

    Change-Id: I5a1d651cc7dc46162140210ebeacaa7519111c91
    Closes-bug: 1451819
    (cherry picked from commit 0fbb16e6fc2c0314a183e125b74656730219caa8)

Thierry Carrez (ttx)
Changed in heat:
milestone: liberty-1 → 5.0.0
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.