HOT constraints translation broken

Bug #1224111 reported by Randall Burt
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Heat
Fix Released
High
Thomas Spatzier

Bug Description

Due to the way schemata converts parameters to properties, HOT cannot be used as a provider template due to the mis-match between AWS-style parameter validation attributes and HOT-style constraints.

Tags: hot
Steven Hardy (shardy)
Changed in heat:
status: New → Confirmed
importance: Undecided → High
milestone: none → havana-rc1
Revision history for this message
Steven Hardy (shardy) wrote :
Download full text (8.4 KiB)

Confirmed, my testing indicates the same. We really need to fix this ASAP..

Here's a reproducer.

1. Create minimal provider resource template which has constraints on a parameter

# cat /tmp/hot_minimal.yaml
heat_template_version: 2013-05-23

parameters:
  InstanceType:
    type: string
    description: Instance type for WordPress server
    default: m1.small
    constraints:
      - allowed_values: [m1.small, m1.medium, m1.large]
        description: InstanceType must be one of m1.small, m1.medium or m1.large
  ImageId:
    type: string
    description: ID of the image to use for the WordPress server
    default: F18-x86_64-cfntools
    constraints:
      - allowed_values: [ F18-i386-cfntools, F18-x86_64-cfntools ]
        description: >
          Image ID bust be either F18-i386-cfntools or F18-x86_64-cfntools
  DBName:
    type: string
    description: WordPress database name
    default: wordpress
    constraints:
      - length: { min: 1, max: 64 }
        description: DBName must be between 1 and 64 characters
      - allowed_pattern: '[a-zA-Z][a-zA-Z0-9]*'
        description: >
          DBName must begin with a letter and contain only alphanumeric
          characters

resources:
  wordpress_instance:
    type: OS::Nova::Server
    properties:
      image: { get_param: ImageId }
      flavor: { get_param: InstanceType }

2. Create an environment file pointing to the template above

# cat env_minimal.yaml
resource_registry:
    # Define a custom resource type based on a template
    "My::Custom::Server": file:///tmp/hot_minimal.yaml

3 . Create a template which uses the provder resource

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

resources:
  wordpress_instance:
    type: My::Custom::Server

4. Launch the template

heat --debug create test_stack --template-file=./minimal_test.yaml --environment-file=./env_minimal.yaml

We get this in the engine log:

2013-09-18 14:51:01.628 7560 INFO heat.engine.environment [-] Registering My::Custom::Server -> file:///tmp/hot_minimal.yaml
SHDEBUG getting num val for MinLength from [(1, u'DBName must be between 1 and 64 characters')]
2013-09-18 14:51:01.630 7560 ERROR heat.openstack.common.rpc.amqp [-] Exception during message handling
2013-09-18 14:51:01.630 7560 TRACE heat.openstack.common.rpc.amqp Traceback (most recent call last):
2013-09-18 14:51:01.630 7560 TRACE heat.openstack.common.rpc.amqp File "/usr/lib/python2.7/site-packages/heat/openstack/common/rpc/amqp.py", line 461, in _process_data
2013-09-18 14:51:01.630 7560 TRACE heat.openstack.common.rpc.amqp **args)
2013-09-18 14:51:01.630 7560 TRACE heat.openstack.common.rpc.amqp File "/usr/lib/python2.7/site-packages/heat/openstack/common/rpc/dispatcher.py", line 172, in dispatch
2013-09-18 14:51:01.630 7560 TRACE heat.openstack.common.rpc.amqp result = getattr(proxyobj, method)(ctxt, **kwargs)
2013-09-18 14:51:01.630 7560 TRACE heat.openstack.common.rpc.amqp File "/usr/lib/python2.7/site-packages/heat/engine/service.py", line 56, in wrapped
2013-09-18 14:51:01.630 7560 TRACE heat.openstack.common.rpc.amqp return func(self, ctx, *args, **kwargs)
2013-09-18 14:51:01.630 7560 TRACE heat.openstack.common.r...

Read more...

Changed in heat:
assignee: nobody → Steven Hardy (shardy)
Revision history for this message
Steven Hardy (shardy) wrote :

So it actually looks like this is not specific to provider templates, all HOT templates which contain constraints are broken, because we're not translating correcty to the AWS schema in HOTemplate::_translate_constraints

patch coming soon...

Changed in heat:
status: Confirmed → In Progress
summary: - HOT cannot be used as a provider template
+ HOT constraints translation broken
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/47570

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

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

Changed in heat:
assignee: Steven Hardy (shardy) → Thomas Spatzier (thomas-spatzier)
Revision history for this message
Thomas Spatzier (thomas-spatzier) wrote :

This bug can be closed based upon patches in comment #3 and #4.

We had some discussion about some refactoring of the second patch, but decided to move that refactoring into Icehouse. I have opened bug #1230229 to track this.

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

Reviewed: https://review.openstack.org/47827
Committed: http://github.com/openstack/heat/commit/170920638206d0ece54e945c97da7f281cea9cad
Submitter: Jenkins
Branch: master

commit 170920638206d0ece54e945c97da7f281cea9cad
Author: Thomas Spatzier <email address hidden>
Date: Mon Sep 23 15:05:02 2013 +0200

    Do not translate HOT param constraints

    Do not translate HOT parameter constraint definitions and have them processed
    by default CFN-based code. Instead, do HOT parameter constraint validation in
    HOTParamSchema class to handle HOT-specific constraint syntax appropriately.
    This is more robust than trying to map the new HOT syntax to old CFN
    constraint style.

    This patch is cleanup and first in a row for fixing the use of HOT templates
    as provider templates.

    Partial-Bug: #1224111

    Change-Id: Ia35f281f874b906aabeb684fd9caca03dd994b9c

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Reviewed: https://review.openstack.org/47877
Committed: http://github.com/openstack/heat/commit/c8293a3143c7a11e7c9d922797f47943e04c9d50
Submitter: Jenkins
Branch: master

commit c8293a3143c7a11e7c9d922797f47943e04c9d50
Author: Thomas Spatzier <email address hidden>
Date: Mon Sep 23 18:47:42 2013 +0200

    Handle HOT param constraints in provider templates

    When HOT templates are used as provider templates, parameter constraints
    have to be translated into provider resource properties correctly. The
    properties Schema class has been design to cover both CFN and HOT, but
    the code in Schema.from_parameter has to distinguish between CFN and
    HOT parameter constraints to correctly build the schema.

    This patch fixes the handling of HOT parameters.

    Change-Id: I59027d3b51e5d6dcc2a867cc5b5015cd6c88051c
    Closes-Bug: #1224111

Changed in heat:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in heat:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in heat:
milestone: havana-rc1 → 2013.2
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.