Ask Your Question
0

VMs / stacks described in a template created and deployed in parallel or serially?

asked 2013-06-13 21:16:15 -0500

lakshminarayanan-r gravatar image

Hi,

I am interested in understanding how Heat deploys a template that specifies multiple VMs. For example, consider a template that creates 1 apache vm, 1 tomcat vm, and 1 mysql vm. Will Heat start creating and deploying these three VMs in parallel (i.e., concurrently) or will do it serially (in some order)?

I am also interested in Heat's VM creation scheme, when the template has multiple VMs and there are dependencies between them. For example, consider a dependency between the tomcat vm and the mysql vm, in the above scenario. With such dependencies, will Heat create the VMs in parallel or serially?

I would greatly appreciate any info / pointers (even to the right section of Heat code :-) )

Thanks for your time, LN

edit retag flag offensive close merge delete

6 answers

Sort by ยป oldest newest most voted
0

answered 2013-06-14 11:25:12 -0500

zaneb gravatar image

Excellent question.

In the Grizzly (2013.1) version of Heat, VMs will be created serially (in dependency order if dependencies exist). In the current development version of Heat (and in the eventual Havana release) the VMs will be created in parallel provided that they do not have any dependencies on each other.

Dependencies are mostly created automatically. If you use the "Ref" or "Fn::GetAtt" functions within a resource to refer to another resource, then that creates a dependency between them. This generally just works how you would want - e.g. if your Tomcat VM configuration uses {"Fn::GetAtt": ["MySqlVM", "PrivateIp"]} to get the IP address of your MySQL VM, then the Tomcat one will not be created until after the MySQL one has been (and hence it's IP address is known).

You can also add dependency manually, by adding e.g. "DependsOn": "MySqlVM" to the resource definition.

Note, however, that a VM is considered created as soon as Nova has started it. If you want to wait for the guest OS to actually boot and/or for applications to be installed/started then you need to add a WaitCondition resource to your template. In the Instance's UserData script, you post a notification to the URL of the corresponding WaitConditionHandle when everything is ready. The WaitCondition will wait until this notification is received. (The WaitCondition usually "DependsOn" the Instance that is expected to notify it, so that it's timeout period starts only once the VM is created.) You can then mark that another resource "DependsOn" the WaitCondition.

edit flag offensive delete link more
0

answered 2013-06-14 14:10:58 -0500

lakshminarayanan-r gravatar image

Thanks Zane Bitter, that solved my question.

edit flag offensive delete link more
0

answered 2013-06-14 14:41:08 -0500

lakshminarayanan-r gravatar image

Hi Zane,

Thanks very much for the detailed reply.

I have a follow up question regarding when and how Heat determines a dependence is satisfied and hence starts the creation of the dependent resource.

Consider a template that creates two VMs, say vmA and vmB, with the following properties:

-- vmA needs the IP address of vmB and uses a Ref to get that

-- vmB has UserData that installs a lot of applications, after the VM is created.

Now, I assume that Heat will first create vmB and then create vmA. When does the creation of vmA start? After vmB (the base vm) is created, i.e, Nova has started vmB? or After Nova has started vmB AND all its UserData scripts are executed?

I am also interested in looking at the

  1. code that analyzes the template for Ref, Fn::GetAtt and builds the dependence graph (I am assuming an explicit dependence graph is built)

  2. code that uses the dependence graph to enforce the order of VM creation.

Can you please point me to these parts of the code?

Once again, thanks very much for your time and I greatly appreciate the help.

LN

edit flag offensive delete link more
0

answered 2013-06-14 18:33:14 -0500

zaneb gravatar image

Sure, no problem :)

vmA will start as soon as Nova has finished building vmB. (And we may modify it in the future to start even sooner - as soon as the call to Nova has completed.) It will not wait for the UserData scripts on vmB to run, or even for vmB to boot.

If you did want to wait for the UserData script to complete, you would use a WaitCondition and signal it at the end of the UserData script, then add a manual dependency on the WaitCondition resource, as described above.

Dependencies for each resource are calculated in the Resource.add_dependencies() method in heat/engine/resource.py. The Stack object gets each of its resources to add its dependencies to the Stack's dependency list in Stack._get_dependencies() in heat/engine/parser.py. The code for the dependency graph itself is in heat/engine/dependencies.py.

The stack creation is called from Stack.create_task(), and the order is enforced by the DependencyTaskGroup in heat/engine/scheduler.py.

https://github.com/openstack/heat/blob/master/heat/engine/parser.py (https://github.com/openstack/heat/blo...) https://github.com/openstack/heat/blob/master/heat/engine/resource.py (https://github.com/openstack/heat/blo...) https://github.com/openstack/heat/blob/master/heat/engine/dependencies.py (https://github.com/openstack/heat/blo...) https://github.com/openstack/heat/blob/master/heat/engine/scheduler.py (https://github.com/openstack/heat/blo...)

edit flag offensive delete link more
0

answered 2013-06-14 20:15:31 -0500

lakshminarayanan-r gravatar image

Hi Zane,

Thank you very much for the clarification and pointers to the code!

Thanks, LN

edit flag offensive delete link more
0

answered 2013-06-14 20:15:55 -0500

lakshminarayanan-r gravatar image

Thanks Zane Bitter, that solved my question.

edit flag offensive delete link more

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: 2013-06-13 21:16:15 -0500

Seen: 424 times

Last updated: Jun 14 '13