resource validation fails before a dependant resource is created

Bug #1407392 reported by Removed by request
16
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Heat
Fix Released
High
Angus Salkeld
Juno
Fix Released
High
Zane Bitter

Bug Description

stack-create fails for validating a resource with missing attributes:

# heat stack-create -f caller.yaml -e envi.yaml
ERROR: Failed to validate: At least one of the following properties must be specified: subnet, subnet_id

This template creates network resources in a nested template and load balancer resources in a different nested template.
The 'network; template returnes an attribute called private_subnet_id that is later being used (or should be used) by Neutron::Pool in the 'load balancer' template'.
However on validation, validating Neutron::Pool fails validation because the subnet_id parameter is empty (hasn't been created yet).

----------------------------------------------------------------------------------------------------
templates:
----------------------------------------------------------------------------------------------------

# cat caller.yaml
heat_template_version: 2013-05-23

resources:

  network:
    type: Test::Network

  lb:
    type: Test::LoadBalancer
    properties:
      private_subnet_id: {get_attr: [ network, private_subnet_id ]}
    depends_on: network

----------------------------------------------------------------------------------------------------

# cat net.yaml
heat_template_version: 2013-05-23
description: >
  Network provider template

resources:
  private_network:
    type: OS::Neutron::Net
    properties:
      name: private_net_heat
      shared: false

  private_subnet:
    type: OS::Neutron::Subnet
    properties:
      name: private_subnet_heat
      network: {get_resource: private_network}
      ip_version: 4
      cidr: 10.1.10.1/24
      gateway_ip: 10.1.10.1
      allocation_pools: [{"start": 10.1.10.10, "end":10.1.10.200}]

outputs:
  private_network_id:
    description: Private network ID
    value: {get_resource: private_network}
  private_subnet_id:
    description: Private subnet ID
    value: {get_resource: private_subnet}

----------------------------------------------------------------------------------------------------

# cat lb.yaml
heat_template_version: 2013-05-23
description: >
  Load Balancing provider template

parameters:
  private_subnet_id:
    type: string

resources:
  monitor:
    type: OS::Neutron::HealthMonitor
    properties:
      type: TCP
      delay: 5
      max_retries: 5
      timeout: 5

  pool:
    type: OS::Neutron::Pool
    properties:
      protocol: HTTP
      monitors: [{get_resource: monitor}]
      subnet_id: {get_param: private_subnet_id}
      lb_method: ROUND_ROBIN
      vip:
        protocol_port: 80

  lb:
    type: OS::Neutron::LoadBalancer
    properties:
      protocol_port: 80
      pool_id: {get_resource: pool}

----------------------------------------------------------------------------------------------------
Log: (TL;DR - )'Type': u'OS::Neutron::Pool', 'Properties': {u'subnet_id': <heat.engine.hot.functions.GetParam {get_param: u'private_subnet_id'} -> ''>
----------------------------------------------------------------------------------------------------
2015-01-04 10:46:51.635 3678 INFO heat.engine.service [req-f0769e65-5736-4ddc-86cb-ee75dbf5f8d2 None] Creating stack test-test
2015-01-04 10:46:51.765 3678 INFO heat.engine.environment [req-f0769e65-5736-4ddc-86cb-ee75dbf5f8d2 None] Registering Test::LoadBalancer -> file:///home/augol/FIX/lb.yaml
2015-01-04 10:46:51.765 3678 INFO heat.engine.environment [req-f0769e65-5736-4ddc-86cb-ee75dbf5f8d2 None] Registering Test::Network -> file:///home/augol/FIX/net.yaml
2015-01-04 10:46:51.768 3678 DEBUG heat.engine.parameter_groups [req-f0769e65-5736-4ddc-86cb-ee75dbf5f8d2 None] <heat.engine.hot.template.HOTemplate20130523 object at 0x4d3bc90> __init__ /opt/stack/heat/heat/engine/parameter_groups.py:31
2015-01-04 10:46:51.768 3678 DEBUG heat.engine.parameter_groups [req-f0769e65-5736-4ddc-86cb-ee75dbf5f8d2 None] <heat.engine.hot.parameters.HOTParameters object at 0x4dfc450> __init__ /opt/stack/heat/heat/engine/parameter_groups.py:32
2015-01-04 10:46:51.768 3678 DEBUG heat.engine.parameter_groups [req-f0769e65-5736-4ddc-86cb-ee75dbf5f8d2 None] Validating Parameter Groups. validate /opt/stack/heat/heat/engine/parameter_groups.py:43
2015-01-04 10:46:51.768 3678 DEBUG heat.engine.parameter_groups [req-f0769e65-5736-4ddc-86cb-ee75dbf5f8d2 None] ['OS::project_id', 'OS::stack_id'] validate /opt/stack/heat/heat/engine/parameter_groups.py:44
2015-01-04 10:46:51.771 3678 INFO heat.common.urlfetch [req-f0769e65-5736-4ddc-86cb-ee75dbf5f8d2 None] Fetching data from file:///home/augol/FIX/lb.yaml
2015-01-04 10:46:51.774 3678 INFO heat.common.urlfetch [req-f0769e65-5736-4ddc-86cb-ee75dbf5f8d2 None] Fetching data from file:///home/augol/FIX/net.yaml
2015-01-04 10:46:51.777 3678 INFO heat.engine.resource [req-f0769e65-5736-4ddc-86cb-ee75dbf5f8d2 None] Validating TemplateResource "network"
2015-01-04 10:46:51.777 3678 DEBUG heat.engine.resource [req-f0769e65-5736-4ddc-86cb-ee75dbf5f8d2 None] TemplateResource "network" - ResourceDefinition {'Type': u'Test::Network'} validate /opt/stack/heat/heat/engine/resource.py:840
2015-01-04 10:46:51.780 3678 DEBUG heat.engine.parameter_groups [req-f0769e65-5736-4ddc-86cb-ee75dbf5f8d2 None] <heat.engine.hot.template.HOTemplate20130523 object at 0x7fe3bada1a10> __init__ /opt/stack/heat/heat/engine/parameter_groups.py:31
2015-01-04 10:46:51.780 3678 DEBUG heat.engine.parameter_groups [req-f0769e65-5736-4ddc-86cb-ee75dbf5f8d2 None] <heat.engine.hot.parameters.HOTParameters object at 0x4dfcf10> __init__ /opt/stack/heat/heat/engine/parameter_groups.py:32
2015-01-04 10:46:51.780 3678 DEBUG heat.engine.parameter_groups [req-f0769e65-5736-4ddc-86cb-ee75dbf5f8d2 None] Validating Parameter Groups. validate /opt/stack/heat/heat/engine/parameter_groups.py:43
2015-01-04 10:46:51.780 3678 DEBUG heat.engine.parameter_groups [req-f0769e65-5736-4ddc-86cb-ee75dbf5f8d2 None] ['OS::project_id', 'OS::stack_id'] validate /opt/stack/heat/heat/engine/parameter_groups.py:44
2015-01-04 10:46:51.784 3678 INFO heat.engine.resource [req-f0769e65-5736-4ddc-86cb-ee75dbf5f8d2 None] Validating Net "private_network"
2015-01-04 10:46:51.784 3678 DEBUG heat.engine.resource [req-f0769e65-5736-4ddc-86cb-ee75dbf5f8d2 None] Net "private_network" - ResourceDefinition {'Type': u'OS::Neutron::Net', 'Properties': {u'shared': False, u'name': u'private_net_heat'}} validate /opt/stack/heat/heat/engine/resource.py:840
2015-01-04 10:46:51.785 3678 INFO heat.engine.resource [req-f0769e65-5736-4ddc-86cb-ee75dbf5f8d2 None] Validating Subnet "private_subnet"
2015-01-04 10:46:51.785 3678 DEBUG heat.engine.resource [req-f0769e65-5736-4ddc-86cb-ee75dbf5f8d2 None] Subnet "private_subnet" - ResourceDefinition {'Type': u'OS::Neutron::Subnet', 'Properties': {u'name': u'private_subnet_heat', u'allocation_pools': [{u'start': u'10.1.10.10', u'end': u'10.1.10.200'}], u'gateway_ip': u'10.1.10.1', u'ip_version': 4, u'cidr': u'10.1.10.1/24', u'network': <heat.engine.cfn.functions.ResourceRef {get_resource: u'private_network'} -> u'None'>}} validate /opt/stack/heat/heat/engine/resource.py:840
2015-01-04 10:46:51.786 3678 INFO heat.engine.resource [req-f0769e65-5736-4ddc-86cb-ee75dbf5f8d2 None] Validating TemplateResource "lb"
2015-01-04 10:46:51.787 3678 DEBUG heat.engine.resource [req-f0769e65-5736-4ddc-86cb-ee75dbf5f8d2 None] TemplateResource "lb" - ResourceDefinition {'Type': u'Test::LoadBalancer', 'Properties': {u'private_subnet_id': <heat.engine.hot.functions.GetAttThenSelect {get_attr: [u'network', u'private_subnet_id']} -> None>}, 'DependsOn': u'network'} validate /opt/stack/heat/heat/engine/resource.py:840
2015-01-04 10:46:51.789 3678 DEBUG heat.engine.parameter_groups [req-f0769e65-5736-4ddc-86cb-ee75dbf5f8d2 None] <heat.engine.hot.template.HOTemplate20130523 object at 0x4dec510> __init__ /opt/stack/heat/heat/engine/parameter_groups.py:31
2015-01-04 10:46:51.789 3678 DEBUG heat.engine.parameter_groups [req-f0769e65-5736-4ddc-86cb-ee75dbf5f8d2 None] <heat.engine.hot.parameters.HOTParameters object at 0x4e0c190> __init__ /opt/stack/heat/heat/engine/parameter_groups.py:32
2015-01-04 10:46:51.789 3678 DEBUG heat.engine.parameter_groups [req-f0769e65-5736-4ddc-86cb-ee75dbf5f8d2 None] Validating Parameter Groups. validate /opt/stack/heat/heat/engine/parameter_groups.py:43
2015-01-04 10:46:51.790 3678 DEBUG heat.engine.parameter_groups [req-f0769e65-5736-4ddc-86cb-ee75dbf5f8d2 None] ['OS::project_id', u'private_subnet_id', 'OS::stack_id'] validate /opt/stack/heat/heat/engine/parameter_groups.py:44
2015-01-04 10:46:51.792 3678 INFO heat.engine.resource [req-f0769e65-5736-4ddc-86cb-ee75dbf5f8d2 None] Validating HealthMonitor "monitor"
2015-01-04 10:46:51.792 3678 DEBUG heat.engine.resource [req-f0769e65-5736-4ddc-86cb-ee75dbf5f8d2 None] HealthMonitor "monitor" - ResourceDefinition {'Type': u'OS::Neutron::HealthMonitor', 'Properties': {u'delay': 5, u'max_retries': 5, u'type': u'TCP', u'timeout': 5}} validate /opt/stack/heat/heat/engine/resource.py:840
2015-01-04 10:46:51.792 3678 INFO heat.engine.resource [req-f0769e65-5736-4ddc-86cb-ee75dbf5f8d2 None] Validating Pool "pool"
2015-01-04 10:46:51.793 3678 DEBUG heat.engine.resource [req-f0769e65-5736-4ddc-86cb-ee75dbf5f8d2 None] Pool "pool" - ResourceDefinition {'Type': u'OS::Neutron::Pool', 'Properties': {u'subnet_id': <heat.engine.hot.functions.GetParam {get_param: u'private_subnet_id'} -> ''>, u'vip': {u'protocol_port': 80}, u'lb_method': u'ROUND_ROBIN', u'protocol': u'HTTP', u'monitors': [<heat.engine.cfn.functions.ResourceRef {get_resource: u'monitor'} -> u'None'>]}} validate /opt/stack/heat/heat/engine/resource.py:840
2015-01-04 10:46:51.795 3678 INFO heat.engine.stack [req-f0769e65-5736-4ddc-86cb-ee75dbf5f8d2 None] At least one of the following properties must be specified: subnet, subnet_id
2015-01-04 10:46:51.795 3678 INFO heat.engine.stack [req-f0769e65-5736-4ddc-86cb-ee75dbf5f8d2 None] Failed to validate: At least one of the following properties must be specified: subnet, subnet_id
2015-01-04 10:46:51.796 3678 INFO oslo.messaging._drivers.impl_rabbit [req-f0769e65-5736-4ddc-86cb-ee75dbf5f8d2 ] Connecting to AMQP server on 10.35.160.83:5672
2015-01-04 10:46:51.810 3678 INFO oslo.messaging._drivers.impl_rabbit [req-f0769e65-5736-4ddc-86cb-ee75dbf5f8d2 ] Connected to AMQP server on 10.35.160.83:5672
/usr/lib/python2.7/site-packages/amqp/channel.py:616: VDeprecationWarning: The auto_delete flag for exchanges has been deprecated and will be removed
from py-amqp v1.5.0.
  warn(VDeprecationWarning(EXCHANGE_AUTODELETE_DEPRECATED))
/usr/lib/python2.7/site-packages/amqp/channel.py:616: VDeprecationWarning: The auto_delete flag for exchanges has been deprecated and will be removed
from py-amqp v1.5.0.
  warn(VDeprecationWarning(EXCHANGE_AUTODELETE_DEPRECATED))

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

Revision history for this message
Angus Salkeld (asalkeld) wrote :

This code is at fault: https://github.com/openstack/heat/blob/master/heat/engine/resources/neutron/neutron.py#L53-L63
It doesn't take into acount that the property could be unresolved.

The call to it is here: https://github.com/openstack/heat/blob/master/heat/engine/resources/neutron/loadbalancer.py#L353

We really need a better way to get the information that it is provided but not resolved yet (to delay validation).
Really property validation is hopeless at validation time as there are often references and we will need to duplicate the validation
step in the create/update.

Revision history for this message
Angus Salkeld (asalkeld) wrote :
Changed in heat:
status: New → Confirmed
importance: Undecided → High
milestone: none → kilo-2
Angus Salkeld (asalkeld)
Changed in heat:
assignee: nobody → Angus Salkeld (asalkeld)
Changed in heat:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

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

Steven Hardy (shardy)
tags: added: juno-backport-potential
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to heat (master)

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

commit 7143f98a25cfd34e7e2172799bf8c35cb951d08c
Author: Angus Salkeld <email address hidden>
Date: Thu Jan 22 21:49:05 2015 +1000

    Use properties.data when testing for "provided by the user"

    We need to be able to support references in our properties.

    Change-Id: I1d2eeba7ee39d287c6259f82769bf740c7344e31
    Closes-bug: 1407392

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

Fix proposed to branch: stable/juno
Review: https://review.openstack.org/153369

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

Reviewed: https://review.openstack.org/153369
Committed: https://git.openstack.org/cgit/openstack/heat/commit/?id=7d4e570e1a31c352af01cbd75548d41d7102dc53
Submitter: Jenkins
Branch: stable/juno

commit 7d4e570e1a31c352af01cbd75548d41d7102dc53
Author: Angus Salkeld <email address hidden>
Date: Thu Jan 22 21:49:05 2015 +1000

    Use properties.data when testing for "provided by the user"

    We need to be able to support references in our properties.

    Change-Id: I1d2eeba7ee39d287c6259f82769bf740c7344e31
    Closes-bug: 1407392
    (cherry picked from commit 7143f98a25cfd34e7e2172799bf8c35cb951d08c)

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on heat (master)

Change abandoned by Angus Salkeld (<email address hidden>) on branch: master
Review: https://review.openstack.org/145147

Thierry Carrez (ttx)
Changed in heat:
milestone: kilo-2 → 2015.1.0
Zane Bitter (zaneb)
tags: added: in-stable-juno
removed: juno-backport-potential
Revision history for this message
Jeffrey Guan (double12gzh) wrote :

The OS::Neutron::Port has a validation logic to handle the validation for the "network_id" and "network" .
The former is not supported now, the latter is a new property.
If the parameters passed from one nested stack to the other, the value for that parameters should be set before.
Otherwise the Port validation does not see it and then an exception will be thrown.

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.