Ceilometer alarm based AWS::CloudWatch::Alarm implementation does not work

Bug #1316842 reported by Marc Heckmann
18
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Heat
Fix Released
High
Rabi Mishra

Bug Description

When trying to use the supplied (/etc/heat/templates/AWS_CloudWatch_Alarm.yaml) Ceilometer based AWS::CloudWatch::Alarm implementation we get the the following error:

"ValueError: Value must be a comma-delimited list string: 'list' object has no attribute 'split'"

This is with Havana, but Icehouse seems to have the same implementation.

It seems to correspond with the way the "Dimensions" property of AWS::Cloudwatch::Alarm is mapped to the "matching_metadata" property of OS::Ceilometer::Alarm.

Here is what is in the heat-engine.log:

2014-05-06 22:31:41.965 3619 INFO heat.engine.resource [-] creating TemplateResource "CPUHighAlarm"
2014-05-06 22:31:41.966 3619 DEBUG heat.engine.scheduler [-] Task resource_action running step /usr/lib/python2.7/dist-packages/heat/engine/scheduler.py:164
2014-05-06 22:31:41.984 3619 INFO urllib3.connectionpool [-] Starting new HTTPS connection (1): cloud-api-onl.ncsa-east-msr.ubisoft.com
2014-05-06 22:31:42.055 3619 DEBUG urllib3.connectionpool [-] "GET /identity/admin/v2.0//users/cf31a52de0cc4ab7badc3064b6e19a3b/credentials/OS-EC2 HTTP/1.1" 200 None _make_request /usr/lib/python2.7/dist-packages/urllib3/connectionpool.py
:296
2014-05-06 22:31:42.091 3619 ERROR heat.engine.resource [-] CREATE : TemplateResource "CPUHighAlarm"
2014-05-06 22:31:42.091 3619 TRACE heat.engine.resource Traceback (most recent call last):
2014-05-06 22:31:42.091 3619 TRACE heat.engine.resource File "/usr/lib/python2.7/dist-packages/heat/engine/resource.py", line 368, in _do_action
2014-05-06 22:31:42.091 3619 TRACE heat.engine.resource handle_data = handle()
2014-05-06 22:31:42.091 3619 TRACE heat.engine.resource File "/usr/lib/python2.7/dist-packages/heat/engine/resources/template_resource.py", line 181, in handle_create
2014-05-06 22:31:42.091 3619 TRACE heat.engine.resource self._to_parameters())
2014-05-06 22:31:42.091 3619 TRACE heat.engine.resource File "/usr/lib/python2.7/dist-packages/heat/engine/stack_resource.py", line 100, in create_with_template
2014-05-06 22:31:42.091 3619 TRACE heat.engine.resource owner_id=self.stack.id)
2014-05-06 22:31:42.091 3619 TRACE heat.engine.resource File "/usr/lib/python2.7/dist-packages/heat/engine/parser.py", line 100, in __init__
2014-05-06 22:31:42.091 3619 TRACE heat.engine.resource user_params=self.env.params)
2014-05-06 22:31:42.091 3619 TRACE heat.engine.resource File "/usr/lib/python2.7/dist-packages/heat/engine/parameters.py", line 360, in __init__
2014-05-06 22:31:42.091 3619 TRACE heat.engine.resource self.params = dict((p.name, p) for p in parameters())
2014-05-06 22:31:42.091 3619 TRACE heat.engine.resource File "/usr/lib/python2.7/dist-packages/heat/engine/parameters.py", line 360, in <genexpr>
2014-05-06 22:31:42.091 3619 TRACE heat.engine.resource self.params = dict((p.name, p) for p in parameters())
2014-05-06 22:31:42.091 3619 TRACE heat.engine.resource File "/usr/lib/python2.7/dist-packages/heat/engine/parameters.py", line 355, in parameters
2014-05-06 22:31:42.091 3619 TRACE heat.engine.resource yield Parameter(name, schema, value, validate_value)
2014-05-06 22:31:42.091 3619 TRACE heat.engine.resource File "/usr/lib/python2.7/dist-packages/heat/engine/parameters.py", line 156, in __new__
2014-05-06 22:31:42.091 3619 TRACE heat.engine.resource return ParamClass(name, schema, value, validate_value)
2014-05-06 22:31:42.091 3619 TRACE heat.engine.resource File "/usr/lib/python2.7/dist-packages/heat/engine/parameters.py", line 246, in __init__
2014-05-06 22:31:42.091 3619 TRACE heat.engine.resource validate_value)
2014-05-06 22:31:42.091 3619 TRACE heat.engine.resource File "/usr/lib/python2.7/dist-packages/heat/engine/parameters.py", line 171, in __init__
2014-05-06 22:31:42.091 3619 TRACE heat.engine.resource self.validate(self.user_value)
2014-05-06 22:31:42.091 3619 TRACE heat.engine.resource File "/usr/lib/python2.7/dist-packages/heat/engine/parameters.py", line 270, in validate
2014-05-06 22:31:42.091 3619 TRACE heat.engine.resource parsed = self.parse(val)
2014-05-06 22:31:42.091 3619 TRACE heat.engine.resource File "/usr/lib/python2.7/dist-packages/heat/engine/parameters.py", line 255, in parse
2014-05-06 22:31:42.091 3619 TRACE heat.engine.resource raise ValueError(message % str(err))
2014-05-06 22:31:42.091 3619 TRACE heat.engine.resource ValueError: Value must be a comma-delimited list string: 'list' object has no attribute 'split'
2014-05-06 22:31:42.091 3619 TRACE heat.engine.resource
2014-05-06 22:31:42.122 3619 DEBUG heat.engine.scheduler [-] Task resource_action cancelled cancel /usr/lib/python2.7/dist-packages/heat/engine/scheduler.py:187
2014-05-06 22:31:42.130 3619 DEBUG heat.engine.scheduler [-] Task stack_task from Stack "test_aws_for_report" complete step /usr/lib/python2.7/dist-packages/heat/engine/scheduler.py:170
2014-05-06 22:31:42.131 3619 WARNING heat.engine.service [-] Stack create failed, status FAILED

My basic test template is as follows:

{
  "AWSTemplateFormatVersion" : "2010-09-09",
  "Parameters" : {
    "KeyName" : {
      "Description" : "Name of an existing KeyPair to enable SSH access to the instance",
      "Type" : "String"
    },
    "InstanceType" : {
      "Description" : "Instance type",
      "Type" : "String",
      "Default" : "U1.small",
      "AllowedValues" : [ "U1.small" ],
      "ConstraintDescription" : "must be a valid instance type."
    },
    "Image": {
      "Default": "redhat",
      "Description" : "Distribution of choice",
      "Type": "String",
      "AllowedValues" : [ "cirros", "redhat" ]
    },
    "MinPoolSize" : {
      "Default": "1",
      "Description": "Minimum Size of the Scaling Pool",
      "Type": "String"
    },
    "MaxPoolSize" : {
      "Default": "10",
      "Description": "Maximum size of the Scaling Pool",
      "Type": "String"
    }
  },

  "Mappings" : {
    "DistroArch2AMI": {
      "cirros" : { "64" : "cirros-0.3.1-x86_64" },
      "redhat" : { "64" : "CentOS-6.5-x86_64-20140227" }
    }
  },
  "Resources" : {
    "Nodes" : {
      "Type" : "AWS::AutoScaling::AutoScalingGroup",
      "Properties" : {
        "AvailabilityZones" : { "Fn::GetAZs" : ""},
        "LaunchConfigurationName" : { "Ref" : "LaunchConfig" },
        "MinSize" : { "Ref" : "MinPoolSize" },
        "MaxSize" : { "Ref" : "MaxPoolSize" }
      }
    },
    "LaunchConfig" : {
      "Type" : "AWS::AutoScaling::LaunchConfiguration",
      "Metadata" : {
        "AWS::CloudFormation::Init" : {
          "config" : {
          }
        }
      },
      "Properties" : {
        "KeyName" : { "Ref" : "KeyName" },
        "ImageId" : { "Fn::FindInMap" : [ "DistroArch2AMI", { "Ref" : "Image" }, "64" ] },
        "InstanceType": { "Ref" : "InstanceType" },
        "UserData" : {
            "Fn::Base64" : {
                "Fn::Join" : ["", [
                    "#!/bin/bash\n",
                    "if [ -e '/root/setup.sh' ]; then exec /root/setup.sh; fi\n"
                ]]
            }
        }
      }
    },
    "ScaleUpPolicy" : {
      "Type" : "AWS::AutoScaling::ScalingPolicy",
      "Properties" : {
        "AdjustmentType" : "ChangeInCapacity",
        "AutoScalingGroupName" : { "Ref" : "Nodes" },
        "Cooldown" : "60",
        "ScalingAdjustment" : "1"
      }
    },
    "CPUHighAlarm" : {
        "Type" : "AWS::CloudWatch::Alarm",
        "Properties" : {
            "AlarmDescription" : "Scale up with CPU > 50% for 5 minute",
            "MetricName" : "cpu_util",
            "Statistic" : "Average",
            "Period" : "300",
            "EvaluationPeriods" : "1",
            "Threshold" : "50",
            "AlarmActions" : [ { "Ref" : "ScaleUpPolicy" } ],
            "Dimensions": [
              {
                "Name": "AutoScalingGroupName",
                "Value": { "Ref": "Nodes" }
              }
            ],
            "ComparisonOperator" : "GreaterThanThreshold"
        }
    }
  },
  "Outputs" : {
    "ScaleUpTrigger" : {
      "Description" : "Scale Up Policy Trigger",
      "Value" : { "Fn::Join" : [ "", [ "ScaleUpTrigger=", { "Ref" : "ScaleUpPolicy" } ]] }
    }
  }
}

Rabi Mishra (rabi)
Changed in heat:
assignee: nobody → Rabi Mishra (ramishra)
Revision history for this message
Rabi Mishra (rabi) wrote :

It does not work with custom template resource mapping. Looks like the custom resource template is not in sync with property changes and treats some properties as strings rather than lists.

Changed in heat:
status: New → Confirmed
Steven Hardy (shardy)
Changed in heat:
importance: Undecided → High
milestone: none → juno-1
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/94780

Changed in heat:
status: Confirmed → In Progress
Steven Hardy (shardy)
tags: added: icehouse-backport-potential
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to heat (master)

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

commit ce62bdc1925d9e746289c43bc0b76b41df8f2d53
Author: Rabi Mishra <email address hidden>
Date: Mon Jun 2 16:28:27 2014 +0530

    Fix default template for AWS::CloudWatch::Alarm with Ceilometer

    Existing template assumes certain parameters to be delimited
    strings rather than lists and uses 'Fn::Split' to convert them
    to list. However, delimitedstring representations of parameters
    are by default converted to list for CommaDelimitedList types.
    Also includes change for CommaDelimitedList to accept empty string.

    Change-Id: Ib566f1d098c575a80c4f1a975eaaaac93d70af34
    Closes-Bug: #1316842

Changed in heat:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in heat:
status: Fix Committed → Fix Released
Revision history for this message
Lars Kellogg-Stedman (larsks) wrote :

I believe that https://review.openstack.org/94780 did not fix this problem. The template in that change has:

  OKActions:
   Type: CommaDelimitedList
   Default: ''

The empty string is not a valid default value for a CommaDelimitedList, and will result in:

  StackValidationFailed: Property error : __alarm__: ok_actions "u''" is not a list

Revision history for this message
Lars Kellogg-Stedman (larsks) wrote :
Revision history for this message
Angus Salkeld (asalkeld) wrote :

Lars,

Note: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html

See the Default value, it's a string not a list:

"Parameters" : {
  "DbSubnetIpBlocks" : {
    "Description" : "Comma-delimited list of three IP blocks",
    "Type" : "CommaDelimitedList",
    "Default" : "10.0.48.0/24, 10.0.112.0/24, 10.0.176.0/24"
  }
}

Thierry Carrez (ttx)
Changed in heat:
milestone: juno-1 → 2014.2
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on heat (master)

Change abandoned by Lars Kellogg-Stedman (<email address hidden>) on branch: master
Review: https://review.openstack.org/123581

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.