ClusterLabs / resource-agents

Combined repository of OCF agents from the RHCS and Linux-HA projects
GNU General Public License v2.0
491 stars 582 forks source link

ocf:heartbeat:VirtualDomain defines the domain #240

Closed liedekef closed 10 years ago

liedekef commented 11 years ago

In the old days (using vm.sh and rgmanager), a domain was never defined on a kvm server. In stead "virsh create" was used to start a domain in a non-persistent way and when a live migration happened, the domain then just moved to the other side without issues or traces on the original kvm server. Now I have 2 kvm servers that both have all virtual machines defined, which is imho dangerous if somebody just did a "virsh start" on the wrong kvm server ... Sanlock or virtlockd protects against that of course, but still ...

It seems the "define" is used here for 2 things:

To get the domain name, one could simply do: egrep ".$" /path/to/XMLFILE |sed -e 's/.(.*)<\/name>$/\1/'

And to get the domain state (since running is the one that interests us), the main logic of the function VirtualDomain_Status() would be: virsh list|grep running|grep DOMAINNAME

As a result, the functions VirtualDomain_Define() and VirtualDomain_Cleanup_Statefile() could be removed, and also the use of a statefile per domain (containing just the domain name) would no longer be needed.

One could argue that we could use a undefine when stopping a vm, and a --undefinefromsource when migrating, but in the case the kvm server crashes it would still leave the domain defined.

If there's interest in a patch, I can create one ...

Franky

dmuhamedagic commented 11 years ago

@fghaas Florian, what do you say about this?

fghaas commented 11 years ago

Makes sense to me, would be happy to review a patch.

liedekef commented 11 years ago

Ok, I'll create a github pull-request for this.

bootc commented 10 years ago

I'm very concerned about this change to the VirtualDomain script. In all the examples I can see, including on http://www.linux-ha.org/wiki/VirtualDomain_(resource_agent), the domain XML file is kept under /etc/libvirt/qemu/{domain}.xml (e.g. params config="/etc/libvirt/qemu/test.xml" hypervisor="qemu:///system"). With this configuration, the XML file vanishes when the resource agent attempts to start the VM; it gets undefined first, then create attempts to start it.

While I agree with the general idea of the change, I can see this breaking a lot of existing configurations.

liedekef commented 10 years ago

@bootc : this change does not undefine the existing domains. You're referring to another change made to this resource agent, so I think you should either create a new issue voicing your concerns or comment on the changes made there: https://github.com/ClusterLabs/resource-agents/commit/f00dcaf19467e3d96d9790d386b860b53ca381f9