Translation fails with interface input / intrinsic function

Bug #1440247 reported by Vahid Hashemian
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Heat Translator
Fix Released
High
Vahid Hashemian

Bug Description

This is a post bug #1439444 issue. To verify please checkout the fix at https://review.openstack.org/#/c/170565/, if not already merged.

The translation works fine when tested on the attached YAML file with inputs "db_name=wordpress;db_user=admin;db_pwd=admin;db_root_pwd=admin;db_port=50000;cpus=8" and generates the valid HOT output attached.

However, if the lines

          #inputs:
            #db_root_password: { get_property: [ mysql_dbms, dbms_root_password ] }

are un-commented the translator generates an invalid HOT output (attached also).

NOTE: As part of the patch for this bug changes made to translator/toscalib/tests/data/tosca_single_instance_wordpress.yaml, translator/toscalib/tests/test_functions.py and translator/toscalib/tests/test_toscatpl.py that were introduced by the patch https://review.openstack.org/#/c/171412 must be reverted.

Revision history for this message
Vahid Hashemian (vahidhashemian) wrote :
Revision history for this message
Vahid Hashemian (vahidhashemian) wrote :
Revision history for this message
Vahid Hashemian (vahidhashemian) wrote :
summary: - Translation fails in with interface input / intrinsic function
+ Translation fails with interface input / intrinsic function
Revision history for this message
Sahdev Zala (spzala) wrote :

Hi Vahid,

Just wondering, what happens if
db_root_password: { get_property: [ mysql_dbms, dbms_root_password ] }
is replaced with and uncomment the code
db_root_password: { get_property: [ SELF, dbms_root_password ] }
in the hot_translation_bug.yaml

Revision history for this message
Sahdev Zala (spzala) wrote :

I think the current function only returns the name of input parameter e.g.
wp_db_name: { get_property: [ mysql_database, db_name ] }
where,
  mysql_database:
    type: tosca.nodes.Database
    properties:
      db_name: { get_input: db_name }
and input is,
  db_name:
    type: string
    description: The name of the database.
returns
'db_name' (the name of input parameter instead of value).

I think Idan's latest patch at least returns a 'default' value if set for the input.

@Idan, can you please look at this issue?

Revision history for this message
Vahid Hashemian (vahidhashemian) wrote :

Hi Sahdev,

I made the change you suggested above, but the HOT output did not improve and is still invalid.

Revision history for this message
Sahdev Zala (spzala) wrote :

@Vahid, thanks for testing. Please go ahead with changes you are proposing, i.e. temporary removing certain tests related to functions. Please also add Idan as reviewer for that patch.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix proposed to heat-translator (master)

Related fix proposed to branch: master
Review: https://review.openstack.org/171412

description: updated
Revision history for this message
Idan Moyal (idanmo) wrote :

Hi Vahid, Sahdev,
Intrinsic functions resolving is done by the translator per TOSCA node type.
get_property & get_input are not automatically resolved before passing the template to the translator and AFAIK the main problem is with custom types which is equivalent to the problems you have encountered.
In my next patch, related to get_input resolving I can take care of get_property as well if we decide that before handing the TOSCA template to the translator, intrinsic functions will be resolved.

Revision history for this message
Sahdev Zala (spzala) wrote :

Hey Idan, sure that's good idea to resolve get_property with your work on get_attribute. That will make translated output with desired value for properties. Thanks!

Revision history for this message
Sahdev Zala (spzala) wrote :

So to me, the good way of going forward is to resolve the get_input functions as,

1. At the command line, if user has provided value for an input, that's what should be returned
2. If no value is provided at the command line, set the value to the default value if provided
3. If above two's not true, set the value to an input function that HOT understand (assuming user will be providing value for it while running translated HOT template)

One exception to the step 3 is, properties for Compute node for OS capability (image related parameters e.g type or version etc.) and Container (flavor related parameters e.g. num_cpu), if user do not provide value at the CLI and no default value is set that will be an error case otherwise we set image and flavor in the HOT by finding the closest match to the image and flavor.

Sahdev Zala (spzala)
Changed in heat-translator:
assignee: nobody → Idan Moyal (idanmo)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix merged to heat-translator (master)

Reviewed: https://review.openstack.org/171412
Committed: https://git.openstack.org/cgit/openstack/heat-translator/commit/?id=66394b802c43cf104da62ebefeaf0e8ef3b3f9d1
Submitter: Jenkins
Branch: master

commit 66394b802c43cf104da62ebefeaf0e8ef3b3f9d1
Author: Steve Martinelli <email address hidden>
Date: Mon Apr 27 12:18:40 2015 -0400

    Create a unit test for wordpress specification in TOSCA

    Create a TOSCA-HOT translation unit test template and use that to
    unit test TOSCA wordpress example.

    Note, to implement this patch some changes had to be made to the
    wordpress TOSCA file as translation of certain pieces were not fully
    supported, as described in bug #1440247. As a result of the change in
    wordpress TOSCA file some existing test cases had to be skipped as
    well. It is important to re-enable the skipped code and revert the
    changes made to wordpress TOSCA file as part of bug #1440247 patch.

    Also, shell scripts that support mysql, web server, and wordpress
    installation and configuration were also updated to make sure the
    HOT translation works with the ubuntu-software-config-os-init image.

    To address bug #1447800 handling of null dictionaries was also
    improved.

    Change-Id: I2710eabb0a74c4d75498ac2d0fe3e50ea50133ab
    Closes-Bug: #1435545
    Closes-Bug: #1447800
    Partial-Bug: #1436420
    Related-Bug: #1440247

Sahdev Zala (spzala)
Changed in heat-translator:
assignee: Idan Moyal (idanmo) → nobody
assignee: nobody → srinivas_tadepalli (srinivas-tadepalli)
Sahdev Zala (spzala)
Changed in heat-translator:
importance: Undecided → Critical
importance: Critical → High
Sahdev Zala (spzala)
Changed in heat-translator:
assignee: srinivas_tadepalli (srinivas-tadepalli) → nobody
assignee: nobody → Vahid Hashemian (vahidhashemian)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to heat-translator (master)

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

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

Reviewed: https://review.openstack.org/206295
Committed: https://git.openstack.org/cgit/openstack/heat-translator/commit/?id=34f2e51e0d60e2871db7048666ebcae8fe3861ff
Submitter: Jenkins
Branch: master

commit 34f2e51e0d60e2871db7048666ebcae8fe3861ff
Author: Vahid Hashemian <email address hidden>
Date: Wed Sep 30 22:17:13 2015 -0700

    Fix translation issue with interface inputs and functions

    Fix the issue with interface inputs described using intrinsic
    functions, that produces an invalid HOT output. Also, include
    necessary unit tests, and revert templates that were simplified
    due to this issue..

    This patch includes changes required in heat-translator for
    resolving the issue.

    Change-Id: I0aa01a05a7e9bf695c10b193023958ec11e4a422
    Closes-Bug: #1440247

Changed in heat-translator:
status: In Progress → Fix Committed
Changed in heat-translator:
status: Fix Committed → Fix Released
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.