Ask Your Question
2

HARestarter with HOT

asked 2014-07-02 02:56:31 -0500

erivni gravatar image

updated 2014-09-17 10:14:10 -0500

larsks gravatar image

Hi all,

I'm trying to create a template which will restart a server on shut down. I'm using a OS::Heat::CWLiteAlarm as an alarm notifier and a OS::Heat::HARestarter as a restart policy. My problem is that heat-engine restarts my server even if my server is up and running. What am I missing?

Thanks, Einav.

-- My template --

heat_template_version: 2013-05-23

description: >
  Simple demonstrating the use of the HARestarter resource, triggering restart 
  via a pre-signed URL

parameters:

  key_name:
    type: string
    description: Name of an existing key pair to use for the instance
  flavor:
    type: string
    description: flavor for the instance to be created
    constraints:
      - allowed_values: [m1.medium, m1.large]
        description: Value must be one of 'm1.medium' or 'm1.large'
  image:
    type: string
    description: Name of the image to use for the instance
  availability_zone:
    type: string 
    description: The Availability Zone in which to launch the instance.
  network_id:
    type: string
    description: ID of network into which servers get deployed
  security_group_id:
    type: string
    description: ID of security group for this instance port

resources:

  server:
    type: OS::Nova::Server
    properties:
      name: restart_instance
      flavor: { get_param: flavor }
      image: { get_param: image }
      key_name: { get_param: key_name }
      availability_zone: { get_param: availability_zone }
      networks:
        - network: { get_param: network_id }
      security_groups: 
        - { get_param: security_group_id }
      user_data:  |
            #!/bin/bash -x
            touch /root/test
            echo "Hello, World!" > /root/test

  restart_policy:
    type: OS::Heat::HARestarter
    properties:
      InstanceId: {get_resource: server} 

  heartbeat_failure_alarm:
    type: OS::Heat::CWLiteAlarm
    properties:
      AlarmActions:  [{ get_resource: restart_policy}]
      AlarmDescription: Restart the Server if it goes down
      ComparisonOperator: LessThanThreshold
      EvaluationPeriods: '1'
      MetricName: Heartbeat
      Namespace: system/linux
      Period: '60'
      Statistic: SampleCount
      Threshold: '1'

outputs:
  RestartURL:
    description: URL to trigger instance restart
    value: { get_attr : [ restart_policy, AlarmUrl ] }
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2014-09-28 23:51:47 -0500

asalkeld gravatar image

Hi

You need to call cfn-push-stats within your server (it is using a Heat beat mechanism, so you need to send the heartbeat - which you are not doing atm).

Have a look here: (watch out this template is a bit old) https://github.com/openstack/heat-tem...

Basically you need to periodically (safely within the period you set in the alarm) call: cfn-push-stats --heartbeat

Note: Do not use the --watch option, it's old and not needed anymore.

Here is some general info about Heat alarms: http://ahsalkeld.wordpress.com/2014/0...

edit flag offensive delete link more

Comments

@asalkeld: Thanks for the info! Is there an example that uses OS::Ceilometer::Alarm, or must CWLiteAlarm be used? The linked template refers to AWS::IAM::AccessKey and SecretAccessKey, so it's unclear how cfn-push-stats would work. n.b.: I realize HARestarter is going the way of the dodo. Still ...

jdandrea gravatar imagejdandrea ( 2014-09-29 16:47:57 -0500 )edit

I have a nice CircularDependancyException.. The instance requires the alarm, the alarm requires the restarter and the restarter depends on the instance ~ http://hastebin.com/zepivelume.sm

MentheAlow gravatar imageMentheAlow ( 2015-04-10 09:47:36 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

Stats

Asked: 2014-07-02 02:56:31 -0500

Seen: 848 times

Last updated: Sep 28 '14