template validate reports invalid error while using improper template

Bug #1571974 reported by Kanagaraj Manickam
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-heatclient
Confirmed
Medium
Sharat Sharma

Bug Description

With invalid json formated template file, template validation fails as below:

leagacy heat template-validate reports circular reference error
================================================================
manickan@mrkanag-os:~/workspace/hot-tutorials$ heat -d template-validate --template-file hello-world-2-invalid-output-value-assignement.yaml
DEBUG (session) REQ: curl -g -i -X GET http://172.241.0.101:5000/v3 -H "Accept: application/json" -H "User-Agent: python-keystoneclient"
INFO (connectionpool) Starting new HTTP connection (1): 172.241.0.101
DEBUG (connectionpool) "GET /v3 HTTP/1.1" 200 252
DEBUG (session) RESP: [200] Content-Length: 252 Vary: X-Auth-Token Connection: keep-alive Date: Tue, 19 Apr 2016 05:48:30 GMT Content-Type: application/json X-Openstack-Request-Id: req-7b6dc6a9-cb01-42af-a061-7ec81374b033
RESP BODY: {"version": {"status": "stable", "updated": "2016-04-04T00:00:00Z", "media-types": [{"base": "application/json", "type": "application/vnd.openstack.identity-v3+json"}], "id": "v3.6", "links": [{"href": "http://172.241.0.101:5000/v3/", "rel": "self"}]}}

DEBUG (base) Making authentication request to http://172.241.0.101:5000/v3/auth/tokens
DEBUG (connectionpool) "POST /v3/auth/tokens HTTP/1.1" 201 7736
WARNING (shell) "heat template-validate" is deprecated, please use "openstack orchestration template validate" instead
Traceback (most recent call last):
  File "/usr/local/bin/heat", line 10, in <module>
    sys.exit(main())
  File "/opt/stack/python-heatclient/heatclient/shell.py", line 704, in main
    HeatShell().main(args)
  File "/opt/stack/python-heatclient/heatclient/shell.py", line 654, in main
    args.func(client, args)
  File "/opt/stack/python-heatclient/heatclient/v1/shell.py", line 927, in do_template_validate
    validation = hc.stacks.validate(**fields)
  File "/opt/stack/python-heatclient/heatclient/v1/stacks.py", line 296, in validate
    resp = self.client.post(url, **args)
  File "/usr/local/lib/python2.7/dist-packages/keystoneclient/adapter.py", line 182, in post
    return self.request(url, 'POST', **kwargs)
  File "/opt/stack/python-heatclient/heatclient/common/http.py", line 321, in request
    **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/keystoneclient/adapter.py", line 212, in request
    resp = super(LegacyJsonAdapter, self).request(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/keystoneclient/adapter.py", line 101, in request
    return self.session.request(url, method, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/positional/__init__.py", line 94, in inner
    return func(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/keystoneclient/session.py", line 370, in request
    kwargs['data'] = jsonutils.dumps(json)
  File "/usr/local/lib/python2.7/dist-packages/oslo_serialization/jsonutils.py", line 178, in dumps
    return json.dumps(obj, default=default, **kwargs)
  File "/usr/lib/python2.7/json/__init__.py", line 250, in dumps
    sort_keys=sort_keys, **kw).encode(obj)
  File "/usr/lib/python2.7/json/encoder.py", line 207, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/lib/python2.7/json/encoder.py", line 270, in iterencode
    return _iterencode(o, 0)
ValueError: Circular reference detected
manickan@mrkanag-os:~/workspace/hot-tutorials$

orchestration template validate command reports template version in datatime error
==================================================================================
manickan@mrkanag-os:~/workspace/hot-tutorials$ openstack -v orchestration template validate -t hello-world-2-invalid-output-value-assignement.yaml
START with options: ['-v', 'orchestration', 'template', 'validate', '-t', 'hello-world-2-invalid-output-value-assignement.yaml']
command: orchestration template validate -> heatclient.osc.v1.template.Validate
/usr/local/lib/python2.7/dist-packages/openstackclient/api/auth.py:118: DeprecationWarning: Using function/method 'keystoneclient.auth.base.get_plugin_class()' is deprecated in version '2.1.0' and will be removed in version '3.0.0': keystoneclient auth plugins are deprecated. Use keystoneauth.
  auth_plugin_class = base.get_plugin_class(auth_plugin_name)
Using auth plugin: password
/usr/local/lib/python2.7/dist-packages/keystoneclient/auth/identity/base.py:56: DeprecationWarning: keystoneclient auth plugins are deprecated as of the 2.1.0 release in favor of keystoneauth1 plugins. They will be removed in future releases.
  'in future releases.', DeprecationWarning)
/usr/local/lib/python2.7/dist-packages/keystoneclient/adapter.py:57: DeprecationWarning: keystoneclient.adapter.Adapter is deprecated as of the 2.1.0 release in favor of keystoneauth1.adapter.Adapter. It will be removed in future releases.
  'removed in future releases.', DeprecationWarning)
datetime.date(2016, 10, 14) is not JSON serializable
END return value: 1
manickan@mrkanag-os:~/workspace/hot-tutorials$

template used
=============
heat_template_version: 2016-10-14

description:
  First heat hot template used to demonstrate the hot template sections.

resources:
  first_rsc:
    type: OS::Heat::RandomString

outputs:
  random_str:
     value: {get_attr:[first_rsc,value]} <<<< -- get_attr is not formatted properly with required whitespace in place

To fix this case, its better to validate the given template is proper one by using template_format.parse() before proceeding further in the command execution

Changed in heat:
assignee: nobody → Sharat Sharma (sharat-sharma)
Thomas Herve (therve)
affects: heat → python-heatclient
Revision history for this message
Jaspreet Singh Rawel (jaspreetsinghrawel) wrote :

Reproduced this issue on OpenStack Mitaka Release. In Mitaka, the reported command (see below):

#############
"openstack -v orchestration template validate -t hello-world-2-invalid-output-value-assignement.yaml"
#############

will be run like below command in Mitaka Release because "openstack orchestration template validate" is removed in Mitaka release and instead that functionality is added to "openstack stack create --dry-run" command shown below:

###########
"openstack -v stack create -t hello-world-2-invalid-output-value-assignement.yaml --dry-run mystack"
###########
In the above example, "mystack" is the name of the stack.

Issue Reproduction Log:
----------------------
----------------------
root@controller:/home/ubuntu# openstack -v stack create -t my-temp1.yaml --dry-run mystack
START with options: ['-v', 'stack', 'create', '-t', 'my-temp1.yaml', '--dry-run', 'mystack']
command: stack create -> heatclient.osc.v1.stack.CreateStack
/usr/lib/python2.7/dist-packages/openstackclient/api/auth.py:118: DeprecationWarning: Using function/method 'keystoneclient.auth.base.get_plugin_class()' is deprecated in version '2.1.0' and will be removed in version '3.0.0': keystoneclient auth plugins are deprecated. Use keystoneauth.
  auth_plugin_class = base.get_plugin_class(auth_plugin_name)
Using auth plugin: password
/usr/lib/python2.7/dist-packages/keystoneclient/auth/identity/base.py:56: DeprecationWarning: keystoneclient auth plugins are deprecated as of the 2.1.0 release in favor of keystoneauth1 plugins. They will be removed in future releases.
  'in future releases.', DeprecationWarning)
/usr/lib/python2.7/dist-packages/keystoneclient/adapter.py:57: DeprecationWarning: keystoneclient.adapter.Adapter is deprecated as of the 2.1.0 release in favor of keystoneauth1.adapter.Adapter. It will be removed in future releases.
  'removed in future releases.', DeprecationWarning)
datetime.date(2016, 10, 14) is not JSON serializable
END return value: 1
root@controller:/home/ubuntu#
root@controller:/home/ubuntu#

Changed in python-heatclient:
status: New → Confirmed
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.