Ask Your Question
2

wait condition in HOT heat template

asked 2014-07-09 07:34:31 -0600

Eric GH gravatar image

updated 2014-07-24 15:16:37 -0600

Hi all,

Anyone kindly send me one copy of HOT heat template that utilize the wait conditions (to control the boot sequence).

THANKS A lot!

Eric

I tried snippet as below: Not working for me. From the log seem the signal/curl did not yield any error. Though "first_wait" can not finish the instantiation and "second" never get instantiated.

 first:
    type: OS::Nova::Server
    properties:
      key_name: PCM-I
      flavor: m1.small
      user_data:
        str_replace:
          template: |
            #!/bin/bash -v
            **# TIME-CONSUMING TASKS here**
            /usr/bin/cfn-signal -s true $wait_handle
          params:
            $wait_handle: {get_resource: first_wait_handle}
  first_wait_handle:
    type: AWS::CloudFormation::WaitConditionHandle
  first_wait:
    type: AWS::CloudFormation::WaitCondition
    depends_on: first
    properties:
      Handle: {get_resource: first_wait_handle}
      Timeout: 1000
  second:
    type: OS::Nova::Server
    depends_on: first_wait
    properties:
      key_name: PCM-I
      image: v37
      flavor: m1.small
      networks:
        - port: { get_resource: server2_port }
      user_data: |
        #!/bin/bash
        echo "second is up"

the user data execution yield no error but the VM "second" can not the instantiate.

/usr/bin/cfn-signal -s true http://152.148.165.80:8000/v1/waitcondition//arn%3Aopenstack%3Aheat%3A%3A782fc66f9e654fc887ff8c41f0539125%3Astacks%2Fh01%2F2502b22d-68fa-4f11-9db3-fdd157ba6df7%2Fresources%2Ffirst_wait_handle?Timestamp=2014-07-09T19%3A32%3A57Z&SignatureMethod=HmacSHA256&AWSAccessKeyId=1d9b6cc686994b569c78401989f377b8&SignatureVersion=2&Signature=aJeIaDcktR2uUPpb6BLqvVA3jVGCBTw364FxxWGXa%2Bk%3D 
echo $?
DEBUG [2014-07-09 15:33:43,807] cfn-signal called Namespace(data='Application has completed configuration.', exit=None, exit_code=None, reason='Configuration Complete', success='true', unique_id='00000', url='http://152.148.165.80:8000/v1/waitcondition//arn%3Aopenstack%3Aheat%3A%3A782fc66f9e654fc887ff8c41f0539125%3Astacks%2Fh01%2F2502b22d-68fa-4f11-9db3-fdd157ba6df7%2Fresources%2Ffirst_wait_handle?Timestamp=2014-07-09T19%3A32%3A57Z') 
DEBUG [2014-07-09 15:33:43,807] Running command: curl -X PUT -H 'Content-Type:' --data-binary '{"Status": "SUCCESS", "Reason": "Configuration Complete", "Data": "Application has completed configuration.", "UniqueId": "00000"}' "http://152.148.165.80:8000/v1/waitcondition//arn%3Aopenstack%3Aheat%3A%3A782fc66f9e654fc887ff8c41f0539125%3Astacks%2Fh01%2F2502b22d-68fa-4f11-9db3-fdd157ba6df7%2Fresources%2Ffirst_wait_handle?Timestamp=2014-07-09T19%3A32%3A57Z"

Provision done: 2014-07-09 15:33:43.959063

If I manually run the command in the vm... Same result. (please note that http://152.148.165.80:8000/v1 is Cloudformation address)

[root@h01-first-4uc2my6jgaxh /]# /usr/bin/cfn-signal -e 0 http://152.148.165.80:8000/v1/waitcondition//arn%3Aopenstack%3Aheat%3A%3A782fc66f9e654fc887ff8c41f0539125%3Astacks%2Fh01%2F92dc4efb-2372-4f09-93cf-79cd6efbc69c%2Fresources%2Ffirst_wait_handle?Timestamp=2014-07-22T13%3A41%3A49Z&SignatureMethod=HmacSHA256&AWSAccessKeyId=656537dd84064705a73a8e9bb9c5dd60&SignatureVersion=2&Signature=fXdSTNue0kH8OCjAdU%2BGR72uQacMIsgA7sjWImDegw8%3D
[1] 4817
[2] 4818
[3] 4819
[4] 4820
[root@h01-first-4uc2my6jgaxh /]# DEBUG [2014-07-22 10:36:30,191] cfn-signal called Namespace(data='Application has completed configuration.', exit=None, exit_code='0', reason='Configuration Complete', success='true', unique_id='00000', url='http://152.148.165.80:8000/v1/waitcondition//arn%3Aopenstack%3Aheat%3A%3A782fc66f9e654fc887ff8c41f0539125%3Astacks%2Fh01%2F92dc4efb-2372-4f09-93cf-79cd6efbc69c%2Fresources%2Ffirst_wait_handle?Timestamp=2014-07-22T13%3A41%3A49Z')
DEBUG [2014-07-22 10:36:30,191] Running command: curl -X PUT -H 'Content-Type:' --data-binary '{"Status": "SUCCESS", "Reason": "Configuration Complete", "Data": "Application has completed configuration.", "UniqueId": "00000"}' "http://152.148.165.80:8000/v1/waitcondition//arn%3Aopenstack%3Aheat%3A%3A782fc66f9e654fc887ff8c41f0539125%3Astacks%2Fh01%2F92dc4efb-2372-4f09-93cf-79cd6efbc69c%2Fresources%2Ffirst_wait_handle?Timestamp=2014-07-22T13%3A41%3A49Z"

[1]   Done                    /usr/bin/cfn-signal -e 0 http://152.148.165.80:8000/v1/waitcondition//arn%3Aopenstack%3Aheat%3A%3A782fc66f9e654fc887ff8c41f0539125%3Astacks%2Fh01%2F92dc4efb-2372-4f09-93cf-79cd6efbc69c%2Fresources%2Ffirst_wait_handle?Timestamp=2014-07-22T13%3A41%3A49Z
[2]   Done                    SignatureMethod=HmacSHA256
[3]-  Done                    AWSAccessKeyId=656537dd84064705a73a8e9bb9c5dd60
[4]+  Done                    SignatureVersion=2
[root ...
(more)
edit retag flag offensive close merge delete

Comments

Your snippet looks correct. What part is actually failing?

zaneb gravatar imagezaneb ( 2014-07-14 17:38:10 -0600 )edit

hi zaneb - thanks for the attention.

From the log seem the signal/curl did not yield any error. Though "first_wait" can not finish the instantiation and "second" never get instantiated.

Eric GH gravatar imageEric GH ( 2014-07-14 21:15:19 -0600 )edit

3 answers

Sort by ยป oldest newest most voted
1

answered 2016-12-15 08:23:43 -0600

MikeyB gravatar image

The shell is interpreting the & in the URL as a command separator. See how each of these are interpreted as separate background commands:

[1]   Done                    /usr/bin/cfn-signal -e 0 http://152.148.165.80:8000/v1/waitcondition//arn%3Aopenstack%3Aheat%3A%3A782fc66f9e654fc887ff8c41f0539125%3Astacks%2Fh01%2F92dc4efb-2372-4f09-93cf-79cd6efbc69c%2Fresources%2Ffirst_wait_handle?Timestamp=2014-07-22T13%3A41%3A49Z
[2]   Done                    SignatureMethod=HmacSHA256
[3]-  Done                    AWSAccessKeyId=656537dd84064705a73a8e9bb9c5dd60
[4]+  Done                    SignatureVersion=2

You need to quote the URL:

/usr/bin/cfn-signal -s true '$wait_handle'

or:

/usr/bin/cfn-signal -e 0 'http://152.148.165.80:8000/v1/waitcondition//arn%3Aopenstack%3Aheat%3A%3A782fc66f9e654fc887ff8c41f0539125%3Astacks%2Fh01%2F92dc4efb-2372-4f09-93cf-79cd6efbc69c%2Fresources%2Ffirst_wait_handle?Timestamp=2014-07-22T13%3A41%3A49Z&SignatureMethod=HmacSHA256&AWSAccessKeyId=656537dd84064705a73a8e9bb9c5dd60&SignatureVersion=2&Signature=fXdSTNue0kH8OCjAdU%2BGR72uQacMIsgA7sjWImDegw8%3D'
edit flag offensive delete link more
1

answered 2015-09-21 05:26:19 -0600

AB239 gravatar image

Hi,

I may be very late to put a comment on this, but can anyone share the correct usage of WaitCondition and how I can make other instance dependent on completion of first instance's user data commands.

edit flag offensive delete link more
1

answered 2014-07-10 08:36:29 -0600

HoangDo gravatar image

This script I used depends on, it worked:

https://gist.github.com/dohuyhoang/74...

You can change type:Docker to a normal OS Server to test.

edit flag offensive delete link more

Comments

Thanks HoangDo

I might not have specified my question clearly. The depends_on keyword only control the booting sequence in general, not in accuracy. the depends_on keywords really can not control the "second" to start after the "first"'s time consuming cloud-init steps are done.

Eric GH gravatar imageEric GH ( 2014-07-10 08:46:40 -0600 )edit

you have the point, Eric. I just encounter it right now. depends_on doesn't wait for user_data to finish.

sorry for bad answer. I'll test wait condition. I'm following this question as well.

HoangDo gravatar imageHoangDo ( 2014-07-10 10:53:30 -0600 )edit

NP HoangDo. We are all learning here :) Now the HOT template supports the updateWaitcondition. So assume this (boot)waitcondition will be supported too. so let's wait for guru to share the snippet.

Eric GH gravatar imageEric GH ( 2014-07-10 12:20:08 -0600 )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

1 follower

Stats

Asked: 2014-07-09 07:34:31 -0600

Seen: 5,358 times

Last updated: Dec 15 '16