AutoScalingGroup doesn't support path attributes

Bug #1400684 reported by Steven Hardy
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Heat
Fix Released
High
Tatiana Kholkina

Bug Description

Due to the unfortunate historical divergence between OS::Heat::AutoScalingGroup and OS::Heat::ResourceGroup, AutoScalingGroup lacks the synthetic attributes added to ResourceGroup some time ago:

https://github.com/openstack/heat/blob/master/heat/engine/resources/resource_group.py#L273

This presents pain for folks who start using ResourceGroup then later move to AutoScalingGroup, e.g here:

https://review.openstack.org/#/c/138733/4/overcloud-without-mergepy.yaml

Long term we need a plan to stop these implementations diverging (hopefully this will fall out of the currently planned refactoring of ASG resources..), but for now, we should just add the path attribute lookup to AutoScalingGroup, either via a cut/paste addition to the ASG FnGetAtt, or if practical abstract the common logic into a mixin class or helper function.

https://github.com/openstack/heat/blob/master/heat/engine/resources/openstack/autoscaling_group.py#L150

Tags: tripleo
Steven Hardy (shardy)
tags: added: tripleo
Changed in heat:
status: New → Triaged
importance: Undecided → High
milestone: none → kilo-2
Changed in heat:
assignee: nobody → Tetiana Lashchova (tlashchova)
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/142516

Changed in heat:
status: Triaged → In Progress
Revision history for this message
Angus Salkeld (asalkeld) wrote :

@shardy, I am not so sure this is as relevant.

https://github.com/openstack/heat/blob/master/heat/engine/resources/instance_group.py#L268

https://github.com/openstack/heat/blob/master/heat/scaling/template.py#L40

https://github.com/openstack/heat/blob/master/heat/common/short_id.py#L57

short id doesn't look index'able (you won't be able to know it before hand), I am just not sure how useful it can be.
How exactly is the template author going know what to put in {get_attr: [group, resource.<shortid>]}

Revision history for this message
Steven Hardy (shardy) wrote :

> How exactly is the template author going know what to put in {get_attr: [group, resource.<shortid>]}

My intention was to allow an index based lookup, not a name based lookup using the shortid.

It's an unfortunate historical thing that the name equals the index in ResourceGroup IMO, I've always interpreted the path based lookup as an index into the group, which is what I wanted for ASG.

Here's an example:

https://review.openstack.org/#/c/138733/4/overcloud-without-mergepy.yaml (line 714)

Here, we're having to use Fn::Select to select the first group member, whereas for ResourceGroup you can just select by index.

So for ResourceGroup, you do:

{get_attr: [Controller, resource.0.hostname]}

For ASG you're forced to do:

'Fn::Select': ['0', {get_attr: [Controller, outputs_list, hostname]}]}

Ugh :(

Provided grouputils.get_members returns a consistent ordering, e.g ideally we want "0" to mean the first group member created, then lookup by index should work fine AFAICT.

Revision history for this message
Steven Hardy (shardy) wrote :
Download full text (3.9 KiB)

Hmm, actually, the latest version of get_attr should provide the lookup by index feature, only it doesn't seem to work:

heat_template_version: 2014-10-16

resources:
  random_group:
    type: OS::Heat::AutoScalingGroup
    properties:
      max_size: 2
      min_size: 2
      resource:
        type: OS::Heat::RandomString

outputs:
  all_values:
    value: {get_attr: [random_group, outputs_list, value]}
  first_value:
    value: {get_attr: [random_group, outputs_list, value, 0]}
  first_value_select:
    value: {'Fn::Select': ['0', {get_attr: [random_group, outputs_list, value]}]}

I expected the "first_value" get_attr to work like the Fn::Select, but they work differently:

| outputs | [ |
| | { |
| | "output_value": [ |
| | "d", |
| | "a" |
| | ], |
| | "description": "No description given", |
| | "output_key": "first_value" |
| | }, |
| | { |
| | "output_value": [ |
| | "dndoby2qS7pD8lxNF51gSkMQvaoL2tr7", |
| | "aJNx9tlkR5B6sKzFHBvpYYkqDv52YBpC" |
| | ], |
| | "description": "No description given", |
| | "output_key": "all_values" |
| | }, |
| | { ...

Read more...

Revision history for this message
Tatiana Kholkina (tlashchova) wrote :

Steven, I think using this feature we can only get elements from the returned value by index or by key if the value is a dict.

Angus Salkeld (asalkeld)
Changed in heat:
milestone: kilo-2 → kilo-3
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to heat (master)

Reviewed: https://review.openstack.org/142516
Committed: https://git.openstack.org/cgit/openstack/heat/commit/?id=584e91fc512a6c8cb9c6572261107f39b5536323
Submitter: Jenkins
Branch: master

commit 584e91fc512a6c8cb9c6572261107f39b5536323
Author: Tetiana Lashchova <email address hidden>
Date: Wed Dec 17 19:30:25 2014 +0200

    Support path attributes in OS::Heat::AutoScalingGroup

    Change-Id: I5cd6a711ae778dec1a205c6954efe57837a2db5c
    Closes-Bug: #1400684

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: kilo-3 → 2015.1.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.