Hot Software Config Dependencies

Registered by JunJie Nan on 2013-08-02

Two or more software configs defined in hot, if they are hosted on same server, the sequence in config set can be used to handle their dependencies. This blueprint is for cross server dependencies handling.

Send signal and receive signal mechanism will be introduced, key points:
1. One wait Condition generated,
2. One wait condition handle generated,
3. Send signal via cfn-signal,
4. Receive signal via cfn-get-metadata -r WaitConditionHandle
5. For software config B depends on software config A:
   Send signal when a software A config done, wait signal when a software B config begin,
6. Send signal when the last software configuration done.
7. Wait condition count is same with the software config number
8. Make sure wait condition handle created first and wait condition created last

Send signal and receive signal via native in instance tools.

Blueprint information

Status:
Complete
Approver:
Steven Hardy
Priority:
Undefined
Drafter:
JunJie Nan
Direction:
Needs approval
Assignee:
JunJie Nan
Definition:
Obsolete
Series goal:
None
Implementation:
Good progress
Milestone target:
None
Started by
JunJie Nan on 2013-09-10
Completed by
Steve Baker on 2013-11-19

Related branches

Sprints

Whiteboard

Discussion at: https://wiki.openstack.org/wiki/Heat/Blueprints/hot-software-config-deps

-----DEPRECATED------
A software component, for example:
...
components:
  config_mysql:
    type: OS::Heat::SoftwareConfig
    properties:
      - dbname: wordpress
    scripts:
      init: /tmp/config_mysql.sh
      files:
        - target: /tmp/config_mysql.sh
          source:http://www.example.com/config_mysql.sh
    requires:
      hosted_on: mysql
  config_wordpress:
    type: OS::Heat::SoftwareConfig
    properties:
      - dbname: wordpress
    scripts:
      init: /tmp/config_wordpress.sh
      files:
        - target: /tmp/config_wordpress.sh
          source:http://www.example.com/config_wordpress.sh
    requires:
      hosted_on: wordpress
      depends_on: config_mysql
resources:
  wordpress:
    type: AWS::EC2::Instance
  mysql:
    type: AWS::EC2::Instance
...

will be translated into(in yaml format):

...
Resources:
  wordpress:
    Type: AWS::EC2::Instance
    DependsOn: mysql
    Metadata:
      AWS::CloudFormation::Init:
        configSets:
          default: [config_mysql, config_wordpress]
        config_mysql:
          commands:
            config:
              env:
                - dbname: wordpress
              command:
                - while true; do
                - cfn-get-template -r WaitHandle -s StackName --credential-file /etc/cfn/cfn-credentials 2>/dev/null > signals.txt
               - read signal.txt and check
               - if get it, break
               - sleep 10;
               - done
              files:
               /etc/cfn/cfn-credentials:
                content:
                ...
                  - |
                  AWSAccessKeyId={Ref: ServerKeys}
                  AWSSecretKey={'Fn::GetAtt': [ServerKeys, SecretAccessKey]}
              mode: '000400'
              owner: root
              group: root
        config_wordpress:
          commands:
            config:
              env:
                - dbname: wordpress
              command:
                - chmod u+x /tmp/config_wordpress.sh
                - /tmp/config_wordpress.sh
                - cfn-signal to complete stack creation
              files:
                - /tmp/config_wordpress.sh : http://www.example.com/config_wordpress.sh
      UserData:
      ......
            #!/bin/bash -v
            cfn-init
  mysql:
    Type: AWS::EC2::Instance
    Metadata:
      AWS::CloudFormation::Init:
        configSets:
          default: [config_mysql]
        config_mysql:
          commands:
            config:
              env:
                - dbname: wordpress
              command:
                - chmod u+x /tmp/config_mysql.sh
                - /tmp/config_mysql.sh
                - cfn-signal ...
              files:
                - /tmp/config_mysql.sh : http://www.example.com/config_mysql.sh
      UserData:
      ......
            #!/bin/bash -v
            cfn-init
  CfnUser:
    Type: 'AWS::IAM::User'
     DependsOn:WaitHandle
  ServerKeys:
    Type: 'AWS::IAM::AccessKey'
    DependsOn:CfnUser
    Properties:
      UserName:
        Ref: CfnUser
  WaitHandle
    Type: 'AWS::CloudFormation::WaitConditionHandle'
  WaitCondition:
    Type: 'AWS::CloudFormation::WaitCondition'
    DependsOn: wordpress
    Properties:
      Handle: {Ref: WaitHandle}
      Count: '2'
      Timeout: '600'
...

More software configs will be translated into more configSets and added into default.

Gerrit topic: https://review.openstack.org/#q,topic:bp/hot-software-config-deps,n,z

Addressed by: https://review.openstack.org/45840
    Handle cross instance depends on

(stevebaker) I think blueprint hot-software-config covers this. It is not obvious yet that this blueprint is a standalone task, it might be too integrated with core hot-software-config to break out into its own blueprint.

(?)

Work Items

This blueprint contains Public information 
Everyone can see this information.