get_attr doesn't work with block_device_mapping

Bug #1463531 reported by Zane Bitter
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Heat
Fix Released
High
Rabi Mishra
Juno
Fix Released
High
Rabi Mishra
Kilo
Fix Released
High
Rabi Mishra

Bug Description

When the fields of the OS::Nova::Server block_device_mapping property are supplied via the get_attr intrinsic function, validation fails (because get_attr returns None and the property is interpreted as missing).

This was previously raised as bug 1230140. The fix on that occasion was to get rid of the 'uuid' attribute of a volume and require people to use get_resource instead. However, this fails to take into account that the volume may be inside a nested stack. At least in Juno and before this means a volume can not be defined in a template resource. In Kilo and later there may be a workaround using get_resource instead of get_attr, but I wouldn't regard it as a fix per se.

Changed in heat:
status: New → Triaged
importance: Undecided → High
Revision history for this message
Rabi Mishra (rabi) wrote :

I think there is a simple fix for this. get_attr returns an empty string rather than 'None'. If we can change the validation logic to
some thing like this, it would work. This is standard problem for all validations where we use nested stack resources for properties which are not created yet.

            if volume_id is not None and snapshot_id is not None:
                raise exception.ResourcePropertyConflict(
                    self.BLOCK_DEVICE_MAPPING_VOLUME_ID,
                    self.BLOCK_DEVICE_MAPPING_SNAPSHOT_ID)
            if volume_id is None and snapshot_id is None:
                msg = _('Either volume_id or snapshot_id must be specified for'
                        ' device mapping %s') % device_name
                raise exception.StackValidationFailed(message=msg)

Changed in heat:
assignee: nobody → Rabi Mishra (rabi)
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/190008

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

Reviewed: https://review.openstack.org/190008
Committed: https://git.openstack.org/cgit/openstack/heat/commit/?id=4d2b275358cd010c0ba19697d5e623a1edef3daf
Submitter: Jenkins
Branch: master

commit 4d2b275358cd010c0ba19697d5e623a1edef3daf
Author: Rabi Mishra <email address hidden>
Date: Wed Jun 10 08:24:58 2015 +0530

    Fix block_device_mapping property validation when using get_attr

    Change-Id: I6501395ab458b75ba7d27c8ce9643bd6d18cb203
    Closes-Bug: #1463531

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

A small correction. Rather than get_attr returning empty values, it seems specified properties[1] are sanitized to their data types before validation. Therefore checking for None would be always useful for validation.

[1]https://github.com/openstack/heat/blob/master/heat/engine/properties.py#L318-L333

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

Revision history for this message
Zane Bitter (zaneb) wrote :

Your comment #4 implies to me that checking for None would _never_ be useful for validation, since a (string) property value can never return None, so the effect of this change would be to prevent any validation occuring. Am I wrong, do we have tests that prove otherwise? I left a -1 review to this effect on the kilo backport until we can confirm.

Revision history for this message
Rabi Mishra (rabi) wrote :

If the properties are not specified in the template then it would be None. If specified they are sanitized i.e string would empty string.

Zane Bitter (zaneb)
tags: added: juno-backport-potential kilo-backport-potential
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/190222

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

Reviewed: https://review.openstack.org/190097
Committed: https://git.openstack.org/cgit/openstack/heat/commit/?id=754851d7cd45bf0effcdccd9658b916317f59f6a
Submitter: Jenkins
Branch: stable/kilo

commit 754851d7cd45bf0effcdccd9658b916317f59f6a
Author: Rabi Mishra <email address hidden>
Date: Wed Jun 10 08:24:58 2015 +0530

    Fix block_device_mapping property validation when using get_attr

    Change-Id: I6501395ab458b75ba7d27c8ce9643bd6d18cb203
    Closes-Bug: #1463531
    (cherry picked from commit 4d2b275358cd010c0ba19697d5e623a1edef3daf)

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

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

commit fbc370a63918e1bfc1b46725dcf27886056afa08
Author: Rabi Mishra <email address hidden>
Date: Wed Jun 10 08:24:58 2015 +0530

    Fix block_device_mapping property validation when using get_attr

    Change-Id: I6501395ab458b75ba7d27c8ce9643bd6d18cb203
    Closes-Bug: #1463531
    (cherry picked from commit 4d2b275358cd010c0ba19697d5e623a1edef3daf)

Thierry Carrez (ttx)
Changed in heat:
status: Fix Committed → Fix Released
tags: added: in-stable-juno in-stable-kilo
removed: juno-backport-potential kilo-backport-potential
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.